‎2009 Jul 11 7:36 AM
Hi,
i have 2 itabs.
itab2 contains:
174422070104 |0760 |000144200160|0000324482| 0321
174422070104 |0760 |000144200160|0000324482|1217
itab4 contains
174422070104 |0760 |000144200180|0000328602|0654
now when i compare as follows
LOOP AT ITAB2 .
READ TABLE ITAB4 WITH KEY MATNR = ITAB2-MATNR binary search.
IF SY-SUBRC <> 0.
MOVE ITAB2-MATNR TO IT_DEL-MATNR.
MOVE ITAB2-MAKTX TO IT_DEL-MAKTX.
MOVE ITAB2-VORNR TO IT_DEL-VORNR.
MOVE ITAB2-KZEAR TO IT_DEL-KZEAR.
MOVE ITAB2-ENMNG TO IT_DEL-ENMNG.
MOVE ITAB2-BDMNG TO IT_DEL-BDMNG.
APPEND IT_DEL.
ENDIF.
ENDLOOP.
1st record of itab2 match with itab4 but itab4 does not have 2nd record. so it append to it_del. but its not happening as header line not cleared.
‎2009 Jul 11 7:48 AM
hi,
wht is ur doubt is not very clear.
If the problem is with header use work area for both the itabs.
If the issue is appending extra record in it_del thn loop at itab4 and read itab2.
Hope this helps
‎2009 Jul 11 7:56 AM
hi seema,
I tried work area also. but it is not working, i have to show this material in the deleted list.
Regards,
‎2009 Jul 11 8:10 AM
Khushi,
Its still not clear wht is the exact issue u r facing in the code. Can you please explain the same.
‎2009 Jul 11 8:15 AM
‎2009 Jul 11 8:25 AM
hi khushi ,
as i said clear your read table i.e it_tab4 which contains 1 record
loop at it_tab2 .
read table it_tab4 .....
your moving code here .
after append it_del .
clear it_tab4 .
endloop.
clear it_tab2 .
This will solve your problem .
your problem is that your header line does not get clear after reading .
Regards
Deepak .
‎2009 Jul 11 8:11 AM
Hi,
LOOP AT ITAB2 .
READ TABLE ITAB4 WITH KEY MATNR = ITAB2-MATNR binary search.
IF SY-SUBRC NE 0. " check this
MOVE ITAB2-MATNR TO IT_DEL-MATNR.
MOVE ITAB2-MAKTX TO IT_DEL-MAKTX.
MOVE ITAB2-VORNR TO IT_DEL-VORNR.
MOVE ITAB2-KZEAR TO IT_DEL-KZEAR.
MOVE ITAB2-ENMNG TO IT_DEL-ENMNG.
MOVE ITAB2-BDMNG TO IT_DEL-BDMNG.
APPEND IT_DEL.
ENDIF.
ENDLOOP.
‎2009 Jul 11 8:14 AM
hi khushi,
can you explian me what is your code and what exact you want.
regards
raghava
‎2009 Jul 11 8:17 AM
Hi Seema,
In itab2 , there are 2 records and in itab4 there are only 1 record. now when i compare these 2 itabs as above after 1st execution ,2nd time itab4 should not contain the material number and value of sy-subrc should be 4, but its not happening. i have used itab with header line. so 2nd time itab4 contain same material number.
‎2009 Jul 11 8:31 AM
‎2009 Jul 11 8:39 AM
PLEASE READ THIS PROPERLY .
when you are reading itab 4 to match with itab2 which has two records
loop will exectute two time .
read will execute one time .
according to your code when record will not match i.e sy-subrc NE 0 .
then you are moving your data to it_del aND APPENDING BUT YOUR RECORD IS RETURNING SY-SUBCR = 0 .
SO IT WILL NOT MOVE RECORDS TO IT_DEL TABLE .
IF YOU WANT TO TRANSFER DATA IF MATNR MATCH THEN USE SY-SUBRC = 0 AND THEN IT WILL MOVE DATA TO IT_DEL
THEN APPEND IT_DEL .
CLEAR ITAB4 .
ENDLOOP.
CLEAR ITAB2.
rEGARDS
DEEPAK .
‎2009 Jul 11 8:46 AM
Hi deepak,
i want to transfer data in matnr not matches ie sy-subrc ne 0. the problem is due the same material is coming twise. if i took differnet materials then i works fine. Is there another way to comapre ie FM.
‎2009 Jul 11 9:16 AM
Hi deepak,
i want to transfer data in matnr not matches ie sy-subrc ne 0. the problem is due the same material is coming twise. if i take differnet materials then i works fine. Is there another way to comapre ie FM.
Regards,
‎2009 Jul 11 9:39 AM
hi khushi ,
Now as code which is written will give you correct result according to what you said .
NOw you tell me what result you are expecting from records which you have show in itab2 and itab 4 .
according to you what result you are expecting .
as there can be more same matnr in itab2 so it will execute that many times .
when there will be another matnr which does not matches itab4 table record .
then only itab2 data will be moved to i it_del table .
if thios is not you are expecting .
then pls give dummy data of both table and expected result .
in this reply .
Regards
Deepak
‎2009 Jul 11 9:58 AM
hi deepak,
i have given data and code above.
u guess right, but not getting the result as expected.
Regards,
‎2009 Jul 11 10:02 AM
Khushi,
I already mentioned this na that try to loop at itab4 and read itab2 thn see the results.
‎2009 Jul 11 10:05 AM
khushi ,
what is your expected result if matnr does not match
you want to move data to it_del
Redards
Deepak .
‎2009 Jul 11 10:07 AM
Hi deepak,
yes, i want the same if material does not match , then append it_del.
‎2009 Jul 11 10:20 AM
Ok ..
Then listen , there is no data in your internal tables that is not matching .
your both table have data they are same i.e matnr are matching it returns sy-subrc = 0 .
so it will not append data .
that means now your code is working fine but you dont have different matnr to test .
It will be better if you test using more data using same code now .
It will work fine .
Regards
Deepak .
‎2009 Jul 11 10:25 AM
Hi Deepak,
ya, both table have same data but in itab2 there are 2 records and itab4 contains only 1and qty is different . so i want the second record in itab2 in the deleted list.
Regards,
‎2009 Jul 11 10:37 AM
ok ...
how can you compare quantity field as there may be multiple records of different quantity with same matnr and all other filed .
how you will decide which to delete .
What is difference between itab4 and itab2 data can you explain .
as columns are same .
all fields data are same except last column i.e bdmng .
now from this data what result you are expecting .
Regards
Deepak .
‎2009 Jul 11 10:53 AM
Hi Deepak,
I am working on network comparision, from one master network i have find which components are to be addeda and which are to be deleted. so this component is to be deleted as it appears more than once as compare to master network in another network. ie in master network it appears only once and in compared network it appeared twice , so i have to print that component in to be deleted list. hope u clear with the problem.
Regards,
‎2009 Jul 11 11:01 AM
hi khushi ,
Then do one thing also add this code in your read condition after comparing matnr .
read table itab4 with key itab4-matnr = itab2-matnr
itab4-bdmng = itab2-bdmng . add this line to compare qty .
Regards
Deepak .
‎2009 Jul 11 11:07 AM
Hi Khushi ,
Can you give me all field names and values in it , because you have given data of five fields .
regards
Deepak .
‎2009 Jul 11 11:20 AM
‎2009 Jul 11 11:25 AM
ha hah haha,
Your thankx brought little smile on my face .
i think you are fedup with the solutions .
Now decide which quantity to keep and which to delete .
and act according .
Regards
Deepak .