‎2009 Jun 02 5:43 PM
I have internal table of 3 fields ebeln ebelp vgabe
If the PO combination has only one entry and the VGABE is equal to 2, then its determined as a successful entry and in case the PO combinations is holding more than one entry then within those entries, if we have any combination like 2,1,1 or 1,2,2, or 1,1,2..any combination these are to be termed as failure entries.
Hence as per this assumption, for the above entries, when taken into consideration, for 940000206, we have 1,1,1,2..this is failure entry. For 940000219, we have 1,2 ..even this is a failure entry. Assumeu2026if we have an entry 940000220 with only one entry with the VGABE is equal to 2, then this is termed as successful entry
for eg:
ebeln ebelp vgabe
940000220 020 1
940000221 010 1
940000221 020 2
940000222 010 1
940000222 020 2
940000223 010 2
From the above code i need to get ONLY with only one entry with the VGABE is equal to 2
i.e, 940000223 need to be retrieved...
Can anyone send me the logic to get only one entry record having vgabe =2.
Thanks....
‎2009 Jun 02 7:42 PM
Hi,
Assuming your records as follows:
ebeln ebelp vgabe
940000220 020 1
940000221 010 1
940000221 020 2
940000222 010 1
940000222 020 2
940000223 010 2
The logic to determine 940000223 010 2 is as follows.
Assume ITAB contains your data.
I need 2 more tables as follow:-
ITAB1.
ebeln cntr where cntr will be type i.
ITAB_FINAL same as ITAB
ebeln ebelp vgabe
loop at itab.
move itab-ebeln to itab1-ebeln.
move itab-vgabe to itab1-cntr.
collect itab1.
endloop.
So now itab1 will contain all the PO's with their VGABE summed up.
data: rec_cntr type i.
LOOP at ITAB1 where cntr eq 2.
LOOP AT ITAB where EBELN = ITAB1-EBELN.
rec_cntr = rec_cntr + 1.
if rec_cntr gt 1.
exit.
endif.
ENDLOOP.
if rec_cntr eq 1.
move-corresponding ITAB to ITAB_FINAL.
append ITAB_FINAL.
endif.
clear : rec_cntr.
ENDLOOP.
So now ITAB_FINAL will contain only those EBELN where vgabe is 2.
I hope this is useful.
Regards,
Ankur Parab
‎2009 Jun 02 7:42 PM
Hi,
Assuming your records as follows:
ebeln ebelp vgabe
940000220 020 1
940000221 010 1
940000221 020 2
940000222 010 1
940000222 020 2
940000223 010 2
The logic to determine 940000223 010 2 is as follows.
Assume ITAB contains your data.
I need 2 more tables as follow:-
ITAB1.
ebeln cntr where cntr will be type i.
ITAB_FINAL same as ITAB
ebeln ebelp vgabe
loop at itab.
move itab-ebeln to itab1-ebeln.
move itab-vgabe to itab1-cntr.
collect itab1.
endloop.
So now itab1 will contain all the PO's with their VGABE summed up.
data: rec_cntr type i.
LOOP at ITAB1 where cntr eq 2.
LOOP AT ITAB where EBELN = ITAB1-EBELN.
rec_cntr = rec_cntr + 1.
if rec_cntr gt 1.
exit.
endif.
ENDLOOP.
if rec_cntr eq 1.
move-corresponding ITAB to ITAB_FINAL.
append ITAB_FINAL.
endif.
clear : rec_cntr.
ENDLOOP.
So now ITAB_FINAL will contain only those EBELN where vgabe is 2.
I hope this is useful.
Regards,
Ankur Parab
‎2009 Jun 02 7:50 PM
Hi,
itab1[] = itab2[].
delete itab2 where vgabe ne 2.
delete itab1 where vgabe eq 2.
loop through itab2 .
read itab1 with itab2-ebeln.
if subrc eq o.
delete itab2 where ebeln = itab1-ebeln.
endif.
endloop.records left in itab2 are successful records.
‎2009 Jun 02 7:52 PM
try this way...
" ebeln ebelp vgabe
" 940000220 020 1
" 940000221 010 1
" 940000221 020 2
" 940000222 010 1
" 940000222 020 2
" 940000223 010 2
sort itab by ebeln ebelp vgabe.
loop at itab.
read table itab with key ebeln = itab-ebeln
ebelp = itab-ebelp
binary search. "use binary search then only it will pick only one entry
if sy-subrc = 0 .
if itab-vgabe = 2.
"display ebeln ebelp vgabe.
endif.
endif.
endloop
Prabhudas