SAP functions for posting

Object Service attachments (eg add form to employee record)

The following example shows how to add a PDF form to an employee master record:

FUNCTION z_fpe_hr_pid_attach_470.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"    VALUE(FORMS_DATA) TYPE  /FLM/XML_TAB_T
*"    VALUE(SEQUENCE) TYPE  /FLM/PROCESS_SEQ
*"    VALUE(DIALOGUE_MODE) TYPE  CHAR1
*"  EXPORTING
*"    VALUE(POSTED_DOC) TYPE  /FLM/PDOC
*"    VALUE(RETURN) TYPE  BAPIRETURN1
*"    VALUE(NO_POST_ATTEMPT) TYPE  FLAG
*"----------------------------------------------------------------------

  DATA: l_ccode    TYPE /flm/cust_code,
        l_ftype    TYPE /flm/ftype_code,
        l_flang    TYPE spras,
        l_fver      TYPE /flm/fver,
        l_fid      TYPE /flm/fid,
        l_fid_var  TYPE /flm/id_var,
        l_faction  TYPE /flm/faction,
        l_fstatus  TYPE /flm/fstatus,
        l_email    TYPE /flm/email_send,
        l_cms_index TYPE /flm/cms_index,
        l_data_cms  TYPE /flm/cms_doc,
        l_temp_cms  TYPE /flm/cms_doc,
        l_data      TYPE /flm/xml_tab,
        l_form_data TYPE /flm/xml_tab_t,
        l_xpdf      TYPE xstring,
        l_mess_ret  TYPE bapiret2,
        l_bo_key    TYPE swo_typeid,
        l_subrc    TYPE sysubrc,
        l_v1        TYPE symsgv,
        l_v2        TYPE symsgv.
*
  l_form_data = forms_data.
*
  READ TABLE l_form_data WITH KEY name = 'FLM_RETURN' INTO l_data.
*
  SPLIT l_data-value AT '+' INTO l_faction l_data_cms l_email.
*
  CALL METHOD /flm/core=>split_xdp_cms_doc
    EXPORTING
      im_cms_doc  = l_data_cms
    IMPORTING
      ex_ccode    = l_ccode
      ex_ftype    = l_ftype
      ex_flang    = l_flang
      ex_fver      = l_fver
      ex_fid      = l_fid
      ex_fid_var  = l_fid_var
      ex_cms_index = l_cms_index.
*
* Get latest variant
*
  CALL METHOD /flm/core=>get_latest_variant
    EXPORTING
      im_ccode  = l_ccode
      im_ftype  = l_ftype
      im_flang  = l_flang
      im_fver    = l_fver
      im_fid    = l_fid
    IMPORTING
      ex_variant = l_fid_var.
*
* Update CMS data document
*
  CALL METHOD /flm/core=>gen_cms_doc
    EXPORTING
      im_ccode  = l_ccode
      im_ftype  = l_ftype
      im_flang  = l_flang
      im_fver    = l_fver
      im_fid    = l_fid
      im_fid_var = l_fid_var
    IMPORTING
      ex_cms_doc = l_data_cms.
*
  SELECT SINGLE fstatus FROM  /flm/fpe INTO l_fstatus
        WHERE  ccode  = l_ccode
        AND    ftype  = l_ftype
        AND    flang  = l_flang
        AND    fver    = l_fver
        AND    id      = l_fid
        AND    id_var  = l_fid_var.
*
  CALL METHOD /flm/core=>gen_cms_doc
    EXPORTING
      im_ccode  = l_ccode
      im_ftype  = l_ftype
      im_flang  = l_flang
      im_fver    = l_fver
    IMPORTING
      ex_cms_doc = l_temp_cms.
*
  CALL METHOD /flm/core=>get_full_pdf
    EXPORTING
      im_data_cms    = l_data_cms
      im_temp_cms    = l_temp_cms
      im_fillable    = ' '
      im_fstatus      = l_fstatus
      im_user        = sy-uname
      im_app_document = ''
      im_ftransport  = '1'
      im_email_rece  = ''
      im_prepop_off  = ' '
    IMPORTING
      ex_pdf          = l_xpdf
      ex_mess        = l_mess_ret.
*
  READ TABLE l_form_data WITH KEY name = 'FLD_PID' INTO l_data.
  l_bo_key = l_data-value.
*
  CALL FUNCTION 'Z_CO_LG_UPDATE_SAP'
    EXPORTING
      im_xpdf  = l_xpdf
      im_bo_key = l_bo_key
      im_ccode  = l_ccode
      im_ctype  = 'HPD2'
      im_clang  = l_flang
      im_cver  = l_fver
      im_fid    = l_fid
    IMPORTING
      ex_subrc  = l_subrc
      ex_v1    = l_v1
      ex_v2    = l_v2.
*
  IF l_subrc EQ 0.
    posted_doc = l_bo_key.
  ENDIF.
*

ENDFUNCTION.
Chris Scott Send private email
Friday, July 24, 2009
 
 
Note that some FLM Correspondence Management configuration is required!
Chris Scott Send private email
Friday, July 24, 2009
 
 
Powered by FogBugz