‎2009 Dec 15 8:09 AM
hi masters,
i have in my internal table 4 records. i want to update all the 4 records, so am LOOPING it.
when i loop the internal table it finishes 4records and again starts with the 1st and it goes on and not ending.
what could be the problem... how can i solve it?
this is my code:
loop at i_mara INTO WA_MARA.
move WA_mara-matnr to t_key.
LOOP AT lt_chars.
AT NEW classnum.
CLEAR: lt_allocvaluesnumnew,
lt_allocvaluescharnew,
lt_allocvaluescurrnew,
lt_return.
REFRESH: lt_allocvaluesnumnew,
lt_allocvaluescharnew,
lt_allocvaluescurrnew,
lt_return.
l_classnum = lt_chars-classnum.
l_classtype = lt_chars-classtype.
ENDAT.
REFRESH lt_return.
CALL FUNCTION 'BAPI_CHARACT_GETDETAIL'
EXPORTING
charactname = lt_chars-atnam
IMPORTING
charactdetail = ls_charactdetail
TABLES
return = lt_return.
REFRESH lt_return.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = l_objectkey
objecttable = l_objecttable
classnum = l_classnum
classtype = l_classtype
TABLES
allocvaluesnumnew = lt_allocvaluesnumnew
allocvaluescharnew = lt_allocvaluescharnew
allocvaluescurrnew = lt_allocvaluescurrnew
return = lt_return
.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
ENDAT.
ENDLOOP.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
APPEND WA_MARA TO I_MARA.
MODIFY MARA FROM TABLE I_MARA." TRANSPORTING MEINS.
endloop.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
APPEND WA_MARA TO I_MARA.
MODIFY MARA FROM TABLE I_MARA." TRANSPORTING MEINS.
endloop.
‎2009 Dec 15 8:18 AM
Hi,
Check APPEND WA_MARA TO I_MARA statement in your coding
appending new line to same internal table will give endless loop.
i guess only modify statement is enough to update.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
APPEND WA_MARA TO I_MARA.
MODIFY MARA FROM TABLE I_MARA." TRANSPORTING MEINS.
endloop.
Regards,
Ravi
‎2009 Dec 15 8:18 AM
Hi,
Check APPEND WA_MARA TO I_MARA statement in your coding
appending new line to same internal table will give endless loop.
i guess only modify statement is enough to update.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
APPEND WA_MARA TO I_MARA.
MODIFY MARA FROM TABLE I_MARA." TRANSPORTING MEINS.
endloop.
Regards,
Ravi
‎2009 Dec 15 8:18 AM
Hi,
U are appending the same internal table inside the loop. See the code.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
APPEND WA_MARA TO I_MARA.This wll create the infinite loop.
Use another temp internal table for your purpose.
Rgds,
Anversha
‎2009 Dec 15 8:29 AM
Hi,
I think you wanted to Modify the internal table. You have instead appended data to it.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
APPEND WA_MARA TO I_MARA. "modify i_mara from wa_mara index sy-tabix.
‎2009 Dec 15 8:42 AM
Hi Pasalabasker,
Never use APPEND to the same internal Table inside loop of same internal Table.. If will be never ending process.. as it's appending same internal table...
Change below line of code..
"APPEND WA_MARA TO I_MARA. " Comment this line..
MODIFY I_MARA FROM WA_MARA INDEX SY-TABIX. " Insert this lineModify your code as below...
loop at i_mara INTO WA_MARA.
move WA_mara-matnr to t_key.
LOOP AT lt_chars.
AT NEW classnum.
CLEAR: lt_allocvaluesnumnew,
lt_allocvaluescharnew,
lt_allocvaluescurrnew,
lt_return.
REFRESH: lt_allocvaluesnumnew,
lt_allocvaluescharnew,
lt_allocvaluescurrnew,
lt_return.
l_classnum = lt_chars-classnum.
l_classtype = lt_chars-classtype.
ENDAT.
REFRESH lt_return.
CALL FUNCTION 'BAPI_CHARACT_GETDETAIL'
EXPORTING
charactname = lt_chars-atnam
IMPORTING
charactdetail = ls_charactdetail
TABLES
return = lt_return.
REFRESH lt_return.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = l_objectkey
objecttable = l_objecttable
classnum = l_classnum
classtype = l_classtype
TABLES
allocvaluesnumnew = lt_allocvaluesnumnew
allocvaluescharnew = lt_allocvaluescharnew
allocvaluescurrnew = lt_allocvaluescurrnew
return = lt_return
.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
ENDAT.
ENDLOOP.
move: MARA-MEINS TO WA_MARA-MEINS,
MARA-LVORM TO WA_MARA-LVORM.
"APPEND WA_MARA TO I_MARA. " Comment this line..
MODIFY I_MARA FROM WA_MARA INDEX SY-TABIX. " Insert this line
MODIFY MARA FROM TABLE I_MARA." TRANSPORTING MEINS.
endloop.Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya
‎2009 Dec 17 10:26 AM
i have sorted problem by self however it is great to see your reply.
thank you all for ur great contribution.
thanks again.