03-06-2009 5:09 AM
Hi Experts,
Please go thru and advice me,
LOOP AT RAW_MAT WHERE MATNR = FG_MAT-MATNR.
RAW_MAT-MENGE = IFG_MAT-MT101 * RAW_MAT-MENGE.
MODIFY RAW_MAT.
ENDLOOP.
Now I have to move both the internal tablesRAW_MAT and FG_MAT to same internal table IT_FINAL.
As per the requirement of my report, inorder to get multiple (records)
IDNRK from RAW_MAT for every single MATNR in FG_MAT and this is what I have
used as per my requirement. But here my all of my values are repeating twice.
Please go thru and advice if my logic is wrong else advice if there is any appropriate step
inorder to get multiple records from FG_MAT.
LOOP AT FG_MAT.
MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
LOOP AT RAW_MAT WHERE MATNR = FG_MAT-MATNR
AND WERKS = FG_MAT-WERKS.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-IDNRK TO IT_FINAL-IDNRK.
MOVE RAW_MAT-MENGE TO IT_FINAL-MENGE.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-MEINS TO IT_FINAL-MEINS.
APPEND IT_FINAL.
CLEAR: IT_FINAL-M101.
ENDLOOP.
ENDLOOP.
Thanks
Karthik
03-06-2009 5:26 AM
and also one thing
LOOP AT FG_MAT.
MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
LOOP AT RAW_MAT WHERE MATNR = FG_MAT-MATNR
MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
AND WERKS = FG_MAT-WERKS.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-IDNRK TO IT_FINAL-IDNRK.
MOVE RAW_MAT-MENGE TO IT_FINAL-MENGE.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-MEINS TO IT_FINAL-MEINS.
APPEND IT_FINAL.
CLEAR: IT_FINAL-M101.
ENDLOOP.
ENDLOOP.
put MOVE-CORRESPONDING FG_MAT TO IT_FINAL inside the loop. it works..
03-06-2009 5:15 AM
Hi,
For best coding practice we should avoid using MOVE-CORRESPONDING
It has some effect with performance issues.
So we always avoid using this keyword and use:-
MOVE str TO str1.
Regards,
Tarun
03-06-2009 5:24 AM
Hi,
before nested looping.
first sort the tables and delete adjacent duplicates for those tables.
Then u will get result fine..
Regards,
Kiran
03-06-2009 5:26 AM
Hi,
Clear your variables after append
> LOOP AT FG_MAT.
> MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
> LOOP AT RAW_MAT WHERE MATNR = FG_MAT-MATNR
> AND WERKS = FG_MAT-WERKS.
> MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS. --> moved twice
> MOVE RAW_MAT-IDNRK TO IT_FINAL-IDNRK.
> MOVE RAW_MAT-MENGE TO IT_FINAL-MENGE.
> MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
> MOVE RAW_MAT-MEINS TO IT_FINAL-MEINS.
> APPEND IT_FINAL.
> CLEAR: IT_FINAL-M101,
> IT_FINAL-CKGS,IT_FINAL-IDNRK, IT_FINAL-MENGE ,IT_FINAL-MEINS.
> ENDLOOP.
> clear IT_FINAL.
> ENDLOOP.
03-06-2009 5:26 AM
and also one thing
LOOP AT FG_MAT.
MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
LOOP AT RAW_MAT WHERE MATNR = FG_MAT-MATNR
MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
AND WERKS = FG_MAT-WERKS.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-IDNRK TO IT_FINAL-IDNRK.
MOVE RAW_MAT-MENGE TO IT_FINAL-MENGE.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-MEINS TO IT_FINAL-MEINS.
APPEND IT_FINAL.
CLEAR: IT_FINAL-M101.
ENDLOOP.
ENDLOOP.
put MOVE-CORRESPONDING FG_MAT TO IT_FINAL inside the loop. it works..
03-06-2009 5:27 AM
Use At New MATNR to loop on each MATNR only once.
LOOP AT FG_MAT.
AT NEW MATNR.
MOVE-CORRESPONDING FG_MAT TO IT_FINAL.
LOOP AT RAW_MAT WHERE MATNR = FG_MAT-MATNR
AND WERKS = FG_MAT-WERKS.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-IDNRK TO IT_FINAL-IDNRK.
MOVE RAW_MAT-MENGE TO IT_FINAL-MENGE.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-MEINS TO IT_FINAL-MEINS.
APPEND IT_FINAL.
CLEAR: IT_FINAL-M101.
ENDLOOP.
ENDAT.
ENDLOOP.
Regards,
Anil
03-06-2009 5:32 AM
Move-corresponding fg_mat[] to it_final[]. "--------->Get all Data of Fg_mat inot table IT_final
Loop at raw_mat.
Read table it_final with key matnr = raw_mat-matnr. "----------> Read matching materials.
If sy-sunrc = 0.
Modify it_final from raw_mat transproting CKGS IDNRK MENGE CKGS MEINS . "--->If the material matches modify It_final
endif.
endloop.
Regards,
Gurpreet
03-06-2009 5:35 AM
Before going to loop you have to sort the internal table and delete the adjacent duplicates.
It is better to avoid Move-Corresponding because of performance issue. After appending the internal table you want to clear the header.
You check the data while debugging.
Regards,
Joan
03-06-2009 5:39 AM
Chek this:
LOOP AT FG_MAT.
READ TABLE RAW_MAT WITH KEY MATNR = FG_MAT-MATNR
WERKS = FG_MAT-WERKS.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-IDNRK TO IT_FINAL-IDNRK.
MOVE RAW_MAT-MENGE TO IT_FINAL-MENGE.
MOVE RAW_MAT-CKGS TO IT_FINAL-CKGS.
MOVE RAW_MAT-MEINS TO IT_FINAL-MEINS.
APPEND IT_FINAL.
CLEAR: IT_FINAL-M101.
ENDLOOP.
03-06-2009 7:54 AM
Hi Experts,
Non of the above said logic is working for me,
My output is correct if lifnr, werks and budat is obligatory in selection screen but I am worried if there won't be any problem in future.
Also if write like the below, my output is correct in development as there are only few records in it
Please advice me.
SORT RAW_MAT BY IDNRK WERKS.
DELETE ADJACENT DUPLICATES FROM RAW_MAT COMPARING ALL FIELDS.
03-06-2009 9:07 AM
Hi,
Generally we dnt use MOVE-CORRESPONDING due to some performance issues
If we use:-
MOVE-CORRESPONDING it_header TO it_final.
Then this statement will match all the fields from it_header to it_final till it finds the same column and then transfer the values from one to other table.
So, this is considered to be time taking and a lot of resources can be used in this process.
However if we use:-
LOOP AT it_header.
MOVE : it_header-field1 TO it_final-field1,
it_header-field2 TO it_final-field2,
it_header-field3 TO it_final-field3.
" and so on.....
APPEND it_final.
CLEAR it_final.
CLEAR it_header.
ENDLOOP.
Using this approcah we already mae sure the field type match.
So no extra time is taken to find the appropiate field type.
And thus eliminates performance issues.
For reference reading on Performance Issues you can refer link:-
https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/performance
Hope this helps you.
Regards,
Tarun
03-16-2009 6:17 PM
Karthik-
Have you solved you issue yet? I was away on vacation, so I was unable to respond.
If you are still looking for help - I would be curious as to the contents of the IT_RAW and the FG_MAT tables before you begin the process of totaling. I am wondering if some of the results are causing the double rows.
Regards,
Mark
Edited by: Mark Schwendinger on Mar 16, 2009 7:19 PM