0% found this document useful (0 votes)
64 views3 pages

Check Material Has Exploded

This document contains ABAP code that is querying master data and order tables to retrieve order information for a specific promo material. It is checking if the promo material contains other materials, and if so, it is looking up those contained materials in the orders to populate sublists with the order data. It will flag if any of the orders contain materials for pack A or B.

Uploaded by

Jose Grill
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views3 pages

Check Material Has Exploded

This document contains ABAP code that is querying master data and order tables to retrieve order information for a specific promo material. It is checking if the promo material contains other materials, and if so, it is looking up those contained materials in the orders to populate sublists with the order data. It will flag if any of the orders contain materials for pack A or B.

Uploaded by

Jose Grill
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

"Check material is a BOM one

SELECT SINGLE *
FROM mast
INTO lw_mast
WHERE matnr EQ zpromo
AND stlan EQ '5'.
"Check there is no other order with Pack A or B determined
"Get all orders containing promo material
SELECT vbeln
FROM vapma
INTO TABLE lt_orders_num
WHERE matnr = zpromo
AND auart = lc_zrep.
IF lt_orders_num[] IS NOT INITIAL.
SELECT vbeln
FROM vbak
INTO TABLE lt_orders_num_aux
FOR ALL ENTRIES IN lt_orders_num
WHERE vbeln = lt_orders_num-vbeln.
"Create rangee with all Order#
LOOP AT lt_orders_num_aux INTO lw_order.
lr_w_orders-sign = 'I'.
lr_w_orders-option = 'EQ'.
lr_w_orders-low = lw_order-vbeln.
APPEND lr_w_orders TO lr_orders.
ENDLOOP.
lv_times = ceil( ( lines( lt_orders_num_aux ) / 1000 ) ).
lv_from = 1.
DO lv_times TIMES.
ADD 2000 TO lv_to.
IF lv_to GT lines( lt_orders_num_aux ).
lv_to = lines( lt_orders_num_aux ).
ENDIF.
REFRESH lr_orders_aux.
APPEND LINES OF lr_orders FROM lv_from TO lv_to TO lr_orders_aux.
"Get Orders' positions that are not rejected
SELECT vbeln posnr matnr arktx uepos kwmeng erdat erzet ernam abgru
FROM vbap
APPENDING CORRESPONDING FIELDS OF TABLE lt_orders
WHERE vbeln IN lr_orders_aux.
*

DELETE lt_orders WHERE abgru NE ''.


lv_from = lv_to + 1.
ENDDO.
LOOP AT lt_orders INTO lw_order.
lw_order_num-vbeln = lw_order-vbeln.
APPEND lw_order_num TO lt_orders_num.
ENDLOOP.

SORT lt_orders_num.
DELETE ADJACENT DUPLICATES FROM lt_orders_num.
"Get materials contained in Promo material
SELECT *
FROM stpo
INTO TABLE lt_stpo
WHERE stlnr EQ lw_mast-stlnr.
SELECT *
INTO TABLE lt_stlnr
FROM mast
FOR ALL ENTRIES IN lt_stpo
WHERE matnr = lt_stpo-idnrk.
IF lt_stpo IS NOT INITIAL.
"Promo material contains materials. Check if they already contain BO
M materials
SELECT b~stlty b~stlnr b~idnrk
FROM mast AS a INNER JOIN stpo AS b ON a~stlnr = b~stlnr
INTO TABLE lt_bom
FOR ALL ENTRIES IN lt_stpo
WHERE a~matnr = lt_stpo-idnrk.
SORT lt_bom BY stlnr.
SORT lt_orders BY matnr vbeln.
LOOP AT lt_orders_num INTO lw_order_num.
LOOP AT lt_stpo INTO lw_stpo.
IF lw_stpo-postp = 'N'.
"Populate sublists' data
READ TABLE lt_orders INTO lw_order WITH KEY matnr = lw_stpo-id
nrk
vbeln = lw_order_n
um BINARY SEARCH.
IF sy-subrc = 0.
"Populate sublist materials' data
CLEAR lw_stlnr.
READ TABLE lt_stlnr INTO lw_stlnr WITH KEY matnr = lw_stpo-i
dnrk.
IF sy-subrc = 0.
LOOP AT lt_bom INTO lw_bom WHERE stlnr = lw_stlnr-stlnr.
READ TABLE lt_orders INTO lw_order WITH KEY matnr = lw_b
om-idnrk
vbeln = lw_o
rder_num BINARY SEARCH.
IF sy-subrc = 0 AND lw_order-uepos EQ lv_list_pos.
READ TABLE lt_orders INTO lw_order WITH KEY posnr = lw
_order-uepos.
IF sy-subrc = 0.
IF lw_order-matnr = 'PR_XMAS14A'.
lv_exploded_a = abap_true.
ELSEIF lw_order-matnr = 'PR_XMAS14B'.

lv_exploded_b = abap_true.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDIF.

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