2008 Jul 21 9:50 AM
hi ,
i hav used loop(w_cdpos) inside the same loop, so it is showing error, is there any alternate solution for this. pls send me hard code.
SELECT * FROM cdhdr INTO TABLE w_cdhdr
WHERE objectclas = 'KRED'
AND objectid = w_lfa1-lifnr
AND udate IN c_date
AND change_ind = 'I'.
SELECT * FROM cdpos INTO TABLE w_cdpos
FOR ALL ENTRIES IN w_cdhdr
WHERE objectclas = 'KRED'
AND objectid = w_lfa1-lifnr
AND tabname = 'LFBK'
AND changenr = w_cdhdr-changenr .
loop at w_cdpos. (giv me alternate solution)
IF sy-dbcnt GT 1 .
SORT w_cdpos BY changenr ASCENDING .
CLEAR w_result .
w_result-lifnr = w_lfa1-lifnr .
w_result-fname = 'BANK' .
w_result-ddtext = text-001 .
LOOP AT w_cdpos.(giv me alternate solution)
ws_cdpos = w_cdpos .
AT NEW changenr .
IF w_result-value_old IS INITIAL .
w_result-value_old = ws_cdpos-tabkey+13(57) .
ELSE .
w_result-value_new = ws_cdpos-tabkey+13(57) .
ENDIF .
ENDAT .
AT END OF changenr .
IF w_result-value_old IS NOT INITIAL
AND w_result-value_new IS NOT INITIAL .
w_result-value_old = w_result-value_new .
CLEAR w_result-value_new .
ENDIF .
ENDAT .
MOVE-CORRESPONDING ws_cdpos TO w_result.
APPEND w_result .
ENDLOOP.
ENDIF .
endloop.
2008 Jul 21 10:00 AM
Hi,
You will use 2 loops only if u want to get the desired o/p like for one row of first loop you want to
execute the second loop for all entry.
But I feel if u don't want to do that then you can get the desired o/p using one loop only.Don't forget to sort the table when u r using AT NEW of AT END OF w_cdpos by changenr.
Regards,
Rajesh Akarte
2008 Jul 21 9:58 AM
Hii,.,
Try this,,
DESCRIBE TABLE w_cdpos LINES wf_lines.
If wf_lines GT 1.
SORT w_cdpos BY changenr ASCENDING .
CLEAR w_result .
w_result-lifnr = w_lfa1-lifnr .
w_result-fname = 'BANK' .
w_result-ddtext = text-001 .
LOOP AT w_cdpos.(giv me alternate solution)
ws_cdpos = w_cdpos .
AT NEW changenr .
IF w_result-value_old IS INITIAL .
w_result-value_old = ws_cdpos-tabkey+13(57) .
ELSE .
w_result-value_new = ws_cdpos-tabkey+13(57) .
ENDIF .
ENDAT .
AT END OF changenr .
IF w_result-value_old IS NOT INITIAL
AND w_result-value_new IS NOT INITIAL .
w_result-value_old = w_result-value_new .
CLEAR w_result-value_new .
ENDIF .
ENDAT .
MOVE-CORRESPONDING ws_cdpos TO w_result.
APPEND w_result .
ENDLOOP.
Endif.
Regards,
Sachin M M
Edited by: Sachin Mathapati on Jul 21, 2008 2:31 PM
2008 Jul 21 9:58 AM
Hi,
Check this links:
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/performanceTuningusingParallelCursor
http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm
Regards
Adil
2008 Jul 21 10:00 AM
Hi,
You will use 2 loops only if u want to get the desired o/p like for one row of first loop you want to
execute the second loop for all entry.
But I feel if u don't want to do that then you can get the desired o/p using one loop only.Don't forget to sort the table when u r using AT NEW of AT END OF w_cdpos by changenr.
Regards,
Rajesh Akarte
2008 Jul 21 10:03 AM
2008 Jul 21 10:55 AM
Hi,
before starting the loop, you need to use DESCRIBE statement to check the number of records in that internal table.
if records found ...then sort the internal table.
Regards,
venkat n