‎2008 Apr 03 6:44 AM
I have an internal table with 2 records as follows
material no, empty material, sequence no
Values
MAT1 EMAT1 SEQ001
MAT1 EMAT1 SEQ002
if record >1
Here I need to write logic as follows
Check internal table
Within internal table loop through records
if mat1 (1st record) = mat1 (second record)
and
emat1(1st record) = emat1 (second record)
then skip further processing (like exit from loop)
endif
How to do this.
thanks.
‎2008 Apr 03 7:02 AM
Hi,
See the code wheather it helps u,
data : ind like sy-tabix,
mat1 like itab-mat1,
emat1 like itab-emat1.
loop at itab .
if sy-tabix mod 2 = 0.
read table itab index ind .
if sy-subrc eq 0.
if itab-mat1 = mat1 and
itab-emat1 = emat1 .
exit.
else.
clear : mat1,emat1.
endif.
else.
mat1 = itab-mat1.
emat1 = itab-emat1.
endif.
endloop.Regards,
Morris Bond.
Reward Points if Helpful.
‎2008 Apr 03 7:04 AM
data: l_tabix type sy-tabix.
types: begin of ty_itab,
mat type matnr,
emat type matnr,
seqno type char10, " assumed data type
end of ty_itab.
data: wa_itab type ty_itab,
prewa_itab type ty_itab. Previous Work Area
i_itab type standard table of ty_itab.
and consider that the below records exists in i_itab.
MAT1 EMAT1 SEQ001
MAT1 EMAT1 SEQ002
loop at i_itab into wa_itab.
l_tabix = sy-tabix.
if l_tabix > 1.
if prewa_itab-mat1 = wa_itab-mat1 and
prewa_itab-emat1 = wa_itab-emat1.
clear prewa_itab.
Exit.
endif.
prewa_itab = wa_itab.
endloop.
Edited by: Ravi Sankara. Z on Apr 3, 2008 8:05 AM
Edited by: Ravi Sankara. Z on Apr 3, 2008 8:06 AM
‎2008 Apr 03 7:16 AM
data: v_mat(10),
v_emat(10),
v_lines type i.
describe table itab lines v_lines.
if v_lines > 1.
do v_lines times.
read table itab index sy-index.
if sy-subrc = 0.
if itab-mat <> v_mat and
itab-emat <> v_emat.
v_mat = itab-mat.
v_emat = itab-emat.
else.
EXIT.
endif.
endif.
enddo.
endif.
‎2008 Apr 03 7:21 AM
Table itab has following records:
Values
Field1 Field2 Field3
MAT1 EMAT1 SEQ001
MAT1 EMAT1 SEQ002
MAT2 EMAT1 SEQ001
MAT2 EMAT1 SEQ002
Move the contents of this table into another table having same structure itab2.
itab2[] = itab[].
sort itab2 by field1 field2.
delete adjacent duplicates from itab2 comparing field1 field2.So now Itab2 has the required records which you need to process i.e.
Field1 Field2 Field3
MAT1 EMAT1 SEQ001
MAT2 EMAT1 SEQ001.
Edited by: Richa Gupta on Apr 3, 2008 8:23 AM
‎2008 Apr 03 7:29 AM
Hi Morris,
thanks for the logic.
the logic is currently like this
if
Your logic suggested
endif
Will your exit statement move the program control out of the outer if statement as well