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

Line item issue

Former Member
0 Likes
879

Hi all,

I am writing a code in a loop....here i am printing hard code lines"please show..." in the header data based on the line item condition as tax code = 'M3'...here the hard code is printing fine but when ever there are more than one line item having tax code = 'M3' the hard code lines are getting repeated for that i need to get only single line...

i ahve wrote below code but it is not working...pls hlp

MOVE '1' TO GV_TAX_FLAG.

LOOP AT SF_PO-IT_ITEM INTO WA_ITEM.

IF WA_ITEM-TAX_CODE = 'I2'.

*MOVE 'X' TO GV_TAX_FLAG.

GV_TAX_FLAG = GV_TAX_FLAG + 1.

ELSE.

GV_TAX_FLAG = '0'.

ENDIF.

ENDLOOP.

and writing the condition as GV_TAX_FLAG = '1' then print this"...."....

my code is printing the hard code lines repeatedly for line items containing same tax code = "M3" ...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
779

Hi Srikanth,

herez the solution,

1)first sort your internal table by Tax Code.

2) in the loop use AT NEW.

eg:

data flag type i.

clear flag.

Loop at sf_po into wa_item.

at new wa_item-<your taxcode field>.

flag = 1.

endat.

if flag = 1.

flag = 0.

if taxcodefield = 'l2'.

write:/ "your hard coded statement".

endif.

if taxcodefield = 'm3'.

write:/ "your hard coded statement".

endif.

endif.

Hope this helps you to come up with your solution.

<b>Rewards points if this helps,</b>

Kiran

2 REPLIES 2
Read only

Former Member
0 Likes
780

Hi Srikanth,

herez the solution,

1)first sort your internal table by Tax Code.

2) in the loop use AT NEW.

eg:

data flag type i.

clear flag.

Loop at sf_po into wa_item.

at new wa_item-<your taxcode field>.

flag = 1.

endat.

if flag = 1.

flag = 0.

if taxcodefield = 'l2'.

write:/ "your hard coded statement".

endif.

if taxcodefield = 'm3'.

write:/ "your hard coded statement".

endif.

endif.

Hope this helps you to come up with your solution.

<b>Rewards points if this helps,</b>

Kiran

Read only

0 Likes
779

Try this code :::

keep the EXIT command whne ever u have acheived same tax_code

LOOP AT SF_PO-IT_ITEM INTO WA_ITEM.

IF WA_ITEM-TAX_CODE = 'I2'.

*MOVE 'X' TO GV_TAX_FLAG.

GV_TAX_FLAG = GV_TAX_FLAG + 1.

EXIT.

ENDIF.

ENDLOOP.