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

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.