Application Development and Automation 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: 
Read only

Check for different plants in print program

Former Member
0 Likes
474

Hi,

I am working on a print program for SAP Script for order confirmations. I have to find a way to determine if there are different plant between the positions before printout, as it should trigger an additional text at the end of each line.

example: itab = TVBDPA (order lines)

Pos. Plant

10 A

20 C

30 A

40 D

As you can see the item lines have different plants. How can I determine this in my program, so I can set a flag for different plants

for instance G_PLANT ?

In short: how to run though the positions and check if plants are different ?

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
436

May be this way


sort TVBDPA by plants.
delete adjacent duplicates from TVBDPA comparing PLANTS.
describe table TVBDPA lines v_lin.
if v_lin > 1.
  " Different plant.
else.
  " Single plant
endif.

Hi,

I am working on a print program for SAP Script for order confirmations. I have to find a way to determine if there are different plant between the positions before printout, as it should trigger an additional text at the end of each line.

example: itab = TVBDPA (order lines)

Pos. Plant

10 A

20 C

30 A

40 D

As you can see the item lines have different plants. How can I determine this in my program, so I can set a flag for different plants

for instance G_PLANT ?

In short: how to run though the positions and check if plants are different ?

2 REPLIES 2
Read only

Former Member
0 Likes
436

No way but to loop through table TVBDPA. If your intention is find the existence of more than on plant among the lines, without worrying about what the plants are, here is short pseudo-code snippet:


READ TABLE TVBDPA INDEX 1 INTO FIRST_PLANT.
LOOP AT TVBDPA FROM INDEX 2.
   IF TVBDPA-PLANT NOT EQUAL TO FIRST_PLANT.
      FLAG_DIFFERENT_PLANTS = TRUE
      EXIT.   "THE LOOP
   ENDIF.
ENDLOOP.

Read only

former_member194669
Active Contributor
0 Likes
437

May be this way


sort TVBDPA by plants.
delete adjacent duplicates from TVBDPA comparing PLANTS.
describe table TVBDPA lines v_lin.
if v_lin > 1.
  " Different plant.
else.
  " Single plant
endif.