Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to check for a PO line item having same plant value or not?

sandeep_gvv2
Participant
0 Kudos

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.

4 REPLIES 4

nick_giannakis
Explorer
0 Kudos

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 ..

0 Kudos

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.

nick_giannakis
Explorer
0 Kudos

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.

sandeep_gvv2
Participant
0 Kudos

That is correct but i need to put my logic with out group by is there any way without using group by?