Supply Chain Management Blogs by Members
Learn about SAP SCM software from firsthand experiences of community members. Share your own post and join the conversation about supply chain management.
cancel
Showing results for 
Search instead for 
Did you mean: 
Danish
Explorer
4,686

The below code provides the packspec quantity of a material in EWM.

data:

   lv_matnr            type /scwm/de_rf_matnr,

   lv_matnrd           type /scwm/s_rf_unlo_prod-rfprod,

   it_matid            type /scmb/mdl_matid_tab,

   wa_matid            type line of /scmb/mdl_matid_tab,

   is_content_query    type /scwm/s_ps_content_query,

   et_packspec_content type /scwm/tt_packspec_nested,

   wa_packspec_content type line of /scwm/tt_packspec_nested,

   et_ps_keys          type /scwm/tt_ps_header_key,

   wa_ps_keys          type line of /scwm/tt_ps_header_key,

   ev_severity         type bapi_mtype,

   et_return           type bapirettab,

   cv_max_rows         type int4,

   iv_guid_ps          type /scwm/de_guid_ps,

   es_packspec_level   type /scwm/s_ps_level_int,

   it_levels           type /scwm/s_packspec_nested-levels,

   wa_levels           type line of /scwm/s_packspec_nested-levels,

   lv_packspec_qty     type p decimals 3.

*lv_matnr  = <material number>

call function 'CONVERSION_EXIT_MDLPD_INPUT'

   exporting

     input  = lv_matnr

   importing

     output = lv_matnrd.

wa_matid-matid = lv_matnrd.

append wa_matid to it_matid.

clear wa_matid.

clear is_content_query.

clear et_packspec_content.

is_content_query-matid = it_matid.

call function '/SCWM/API_PACKSPEC_GETLIST'

   exporting

     is_content_query = is_content_query

   importing

     et_ps_keys       = et_ps_keys

     ev_severity      = ev_severity

     et_return        = et_return

   changing

     cv_max_rows      = cv_max_rows.

clear wa_ps_keys.

read table et_ps_keys into wa_ps_keys index 1.

clear iv_guid_ps.

iv_guid_ps = wa_ps_keys-guid_ps.

clear et_packspec_content.

call function '/SCWM/PS_PACKSPEC_GET'

   exporting

     iv_guid_ps          = iv_guid_ps

   importing

     et_packspec_content = et_packspec_content

     es_packspec_level   = es_packspec_level

   exceptions

     error               = 1

     others              = 2.

if sy-subrc <> 0.

* Implement suitable error handling here

endif.

clear wa_packspec_content.

read table et_packspec_content into wa_packspec_content index 1.

it_levels = wa_packspec_content-levels.

clear wa_levels.

read table it_levels into wa_levels index 1.

lv_packspec_qty = wa_levels-trgqty.

1 Comment
Labels in this area