‎2006 Jul 12 7:21 AM
Hi All,
I have a issue with <b>2</b> internal table validations.
My First Internal table <b>I_HEADER</b> contains one field called <b>EXGEN[License]</b> along with some other fields.
My Second Internal table <b>I_CLASS</b> contains one field called <b>EXGEN[License]</b> along with some other diffrent fields.
Now after i poulate and filter the internal tables as per logic.
I will have <b>I_HEADER & I_CLASS</b> table values as below:
<b>EX: 1
I_HEADER
EXGEN Values are as:
100
200
300
400
I_CLASS
EXGEN Values are as:
100</b>
In this case i should filter <b>I_HEADER</b> such that i should delete <b>200,300,400</b> entries in <b>I_HEADER</b> finally it will have only <b>100</b> license.
What is the easiest validation i can do here so that i can have one <b>EXGEN</b> entries in <b>I_HEADER</b> which are available in <b>I_CLASS</b>.
<b>EX: 2
I_HEADER
EXGEN Values are as:
100
200
300
400
I_CLASS
EXGEN Values are as:
No Values</b>
In this case i should filter <b>I_HEADER</b> such that i should delete <b>100,200,300,400</b> entries in <b>I_HEADER</b> finally it will not have any licenses.
What can be the logic i can use which will achieve the above functionality!
Thanks in advance.
Thanks & Regards,
Prasad.
‎2006 Jul 12 7:24 AM
Try this way.
loop at i_header.
read table i_class with key exgen - i_header-exgen.
if sy-subrc = 0.
continue.
else
delete i_header index sy-tabix.
endif.
endloop.
‎2006 Jul 12 7:24 AM
Try this way.
loop at i_header.
read table i_class with key exgen - i_header-exgen.
if sy-subrc = 0.
continue.
else
delete i_header index sy-tabix.
endif.
endloop.
‎2006 Jul 12 7:50 AM
HI,
Here one issue is there:
Actually I_CLASS will contain Item No as 000010, 000020, 000030 etc. SO for one license in I_HEADER we will have multiple Items in I_CLASS.
Ex:
I_HEADER
EXGEN Values
1001
1002
1003
1004
I_CLASS
EXGEN, ITEM Values
1001, 000010
1001, 000020
1001, 000030
1002, 000010
1002, 000020
In this case for me I should be able to get I_HEADER values as 300, 400 finally.
As above Number of entries & order of entries in both tables differ so above logic might not work well.
I think in this case we have to select all the distinct EXGEN's of I_CLASS into another internal table and compare it with I_HEADER. Am i right!
If any other solution please post it!
Thanks,
Prasad.
‎2006 Jul 12 7:54 AM
Delete I_CLASS comparing liscence field after moving to new internal table.
But have you tried with the above logic, it should work even with this data.
Regds
Manohar
‎2006 Jul 12 7:36 AM
hi,
sort I_CLASS by EXGEN.
loop at I_HEADER.
read table I_CLASS with key EXGEN = I_HEADER-EXGEN
TRANSPORTING NO FIELDS
binary search.
if sy-subrc <> 0.
delete I_HEADER.
endif.
endloop.
1) Sort the table.
2) Use Transporting no fields & Binary search to speed up the process
3) Delete I_HEADER --> this will delete current row hence no time waste.
‎2006 Jul 12 7:52 AM
Hi,
the Easiest way is,
Sort i_class by exgen.
Loop at i_header.
Read Table i_class with key exgen eq i_class-exgen.
if sy-subrc <> 0.
Delete i_header.
endif.
Endloop.
Thanks,
Neptune.M
Plz reward if it helps.
‎2006 Jul 12 7:55 AM
Hi Neptune,
again Neptune.
Plz change the Read Statement as follows,
Read Table i_class with key exgen = i_header-exgen.
Thanks,
Neptune.M
‎2006 Jul 12 8:42 AM
Hi,
I had written following logic and it worked well.
<b> MOVE i_class[] TO i_class_temp[].
DELETE ADJACENT DUPLICATES FROM i_class_temp
COMPARING zzexgen.
CLEAR wa__header.
LOOP AT i_header INTO wa_header.
READ TABLE i_class_temp INTO wa_class_temp
WITH KEY zzexgen = wa_header-zzexgen.
IF sy-subrc = 0.
CONTINUE.
ELSE.
DELETE i_header
WHERE zzexgen = wa_header-zzexgen.
ENDIF.
ENDLOOP.</b>
Thanks for all those replies.
Thanks & Regards,
Prasad.