Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

THIS CODE GIVES THE LOGIC OF PRINTING ADOBE FORMS WHICH ARE CONFIGURED IN NACE WITH THE FORM ROUTINE BEING ENTRY IN THE BELOW SNIPPET.

REPORT  zlf_adobe_report.
INCLUDE zlr_global_data.
INCLUDE zlr_data_forms.
INCLUDE zlr_print_forms.
*---------------------------------------------------------------------*
*       FORM ENTRY
*---------------------------------------------------------------------*
FORM entry USING return_code like sy-subrc
                 us_screen   type c.
  DATA: lf_retcode TYPE sy-subrc.
  xscreen = us_screen.                 "Screen Used for Display
  PERFORM processing USING    us_screen
                     CHANGING lf_retcode.
  IF lf_retcode NE 0.
    return_code = 1.
  ELSE.
    return_code = 0.
  ENDIF.
ENDFORM.                               "ENTRY
**---------------------------------------------------------------------*
**       FORM PROCESSING                                               *
**---------------------------------------------------------------------*
FORM processing USING    xscreen    type c
                CHANGING cf_retcode like sy-subrc.
  DATA: ls_print_data_to_read TYPE ledlv_print_data_to_read. "Structure For setting print output
  DATA: ls_dlv_delnote        TYPE ledlv_delnote.                         "Structure having Delivery Details
  DATA: lf_fm_name            TYPE rs38l_fnam.                            "Function Module name
  DATA: lf_formname           TYPE fpname.                                "Form Name
  DATA: ls_addr_key           LIKE addr_key.                              "Address Structure
* Pdfname from customizing table TNAPR
  lf_formname = tnapr-sform.
* Determine print data
  PERFORM set_print_data_to_read CHANGING ls_print_data_to_read.
* Set data to print
  PERFORM get_data USING      ls_print_data_to_read
                   CHANGING   ls_addr_key
                              ls_dlv_delnote
                              cf_retcode.
* Set print data requirements
  IF cf_retcode = 0.
* Determine PDF function module for Certificate of guarantee
    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
      EXPORTING
        i_name     = lf_formname
      IMPORTING
        e_funcname = lf_fm_name.
*   E_INTERFACE_TYPE           =
  ENDIF.
  CALL FUNCTION 'FP_JOB_OPEN'
    CHANGING
      ie_outputparams = ls_output_param
    EXCEPTIONS
      cancel          = 1
      usage_error     = 2
      system_error    = 3
      internal_error  = 4
      OTHERS          = 5.
  IF sy-subrc <> 0.
   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  ls_doc_param-langu = nast-spras.
* Calling the function module and passing the form interface values
  CALL FUNCTION lf_fm_name
    EXPORTING
     /1bcdwb/docparams         = ls_doc_param
      is_delnote                        = ls_dlv_delnote
* IMPORTING
*   /1BCDWB/FORMOUTPUT       =
   EXCEPTIONS
     usage_error              = 1
     system_error             = 2
     internal_error           = 3
     OTHERS                   = 4
            .
  IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Close spool job
  CALL FUNCTION 'FP_JOB_CLOSE'
*   IMPORTING
*     E_RESULT             = result
   EXCEPTIONS
     USAGE_ERROR          = 1
     SYSTEM_ERROR         = 2
     INTERNAL_ERROR       = 3
     OTHERS               = 4
             .
  IF sy-subrc <> 0.
   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                               "PROCESSING
*&---------------------------------------------------------------------*
*&  Include           ZLR_GLOBAL_DATA
*&---------------------------------------------------------------------*
DATA:
  ls_doc_param       TYPE sfpdocparams, "Doc Parameters
  ls_output_param    TYPE sfpoutputparams,
                                       "Output Parameters
  result            TYPE sfpjoboutput. "Output parameter returned in job close
TABLES: nast,                          "Messages
        tnapr,                         "Programs & Forms
        addr_key.                      "Adressnumber for ADDRESS
TYPE-POOLS szadr.
DATA:   xscreen(1)   TYPE c.           "Output on printer or screen
DATA:
  ship_to_address    TYPE zaddress,    "Structure for Ship-to Address
  bill_to_address    TYPE zaddress,    "Structure for Bill-to Address
  bill_to            TYPE kunnr,       "Bill to number
  w_landkey(2)       TYPE c,           "Landkey
  it_del_items       TYPE ZLE_T_DLV_IT_GEN.
                                       "Item Table Details
*&---------------------------------------------------------------------*
*&  Include           ZLR_DATA_FORMS
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
*       FORM GET_DATA                                                 *
*---------------------------------------------------------------------*
*       General provision of data for the form                        *
*---------------------------------------------------------------------*
FORM get_data
     USING    is_print_data_to_read TYPE ledlv_print_data_to_read
     CHANGING cs_addr_key           LIKE addr_key
              cs_dlv_delnote        TYPE ledlv_delnote
              cf_retcode            TYPE sy-subrc.
  DATA:
    ls_delivery_key TYPE  leshp_delivery_key. "Delivery Number
    ls_delivery_key-vbeln = nast-objky.
*Function module get fills the structure ledlv_delnote according to exporting parameters
  CALL FUNCTION 'LE_SHP_DLV_OUTP_READ_PRTDATA'
    EXPORTING
      is_delivery_key       = ls_delivery_key
      is_print_data_to_read = is_print_data_to_read
      if_parvw              = nast-parvw
      if_parnr              = nast-parnr
      if_language           = nast-spras
    IMPORTING
      es_dlv_delnote        = cs_dlv_delnote
    EXCEPTIONS
      records_not_found     = 1
      records_not_requested = 2
      OTHERS                = 3.
  IF sy-subrc <> 0.
*  error handling
    cf_retcode = sy-subrc.
    PERFORM protocol_update.
  ENDIF.
* get nast partner adress for communication strategy
  PERFORM get_addr_key USING    cs_dlv_delnote-hd_adr
                       CHANGING cs_addr_key.
ENDFORM.                     "GET_DATA
*---------------------------------------------------------------------*
*       FORM SET_PRINT_DATA_TO_READ                                   *
*---------------------------------------------------------------------*
*       General provision of data for the form                        *
*---------------------------------------------------------------------*
FORM set_print_data_to_read
         CHANGING cs_print_data_to_read TYPE ledlv_print_data_to_read.
* Set print data requirements
  cs_print_data_to_read-hd_gen = 'X'.
  cs_print_data_to_read-hd_ref = 'X'.
  cs_print_data_to_read-it_gen = 'X'.
  cs_print_data_to_read-hd_adr = 'X'.
ENDFORM.                               "SET_PRINT_DATA_TO_READ
*&---------------------------------------------------------------------*
*&      Form  get_addr_key
*&---------------------------------------------------------------------*
FORM get_addr_key USING    it_hd_adr   TYPE ledlv_delnote-hd_adr
                  CHANGING cs_addr_key LIKE addr_key.
  FIELD-SYMBOLS <fs_hd_adr> TYPE LINE OF ledlv_delnote-hd_adr.
  READ TABLE it_hd_adr ASSIGNING <fs_hd_adr>
                       WITH KEY deliv_numb = nast-objky
                                partn_role = nast-parvw.
  IF sy-subrc = 0.
    cs_addr_key-addrnumber = <fs_hd_adr>-addr_no.
    cs_addr_key-persnumber = <fs_hd_adr>-person_numb.
    cs_addr_key-addr_type  = <fs_hd_adr>-address_type.
  ENDIF.
ENDFORM.                               " get_addr_key
*&---------------------------------------------------------------------*
*&  Include           ZLR_PRINT_FORMS
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
*       FORM PROTOCOL_UPDATE                                          *
*---------------------------------------------------------------------*
*       The messages are collected for the processing protocol.       *
*---------------------------------------------------------------------*
FORM protocol_update.
  CHECK xscreen = space.
  CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
    EXPORTING
      msg_arbgb = syst-msgid
      msg_nr    = syst-msgno
      msg_ty    = syst-msgty
      msg_v1    = syst-msgv1
      msg_v2    = syst-msgv2
      msg_v3    = syst-msgv3
      msg_v4    = syst-msgv4
    EXCEPTIONS
      OTHERS    = 1.
ENDFORM.                               "PROTOCOL_UPDATE