Skip to Content
Technical Articles
Author's profile photo Sowmya B K1733

Embed images in adobe form dynamically

The requirement is to embed a image in adobe form dynamically. With the help of two function modules. At first by passing the key, to the function module SCMS_R3DB_IMPORT the file name and the binary content are extracted. The length of the binary content and the contents are passed to the function module SCMS_BINARY_TO_XSTRING.  This xstring is now passed on to the adobe form like a graphic in the interface. The binding is done for the insertion of the image field.

Function modules used :

SCMS_R3DB_IMPORT

Crep_id , Doc_id is the input parameters. In it_content_info and it_content_bin the name of the file and the contents are extracted.

SCMS_BINARY_TO_XSTRING

The length and the binary contents are passed and the xstring is fetched.

Please find the code snippet:

Pass the root key from the table.

SELECT ATF_FILE_KEY FROM EHHSSD_INC_ATDOC INTO  TABLE IT_FIN 
WHERE PARENT_KEY = lv_inc_root AND  USER_ID_CH ne 'SAP_WFRT'.

  READ TABLE IT_FIN INTO WA_FIN INDEX 1.
  LV_ATF_FILE_KEY1 = WA_FIN-LV_ATF_FILE_KEY.

 call function 'SCMS_R3DB_IMPORT'
  exporting
    crep_id            = 'BS_ATF_DB_REPOSITORY'
    doc_id             = LV_ATF_FILE_KEY1
 IMPORTING
   DOC_PROT           =  ld_doc_prot
  CREA_TIME          =    ld_crea_time
   CHNG_TIME          =  ld_chng_time
 TABLES
   CONTENT_INFO       =   it_content_info
   CONTENT_TXT        =   it_content_txt
   CONTENT_BIN        =   it_content_bin
 EXCEPTIONS
   ERROR_IMPORT       = 1
   ERROR_CONFIG       = 2
   OTHERS             = 3
          .
if sy-subrc <> 0.
* Implement suitable error handling here
endif.

LOOP AT it_content_info into wa_bin.
lv_len = wa_bin-comp_size.
ENDLOOP.

string = wa_bin-comp_id.

call function 'SCMS_BINARY_TO_XSTRING'
  exporting
    input_length       = lv_len
 IMPORTING
  BUFFER               =  xstring
  tables
    binary_tab         =  it_content_bin
 EXCEPTIONS
   FAILED             = 1
   OTHERS             = 2
          .
if sy-subrc <> 0.
* Implement suitable error handling here
endif.

Thus the binding is done and then the image is displayed. The image is displayed dynamically.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo hendi hendi
      hendi hendi

      Hi Sowmya,

      Nice post... thank for sharing.

      Author's profile photo Ajit Mhatre
      Ajit Mhatre

      if we have read the document type pdf/word how to use that in adobe form as extra data in adobe form ?

      Author's profile photo Alberto Alfaro
      Alberto Alfaro

      Hi Sowmya,,

      I know this is a little old, but if you can please help me.

      This works just fine to create the XSTRING, however I'm struggling with displaying the image in the form. I have created an object type "Image Type" with binding to the variable that contains this XSTRING, however when I preview it it shows the first characters of the XSTRING, not any image.

      Can you explain this part?, as it's not in your original article.

      Regards,
      Alberto