10-13-2008 4:23 PM
Hi all,
If I have an internal table as below: -
ITEM TANUM VLTYP
1 0000002627 CR3
2 0000002627 CR3
3 0000002627 CR3
4 0000002627 TTY
5 0000002627 MRK
6 0000002627 MRK
7 0000002627 MRK
How could I do like this:
If Item 1 and Item 2 are same TANUm & VLTYP, PERFORM FUNCTION_ABC. If not, PERFORM FUNCTION DEF.
If Item 2 and Item 3 are same TANUm & VLTYP, PERFORM FUNCTION_ABC. If not, PERFORM FUNCTION DEF.
If Item 3 and Item 4 are same TANUm & VLTYP, PERFORM FUNCTION_ABC. If not, PERFORM FUNCTION DEF.
If Item 4 and Item 5 are same TANUm & VLTYP, PERFORM FUNCTION_ABC. If not, PERFORM FUNCTION DEF.
If Item 5 and Item 6 are same TANUm & VLTYP, PERFORM FUNCTION_ABC. If not, PERFORM FUNCTION DEF.
If Item 6 and Item 7 are same TANUm & VLTYP, PERFORM FUNCTION_ABC. If not, PERFORM FUNCTION DEF.
Thanks in advance.
10-13-2008 4:34 PM
Hi ,
For this type of requirement you need to play around with the index number in the internal table
What you need to do is loop at the internal table and then read the current index and read current index + 1.
then on the basis of the condition Put your logic behind.
Thanks,
Chdianand
10-13-2008 4:30 PM
Hi,
First copy the body of table itab into other table jtab..
itab[ ] = jtab[ ].
v_index = sy-tabix.
v_index1 = v_index + 1.
loop at itab.
read table jtab with key index = v_index1.
if jtab-num eq itab-num and jtab-no eq itab-no .
perform abc.
else.
perform xyz.
endif.
endloop.
rgds,
paras
10-13-2008 4:34 PM
Hi ,
For this type of requirement you need to play around with the index number in the internal table
What you need to do is loop at the internal table and then read the current index and read current index + 1.
then on the basis of the condition Put your logic behind.
Thanks,
Chdianand
10-13-2008 4:52 PM
Hi
Just as Chdianand while loop the table read the next record too, use a workarea like your table:
DATA: WA LIKE ITAB,
CURRENT_INDEX TYPE I,
NEXT_INDEX TYPE I.
LOOP AT ITAB.
CURRENT_INDEX = SY-TABIX.
NEXT_INDEX = SY-TABIX + 1.
READ TABLE ITAB INTO WA INDEX NEXT_INDEX.
IF SY-SUBRC = 0.
IF ITAB = WA.
ELSE.
ENDIF.
ENDIF.
ENDLOOP.
Max
10-15-2008 3:17 AM
Hi all,
Thanks for the replies.
I have think of doing it in this way. So far the output is working fine.
Any place in the code which I enhance to make it work better?
LOOP AT XRLDRI
lv_counter = lv_counter + 1.
IF lv_counter >= 13.
call function 'CONTROL_FORM'
exporting
command = 'NEW-WINDOW'.
CLEAR: lv_counter, FLG_HU_PRINT.
ENDIF.
IF NOT lv_tanum IS INITIAL AND NOT lv_vltyp IS INITIAL.
IF lv_tanum <> XRLDRI-tanum OR lv_vltyp <> XRLDRI-vltyp.
call function 'CONTROL_FORM'
exporting
command = 'NEW-WINDOW'.
lv_tanum = XRLDRI-tanum.
lv_vltyp = XRLDRI-vltyp.
CLEAR: lv_counter, FLG_HU_PRINT.
ENDIF.
ELSE.
lv_tanum = XRLDRI-tanum.
lv_vltyp = XRLDRI-vltyp.
ENDIF.
PERFORM MULTI_PRINT.
ENDLOOP.
10-15-2008 4:46 AM
Hi myahsam wong,
Do like this
data : begin of itab occurs 0,
item,
tanum,
vltyp,
end of itab.
data : item1 like itab-item.
data : item2 like itab-item.
Loop at itab.
item1 = itab-item.
if item1 = item2.
perform FUNCTION_DEF.
endif.
item2 = item1.
endloop.
Regards,
Ragu