Tuesday, May 21, 2013

Display employee picture in an adobe form report



Hi,

I want to show the process to display employee picture in an adobe form report which upload from t-code OAAD.

Step 1: Call FM 'BAPI_EMPLOYEE_GETDATA' to get Archive Link ID and Archive Link Document ID.

 CALL FUNCTION 'BAPI_EMPLOYEE_GETDATA'
 EXPORTING
   employee_id            = p_pernr

   date                   = sy-datum
*   EXTENSION              =
*   READDB                 = FALSE
*   ORGTXT_LG              =
*   JOBTXT_LG              =
*   POSTXT_LG              =
*   AUTHORITY_CHECK        = 'X'
* IMPORTING
*   RETURN                 =
 TABLES
   org_assignment         = org_assignment
   personal_data          = personal_data
   internal_control       = internal_control
   communication          = communication
   archivelink            = archivelink.

Step 2: User can upload more than one picture so I took the latest one.


SORT archivelink BY ar_date DESCENDING.
READ TABLE archivelink INTO wa_archivelink INDEX 1



Step 3: Call FM 'SCMS_R3DB_IMPORT' and pass Archive Link ID and Archive Link Document ID to get binary document contents.

CALL FUNCTION 'SCMS_R3DB_IMPORT'
  EXPORTING
    mandt        = sy-mandt
    crep_id      = wa_archivelink-archiv_id
    doc_id       = wa_archivelink-arc_doc_id
  TABLES
    content_info = lt_content_info
    content_txt  = lt_content_txt
    content_bin  = lt_content_bin
  EXCEPTIONS
    error_import = 1
    error_config = 2
    OTHERS       = 3.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.



Step 4: Now call FM 'SCMS_BINARY_TO_XSTRING' the XSTRING value.



READ TABLE lt_content_info INTO lw_file_info INDEX 1.

IF sy-subrc IS INITIAL.
  l_fl = lw_file_info-first_line.
  l_ll = lw_file_info-last_line.
  l_fs = lw_file_info-comp_size.

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length = l_fs
      first_line   = l_fl
      last_line    = l_ll
    IMPORTING
      buffer       = l_url
    TABLES
      binary_tab   = lt_content_bin
    EXCEPTIONS
      failed       = 1
      OTHERS       = 2.

ENDIF.

Step 5: Append your value to the internal table.

Now go to your Adobe forms.

    Add Graphic in the table.
    Change the property Graphic Type as Graphic Content.
    In Field use your XSTRING field.
    Set MIME Type as 'JPG/BMP'.
UA-40152711-1