Skip to Content

This code illustrates how we can use the standard includes in SAP to fetch data for a packing slip in SMART FORMS. This approach helps in fast and accurate data being fetched every time a packing list is triggered.

 

*** Include Programs

INCLUDE zerpsdpi_pcklst_top.

 

***Standard includes********************************8

INCLUDE rle_delnote_data_declare.

INCLUDE rle_delnote_forms.

INCLUDE rle_print_forms.

 

*&———————————————————————*

*&      Form  entry

*&———————————————————————*

 

 

FORM entry USING return_code us_screen.

 

xscreen = us_screen.

PERFORM processing USING    us_screen

CHANGING dgv_retcode.

IF dgv_retcode NE 0.

return_code = 1.

ELSE.

return_code = 0.

ENDIF.

 

ENDFORM.                    “entry

**&———————————————————————*

**&      Form  processing

**&———————————————————————*

FORM processing USING    proc_screen

CHANGING cf_retcode.

 

dgv_formname = tnaprsform.    ” Smartform name is moved to global variable.

 

**Selecting Printing Data**———————————————*

 

PERFORM set_print_data_to_read_pdf USING    dgv_formname

CHANGING dgmss_print_data_to_read

cf_retcode.

 

PERFORM get_data USING    dgmss_print_data_to_read

CHANGING dgmss_addr_key

dgmss_dlv_delnote

cf_retcode.

 

PERFORM set_print_param   USING    dgmss_addr_key

CHANGING dgmss_control_param

dgmss_composer_param

dgmss_recipient

dgmss_sender

cf_retcode.

 

PERFORM fetch_data.           ” Subroutine to fetch the required datas which has to be mapped with Smartform.

PERFORM invoke_smartform.     ” Subroutine to invoke Smartform

*  PERFORM get_data_info.

 

ENDFORM.                    “processing

 

*&———————————————————————*

*&      Form  set_print_data_to_read_pdf

*&———————————————————————*

 

FORM set_print_data_to_read_pdf USING    if_formname LIKE tnaprsform

CHANGING cs_print_data_to_read TYPE ledlv_print_data_to_read

cf_retcode.

cs_print_data_to_readhd_ref = ‘X’.

cs_print_data_to_readit_gen = ‘X’.

cs_print_data_to_readit_org = ‘X’.

cs_print_data_to_readit_ref = ‘X’.

cs_print_data_to_readit_reford = ‘X’.

cs_print_data_to_readhd_gen = ‘X’.

cs_print_data_to_readhd_adr = ‘X’.

cs_print_data_to_readhd_org = ‘X’.

cs_print_data_to_readit_fin = ‘X’.

cs_print_data_to_readhd_org_adr  = ‘X’.

cs_print_data_to_readhd_gen_descript = ‘X’.

 

ENDFORM.                    “set_print_data_to_read_pdf

 

*&———————————————————————*

*&      Form  fetch_data

*&———————————————————————*

*       text

*———————————————————————-*

FORM fetch_data.

REFRESH  dgmst_it_gen.

*** Fetching the address number

dgmst_hd_adr = dgmss_dlv_delnotehd_adr.

READ TABLE dgmst_hd_adr INTO dgw_hd_adr WITH KEY partn_role = ‘WE’.

dgv_addr_no = dgw_hd_adraddr_no.

READ TABLE dgmst_hd_adr INTO dgw_hd_adr1 WITH KEY partn_role = ‘BP’.

dgv_addr_no1 = dgw_hd_adr1addr_no.

********

 

*** Fetching oreder number

dgmst_it_ref = dgmss_dlv_delnoteit_ref.

Read table dgmst_it_ref INTO dgw_it_ref INDEX 1.

dgv_vgbel    dgw_it_refref_doc.      ” sales oredr number vgbel

 

*** Fetching shippng address details from ADRC Table

 

SELECT SINGLE name1

city1

post_code1

street

country

FROM adrc

INTO dgmss_shipto

WHERE addrnumber = dgv_addr_no.

 

*** Fetching billng address details from ADRC Table

 

SELECT SINGLE name1

city1

post_code1

street

country

FROM adrc

INTO dgmss_billpto

WHERE addrnumber = dgv_addr_no.

 

dgmss_customer_ordercustomer_no    = dgmss_dlv_delnotehd_refpurch_no_c” Po number

dgmss_customer_orderorder_date  =     dgmss_dlv_delnotehd_refpurch_date.   ” ship to party oredr date

dgmst_it_gen = dgmss_dlv_delnoteit_gen.              ” Delivery Header : General Data Table

dgmss_customer_ordershipping_method = dgmss_dlv_delnotehd_gen_descriptname_shipping_type. ” shipping type

 

 

clear dgw_it_gen.

clear dgw_products.

REFRESH dgmst_products.

loop at dgmst_it_gen into dgw_it_gen.

dgw_productsQTY_SHIPPED = dgw_it_genDLV_QTY.

dgw_productsMODEL       = dgw_it_genMATERIAL.

dgw_productsDESCRIPTION = dgw_it_genSHORT_TEXT.

 

append dgw_products to dgmst_products.

endloop.

 

 

 

 

ENDFORM.                    “fetch_data

 

FORM invoke_smartform.

 

CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’

EXPORTING

formname                 = dgv_formname

*     VARIANT                  = ‘ ‘

*     DIRECT_CALL              = ‘ ‘

IMPORTING

fm_name                  = dgv_fm_name

EXCEPTIONS

no_form                  = 1

no_function_module       = 2

OTHERS                   = 3

.

IF sysubrc <> 0.

MESSAGE ID symsgid TYPE symsgty NUMBER symsgno

WITH symsgv1 symsgv2 symsgv3 symsgv4.

ENDIF.

 

 

CALL FUNCTION dgv_fm_name

EXPORTING

*   ARCHIVE_INDEX              =

*   ARCHIVE_INDEX_TAB          =

*   ARCHIVE_PARAMETERS         =

*   CONTROL_PARAMETERS         =

*   MAIL_APPL_OBJ              =

*   MAIL_RECIPIENT             =

*   MAIL_SENDER                =

*   OUTPUT_OPTIONS             =

*   USER_SETTINGS              = ‘X’

dgmss_shipto               = dgmss_shipto

dgmss_billpto              = dgmss_billpto

customer_no                = dgmss_customer_ordercustomer_no

order_date                 = dgmss_customer_orderorder_date

vgbel                      = dgv_vgbel

shipping_method            = dgmss_customer_ordershipping_method

* IMPORTING

*   DOCUMENT_OUTPUT_INFO       =

*   JOB_OUTPUT_INFO            =

*   JOB_OUTPUT_OPTIONS         =

tables

dgmst_it_gen               = dgmst_products

* EXCEPTIONS

*   FORMATTING_ERROR           = 1

*   INTERNAL_ERROR             = 2

*   SEND_ERROR                 = 3

*   USER_CANCELED              = 4

*   OTHERS                     = 5

.

IF sysubrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

 

 

 

IF sysubrc <> 0.

MESSAGE ID symsgid TYPE symsgty NUMBER symsgno

WITH symsgv1 symsgv2 symsgv3 symsgv4.

ENDIF.

 

 

 

ENDFORM.                    “invoke_smartform

 

 

*****Top include ********

 

*&———————————————————————*

*&  Include           ZERPSDPI_PCKLST_TOP

*&———————————————————————*

*** Structure declaration

 

DATA : dgmss_print_data_to_read TYPE ledlv_print_data_to_read,

dgmss_addr_key           TYPE addr_key,

dgmss_dlv_delnote        TYPE ledlv_delnote,

dgmss_control_param      TYPE ssfctrlop,

dgmss_composer_param     TYPE ssfcompop,

dgmss_recipient          TYPE swotobjid,

dgmss_sender             TYPE swotobjid,

dgmss_shipto             TYPE zerpsdss_shipto,

dgmss_total              TYPE zerpsdss_total,

dgmss_customer_order     TYPE zerpsdss_customer_order,

dgmss_hd_ref             TYPE ledlv_hd_ref.

 

*data :dgmss_shipto             TYPE zerpsdss_shipto,

data: dgmss_billpto             TYPE zerpsdss_shipto,

dgmst_it_gen             TYPE le_t_dlv_it_gen,

dgmst_hd_adr             TYPE le_t_dlv_hd_adr,

dgmst_products           TYPE zerpsdst_products,

dgmst_it_ref             TYPE LE_T_DLV_IT_REF.

 

data : dgv_addr_no            TYPE cadnr,

dgv_retcode            TYPE sysubrc,

dgv_formname           TYPE tdsfname,

dgv_fm_name            TYPE rs38l_fnam,

dgv_vgbel              TYPE vgbel,

dgv_addr_no1            TYPE cadnr.

 

DATA : dgw_hd_adr                 LIKE LINE OF dgmst_hd_adr,

dgw_it_ref                 LIKE LINE OF dgmst_it_ref,

dgw_products               LIKE LINE OF dgmst_products,

dgw_it_gen                 LIKE LINE OF dgmst_it_gen,

dgw_hd_adr1                LIKE LINE OF dgmst_hd_adr.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply