SAP Function Modules

WTAD_READ_ADDI_4_MATNR SAP Function module







WTAD_READ_ADDI_4_MATNR is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name WTAD_READ_ADDI_4_MATNR into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: AEMM
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM WTAD_READ_ADDI_4_MATNR - WTAD READ ADDI 4 MATNR





CALL FUNCTION 'WTAD_READ_ADDI_4_MATNR' "
* EXPORTING
*   matnr =                     " mara-matnr
*   flag_addiprass_always = 'X'  " c
*   flag_addiprass_promo_only = 'X'  " c
*   flag_addiprass_promo_never = 'X'  " c
*   read_flag = 'M'             " c
*   read_mamt = ' '             " c
*   read_variants = 'X'         " c
*   aktnr =                     " wakh-aktnr
*   promo_date =                " sy-datum
*   fi_sm_transaction = '000'   " twzla-keytr
*   fi_plant =                  " t001w-werks
*   fi_quantity =               " mseg-menge
*   fi_unit_of_measure =        " t006-msehi
*   fi_addi_application = ''    " twtctrl-addiappl
*   fi_sd_doc =                 " vbak-vbeln
*   fi_itm_number =             " vbap-posnr
*   fi_sd_doc_cat =             " vbtyp
*   fi_sd_ref_copy =            " xfeld
*   i_no_expl_sart = SPACE      " c
* TABLES
*   iwtaddi =                   " wtaddi
*   iwtaddi_pr =                " addi_wtaddi_pr
*   imamt =                     " mamt
*   imara =                     " mara
*   fet_matnrs_and_quant =      " wsos_stuli
*   fet_wtadab =                " wtadab
*   fet_wtadabt =               " wtadabt
  EXCEPTIONS
    WRONG_CALL = 1              "
    DB_ERROR = 2                "
    .  "  WTAD_READ_ADDI_4_MATNR

ABAP code example for Function Module WTAD_READ_ADDI_4_MATNR





The ABAP code below is a full code listing to execute function module WTAD_READ_ADDI_4_MATNR including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
it_iwtaddi  TYPE STANDARD TABLE OF WTADDI,"TABLES PARAM
wa_iwtaddi  LIKE LINE OF it_iwtaddi ,
it_iwtaddi_pr  TYPE STANDARD TABLE OF ADDI_WTADDI_PR,"TABLES PARAM
wa_iwtaddi_pr  LIKE LINE OF it_iwtaddi_pr ,
it_imamt  TYPE STANDARD TABLE OF MAMT,"TABLES PARAM
wa_imamt  LIKE LINE OF it_imamt ,
it_imara  TYPE STANDARD TABLE OF MARA,"TABLES PARAM
wa_imara  LIKE LINE OF it_imara ,
it_fet_matnrs_and_quant  TYPE STANDARD TABLE OF WSOS_STULI,"TABLES PARAM
wa_fet_matnrs_and_quant  LIKE LINE OF it_fet_matnrs_and_quant ,
it_fet_wtadab  TYPE STANDARD TABLE OF WTADAB,"TABLES PARAM
wa_fet_wtadab  LIKE LINE OF it_fet_wtadab ,
it_fet_wtadabt  TYPE STANDARD TABLE OF WTADABT,"TABLES PARAM
wa_fet_wtadabt  LIKE LINE OF it_fet_wtadabt .


SELECT single MATNR
FROM MARA
INTO @DATA(ld_matnr).

DATA(ld_flag_addiprass_always) = 'Check type of data required'.
DATA(ld_flag_addiprass_promo_only) = 'Check type of data required'.
DATA(ld_flag_addiprass_promo_never) = 'Check type of data required'.
DATA(ld_read_flag) = 'Check type of data required'.
DATA(ld_read_mamt) = 'Check type of data required'.
DATA(ld_read_variants) = 'Check type of data required'.

SELECT single AKTNR
FROM WAKH
INTO @DATA(ld_aktnr).

DATA(ld_promo_date) = '20210129'.

SELECT single KEYTR
FROM TWZLA
INTO @DATA(ld_fi_sm_transaction).


SELECT single WERKS
FROM T001W
INTO @DATA(ld_fi_plant).


SELECT single MENGE
FROM MSEG
INTO @DATA(ld_fi_quantity).


SELECT single MSEHI
FROM T006
INTO @DATA(ld_fi_unit_of_measure).


SELECT single ADDIAPPL
FROM TWTCTRL
INTO @DATA(ld_fi_addi_application).


SELECT single VBELN
FROM VBAK
INTO @DATA(ld_fi_sd_doc).


SELECT single POSNR
FROM VBAP
INTO @DATA(ld_fi_itm_number).

DATA(ld_fi_sd_doc_cat) = '20210129'.
DATA(ld_fi_sd_ref_copy) = '20210129'.
DATA(ld_i_no_expl_sart) = '20210129'.

"populate fields of struture and append to itab
append wa_iwtaddi to it_iwtaddi.

"populate fields of struture and append to itab
append wa_iwtaddi_pr to it_iwtaddi_pr.

"populate fields of struture and append to itab
append wa_imamt to it_imamt.

"populate fields of struture and append to itab
append wa_imara to it_imara.

"populate fields of struture and append to itab
append wa_fet_matnrs_and_quant to it_fet_matnrs_and_quant.

"populate fields of struture and append to itab
append wa_fet_wtadab to it_fet_wtadab.

"populate fields of struture and append to itab
append wa_fet_wtadabt to it_fet_wtadabt. . CALL FUNCTION 'WTAD_READ_ADDI_4_MATNR' * EXPORTING * matnr = ld_matnr * flag_addiprass_always = ld_flag_addiprass_always * flag_addiprass_promo_only = ld_flag_addiprass_promo_only * flag_addiprass_promo_never = ld_flag_addiprass_promo_never * read_flag = ld_read_flag * read_mamt = ld_read_mamt * read_variants = ld_read_variants * aktnr = ld_aktnr * promo_date = ld_promo_date * fi_sm_transaction = ld_fi_sm_transaction * fi_plant = ld_fi_plant * fi_quantity = ld_fi_quantity * fi_unit_of_measure = ld_fi_unit_of_measure * fi_addi_application = ld_fi_addi_application * fi_sd_doc = ld_fi_sd_doc * fi_itm_number = ld_fi_itm_number * fi_sd_doc_cat = ld_fi_sd_doc_cat * fi_sd_ref_copy = ld_fi_sd_ref_copy * i_no_expl_sart = ld_i_no_expl_sart * TABLES * iwtaddi = it_iwtaddi * iwtaddi_pr = it_iwtaddi_pr * imamt = it_imamt * imara = it_imara * fet_matnrs_and_quant = it_fet_matnrs_and_quant * fet_wtadab = it_fet_wtadab * fet_wtadabt = it_fet_wtadabt EXCEPTIONS WRONG_CALL = 1 DB_ERROR = 2 . " WTAD_READ_ADDI_4_MATNR
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_matnr  TYPE MARA-MATNR ,
it_iwtaddi  TYPE STANDARD TABLE OF WTADDI ,
wa_iwtaddi  LIKE LINE OF it_iwtaddi,
ld_flag_addiprass_always  TYPE C ,
it_iwtaddi_pr  TYPE STANDARD TABLE OF ADDI_WTADDI_PR ,
wa_iwtaddi_pr  LIKE LINE OF it_iwtaddi_pr,
ld_flag_addiprass_promo_only  TYPE C ,
it_imamt  TYPE STANDARD TABLE OF MAMT ,
wa_imamt  LIKE LINE OF it_imamt,
ld_flag_addiprass_promo_never  TYPE C ,
it_imara  TYPE STANDARD TABLE OF MARA ,
wa_imara  LIKE LINE OF it_imara,
ld_read_flag  TYPE C ,
it_fet_matnrs_and_quant  TYPE STANDARD TABLE OF WSOS_STULI ,
wa_fet_matnrs_and_quant  LIKE LINE OF it_fet_matnrs_and_quant,
ld_read_mamt  TYPE C ,
it_fet_wtadab  TYPE STANDARD TABLE OF WTADAB ,
wa_fet_wtadab  LIKE LINE OF it_fet_wtadab,
ld_read_variants  TYPE C ,
it_fet_wtadabt  TYPE STANDARD TABLE OF WTADABT ,
wa_fet_wtadabt  LIKE LINE OF it_fet_wtadabt,
ld_aktnr  TYPE WAKH-AKTNR ,
ld_promo_date  TYPE SY-DATUM ,
ld_fi_sm_transaction  TYPE TWZLA-KEYTR ,
ld_fi_plant  TYPE T001W-WERKS ,
ld_fi_quantity  TYPE MSEG-MENGE ,
ld_fi_unit_of_measure  TYPE T006-MSEHI ,
ld_fi_addi_application  TYPE TWTCTRL-ADDIAPPL ,
ld_fi_sd_doc  TYPE VBAK-VBELN ,
ld_fi_itm_number  TYPE VBAP-POSNR ,
ld_fi_sd_doc_cat  TYPE VBTYP ,
ld_fi_sd_ref_copy  TYPE XFELD ,
ld_i_no_expl_sart  TYPE C .


SELECT single MATNR
FROM MARA
INTO ld_matnr.


"populate fields of struture and append to itab
append wa_iwtaddi to it_iwtaddi.
ld_flag_addiprass_always = '20210129'.

"populate fields of struture and append to itab
append wa_iwtaddi_pr to it_iwtaddi_pr.
ld_flag_addiprass_promo_only = '20210129'.

"populate fields of struture and append to itab
append wa_imamt to it_imamt.
ld_flag_addiprass_promo_never = '20210129'.

"populate fields of struture and append to itab
append wa_imara to it_imara.
ld_read_flag = '20210129'.

"populate fields of struture and append to itab
append wa_fet_matnrs_and_quant to it_fet_matnrs_and_quant.
ld_read_mamt = '20210129'.

"populate fields of struture and append to itab
append wa_fet_wtadab to it_fet_wtadab.
ld_read_variants = '20210129'.

"populate fields of struture and append to itab
append wa_fet_wtadabt to it_fet_wtadabt.

SELECT single AKTNR
FROM WAKH
INTO ld_aktnr.

ld_promo_date = '20210129'.

SELECT single KEYTR
FROM TWZLA
INTO ld_fi_sm_transaction.


SELECT single WERKS
FROM T001W
INTO ld_fi_plant.


SELECT single MENGE
FROM MSEG
INTO ld_fi_quantity.


SELECT single MSEHI
FROM T006
INTO ld_fi_unit_of_measure.


SELECT single ADDIAPPL
FROM TWTCTRL
INTO ld_fi_addi_application.


SELECT single VBELN
FROM VBAK
INTO ld_fi_sd_doc.


SELECT single POSNR
FROM VBAP
INTO ld_fi_itm_number.

ld_fi_sd_doc_cat = '20210129'.
ld_fi_sd_ref_copy = '20210129'.
ld_i_no_expl_sart = '20210129'.

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name WTAD_READ_ADDI_4_MATNR or its description.