2019 Feb 20 8:46 AM
Hello All,
This is a very basic thing to ask but i am not able to crack it. am working on forms
for a PO lets say i have following info and we pass werks into table T001W to get address number.
Requirement : for a line item first we need to check if plant is same for all items (or) not, if it is not same we need to print plant address for each line item in smartform. How can we differentiate for all line items having same plant or not. can you pls help me on this how to put up the logic.
2019 Feb 20 9:44 AM
Not sure if I understand your question correctly,
In any case assuming that you have multiple "EKPO" lines, you can easily get all unique Plant values from your lines, and then check that unique values if are more than just one.
TYPES : BEGIN OF l_ekpo_typ,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
werks TYPE werks_d,
END OF l_ekpo_typ.
TYPES lt_ekpo_typ TYPE STANDARD TABLE OF l_ekpo_typ WITH KEY primary_key COMPONENTS ebeln ebelp.
DATA(lt_ekpo) = VALUE lt_ekpo_typ( ( ebeln = '6000000010' ebelp = '00010' werks = '1001' )
( ebeln = '6000000010' ebelp = '00020' werks = '1002' )
( ebeln = '6000000010' ebelp = '00030' werks = '1001' )
( ebeln = '6000000010' ebelp = '00040' werks = '1003' )
).
DATA(lt_plants) = VALUE plants( FOR GROUPS key OF wa IN lt_ekpo
GROUP BY wa-werks WITHOUT MEMBERS ( key ) ).
CHECK lines( lt_plants ) > 1.
* or
CHECK lines( lt_plants ) = 1.
* or whatever you want ..
2019 Feb 20 9:58 AM
Thanks for the reply I don't need for a line item how many plants are there or not. I need like for all line items is having same plant or not,if it is same no issue if it is not same we need to move item and plant details into some internal table.
Thanks.
2019 Feb 20 3:37 PM
The above code checks exactly what you mention "for all line items is having same plant or not". By checking the number of lines in "lt_plants" you can tell if you have a single plant or more.
After that you apply your logic by doing your 'development' magic.
2019 Feb 21 12:04 PM
That is correct but i need to put my logic with out group by is there any way without using group by?