FM - Get - SNP - Qty

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

*-> Local Data Declarations

DATA: ls_content_query TYPE /scwm/s_ps_content_query,


lt_ps_keys TYPE /scwm/tt_ps_header_key,
lv_severity TYPE bapi_mtype,
lv_matid_16 TYPE /scwm/de_matid,
lt_matid_tab TYPE /scmb/mdl_matid_tab,
lt_object TYPE /scwm/tt_ps_object,
lv_matnr TYPE /scwm/de_matnr,
lt_return TYPE bapirettab.

* Define Local Constants


CONSTANTS : lc_layer TYPE /scwm/de_psleveltype VALUE 'LAYR',
lc_palet TYPE /scwm/de_psleveltype VALUE 'PALT',
lc_e TYPE bapi_mtype VALUE 'E',
lc_x TYPE bapi_mtype VALUE 'X',
lc_a TYPE bapi_mtype VALUE 'A'.

FREE : ev_cs_pallet_quan,
ev_cs_layer_quan,
et_level.

* Checking if material number is not initial


CHECK iv_matnr IS NOT INITIAL.

* Apply Conversion Exit

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'


EXPORTING
input = iv_matnr
IMPORTING
output = lv_matnr.

*-> Get Packaging Specifications of the Product


SELECT SINGLE matid "Secondary Index fetch
FROM /sapapo/matkey
INTO @DATA(lv_matid_22)
WHERE matnr = @lv_matnr.
IF sy-subrc NE 0.
MESSAGE e011(zgmc_ewm_msg).
ENDIF.
* Converting matid from 22 to 16
CALL FUNCTION '/SCMB/MDL_GUID_CONVERT'
EXPORTING
iv_guid22 = lv_matid_22
IMPORTING
ev_guid16 = lv_matid_16.

APPEND INITIAL LINE TO lt_matid_tab ASSIGNING FIELD-SYMBOL(<lfs_matid_tab>).


IF <lfs_matid_tab> IS ASSIGNED.
<lfs_matid_tab>-matid = lv_matid_16.
ls_content_query-matid = lt_matid_tab.

* returns list of packspec guids


CALL FUNCTION '/SCWM/API_PACKSPEC_GETLIST'
EXPORTING
is_content_query = ls_content_query
IMPORTING
et_ps_keys = lt_ps_keys
ev_severity = lv_severity
et_return = lt_return.
ENDIF.
UNASSIGN : <lfs_matid_tab>.

IF lv_severity CA wmegc_severity_eax AND


lt_ps_keys IS INITIAL.
MESSAGE e012(zgmc_ewm_msg).
ENDIF.
CLEAR: lv_severity,
lt_return.
IF lt_ps_keys IS NOT INITIAL.
*-> Get Pack. Spec. details
CALL FUNCTION '/SCWM/API_PACKSPEC_READ'
EXPORTING
it_ps_id = lt_ps_keys
IMPORTING
et_object = lt_object
ev_severity = lv_severity
et_return = lt_return.

ENDIF.

IF lv_severity CA wmegc_severity_eax AND


lt_object IS INITIAL.
LOOP AT lt_return ASSIGNING FIELD-SYMBOL(<lfs_return>) WHERE type = lc_e
OR type = lc_x
OR type = lc_a.
MESSAGE e013(zgmc_ewm_msg).
EXIT.
ENDLOOP.

UNASSIGN : <lfs_return>.
ENDIF.

CLEAR: lv_severity,
lt_return.

* Reading the first entry to find out the quantity in layer


* and pallet
IF lt_object IS NOT INITIAL.
et_object = lt_object.
ENDIF.
READ TABLE lt_object ASSIGNING FIELD-SYMBOL(<lfs_object>)
INDEX 1.
IF <lfs_object> IS ASSIGNED.
et_level = <lfs_object>-levels.

READ TABLE <lfs_object>-levels ASSIGNING FIELD-SYMBOL(<lfs_level>) WITH KEY


level_type = lc_layer.
IF <lfs_level> IS ASSIGNED.
ev_cs_layer_quan = <lfs_level>-total_quan.
ENDIF.
READ TABLE <lfs_object>-levels ASSIGNING <lfs_level> WITH KEY
level_type = lc_palet.
IF <lfs_level> IS ASSIGNED.
ev_cs_pallet_quan = <lfs_level>-total_quan.
ENDIF.

UNASSIGN : <lfs_level>, <lfs_object>.


ENDIF.

FREE : lv_matnr, lt_object, lt_ps_keys, ls_content_query, lv_matid_16,


lv_matid_22.
ENDFUNCTION.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy