‎2009 Mar 13 11:24 AM
Hi friends,
LOOP AT BODY1.
LOOP AT TRANSFER_ITAB.
IF BODY1-SMONTH = TRANSFER_ITAB-TMONTH .
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
APPEND BODY1.
CLEAR BODY1.
exit.
ELSE.
continue.
ENDIF.
ENDLOOP.
APPEND BODY1.
CLEAR BODY1.
ENDLOOP.
**********************************
This is my loop.
BODY1 IS OUTER LOOP. (It has 4,5, 6, 7, 8,9,10, 11,12)
TRANSFER_ITAB IS INNER LOOP.(It has 4, 5 and 😎
When body1 has 4 and inner loop has also 4 .IF condition will be satisfy and then exit from if con. and loop.
When body1 would be 5 it will run same as earlier. But, when bod1 would be 6 my innerloop condition is not fulfill. I need here the control should go outer loop.
I hope my problem u guys would catch.
Regards,
Swapnika
‎2009 Mar 13 11:33 AM
loop at body 1.
read table transfer_itab with key tmonth = body1-smonth.
if sy-subrc = 0.
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
append body1.
clear body1.
endif.
endloop.
Edited by: BrightSide on Mar 13, 2009 11:34 AM
‎2009 Mar 13 11:30 AM
instead you can add some where condition in the inner internal talbe.
‎2009 Mar 13 11:30 AM
Hi,
Try like this, I hope u r problem was solved.
LOOP AT BODY1.
LOOP AT TRANSFER_ITAB.
IF BODY1-SMONTH = TRANSFER_ITAB-TMONTH .
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
APPEND BODY1.
CLEAR BODY1.
ELSE.
exit.
ENDIF.
ENDLOOP.
APPEND BODY1.
CLEAR BODY1.
ENDLOOP.
‎2009 Mar 13 11:39 AM
hi srinu,
Problem would be occur in scond time processing.
When outer loop have 5 and inner loop have 4 in first time process. It will be exit from the loop. But in inner loop has also 5. It will not consider if we use exit in this place.
Regards,
Swapnika
‎2009 Mar 13 11:33 AM
loop at body 1.
read table transfer_itab with key tmonth = body1-smonth.
if sy-subrc = 0.
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
append body1.
clear body1.
endif.
endloop.
Edited by: BrightSide on Mar 13, 2009 11:34 AM
‎2009 Mar 13 12:19 PM
‎2009 Mar 13 11:33 AM
Hi place the following code in place of your code.
LOOP AT BODY1.
LOOP AT TRANSFER_ITAB where TMONTH = BODY1-SMONTH .
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
APPEND BODY1.
CLEAR BODY1.
ENDLOOP.
APPEND BODY1.
CLEAR BODY1.
ENDLOOP.
‎2009 Mar 13 11:38 AM
But .it goes to infinite loop ...coz u always appending body1.
‎2009 Mar 13 11:42 AM
‎2009 Mar 13 11:53 AM
well...thats wot i mean...coz u appending same table everytime the condition satisfies it appends to same table and that table will never run out of data and the loop will be endless.
to solve this
you should declare another internal table with the same structure
loop at body1
read table <anotha table> with key <key> = body1-<field>
if sy-subrc = 0.
move the fileds to new table.
append new table
clear body1.
endif.
endloop.
‎2009 Mar 13 11:43 AM
Can you elaborate your requirement again, i hope instead of making code complex by using nested loops, try with alternatives.
But i am sure that the loop in your code will be infinitive.
Regards,
~Satya
‎2009 Mar 13 11:48 AM
Hi,
LOOP AT BODY1.
LOOP AT TRANSFER_ITAB where SMONTH = BODY1-SMONTH .
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
APPEND BODY1.
CLEAR BODY1.
exit.
ENDLOOP.
ENDLOOP.
It'll work , check this,
I have one doubt, If u append the same internal table(BODY1) inside the BODY1 then it'll be endless loop right.
so create same structure other internal table and append it after the execution of the loop . append new internal table to BODY1.
Edited by: Selva M on Mar 13, 2009 5:21 PM
‎2009 Mar 13 12:10 PM
Hi Selva,
i m getting ur point but i have made a structure body1_itab which transfers tha data to smartform so i need to use same body1, here i can use Modify i think, m i right?
Plz tell me.
Regards,
Swapnika
‎2009 Mar 13 12:14 PM
‎2009 Mar 13 12:16 PM
Hi,
Yes, U can use modify instead of append or use one internal table like BODY1_NEW which has same structure as BODY1.
After coming out of the loop, append BODY!_NEW to BODY1. and do delete adjacent duplicates.
‎2009 Mar 13 11:49 AM
Hi friend,
Try like this.
Data c type i value 0.
LOOP AT BODY1.
LOOP AT TRANSFER_ITAB.
if c ne 1.
IF BODY1-SMONTH = TRANSFER_ITAB-TMONTH .
c = 1.
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
APPEND BODY1.
CLEAR BODY1.
continue.
ENDIF.
else.
c = 0.
exit.
endif.
ENDLOOP.
APPEND BODY1.
CLEAR BODY1.
ENDLOOP.
‎2009 Mar 13 11:49 AM
Hi friend,
Try like this.
Data c type i value 0.
LOOP AT BODY1.
LOOP AT TRANSFER_ITAB.
if c ne 1.
IF BODY1-SMONTH = TRANSFER_ITAB-TMONTH .
c = 1.
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
APPEND BODY1.
CLEAR BODY1.
continue.
ENDIF.
else.
c = 0.
exit.
endif.
ENDLOOP.
APPEND BODY1.
CLEAR BODY1.
ENDLOOP.
Thanks.
‎2009 Mar 13 11:57 AM
hi fried,
When outer loop has 6 and inner loop has not 6. The control should go to outerloop and become 7.
But this coding move only inside the innerloop .
Plz try to modified it.
Regards,
Swapnika
‎2009 Mar 13 12:05 PM
Hi,
I think what u r doing shud work when bod1 is 6 control will come to outer loop,but 1st it will loop all over again to the already looped ones i.e. 4 and 5,
so inorder to improve oerformance what u can do is:
DATA : g_cnt TYPE i,
g_flag(1) TYPE c.
LOOP AT BODY1 INTO wa_ BODY1.
LOOP AT TRANSFER_ITAB INTO wa_TRANSFER_ITAB.
IF WA_BODY1-SMONTH = WA_TRANSFER_ITAB-TMONTH .
MOVE WA_TRANSFER_ITAB-EMPLOYEEPF TO WA_BODY1-EMPLOYEEPF.
MOVE WA_TRANSFER_ITAB-EMPLOYERPF TO WA_BODY1-EMPLOYERPF.
APPEND wa_BODY1 to BODY1.
DELETE TABLE TRANSFER_ITAB FROM wa_TRANSFER_ITAB.
DESCRIBE TABLE TRANSFER_ITAB LINES g_cnt.
EXIT.
ELSE.
IF g_cnt > 1.
CONTINUE.
ELSE.
g_flag = 'X'.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
if g_flag = 'X'.
exit.
ENDIF.
ENDLOOP.
READ TABLE TRANSFER_ITAB INTO wa_TRANSFER_ITAB INDEX 1.
READ TABLE BODY1 INTO WA_BODY1 WITH KEY SMONTH = WA_TRANSFER_ITAB-TMONTH BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE WA_TRANSFER_ITAB-EMPLOYEEPF TO WA_BODY1-EMPLOYEEPF.
MOVE WA_TRANSFER_ITAB-EMPLOYERPF TO WA_BODY1-EMPLOYERPF.
APPEND wa_BODY1 to BODY1.
ENDIF.Regards,
Neha
‎2009 Mar 13 12:21 PM
Hi,
Instead of using loop inside a loop the better way to proceed with this could be using read statement.
LOOP AT BODY1.
read table transfer_tab with key month = body1-smonth.
if sy-subrc = 0.
MOVE TRANSFER_ITAB-EMPLOYEEPF TO BODY1-EMPLOYEEPF.
MOVE TRANSFER_ITAB-EMPLOYERPF TO BODY1-EMPLOYERPF.
modify body1 from body1 transporting employeepf employerpf where smonth = body1-smonth.
endif.
ENDLOOP.
I think this should solve your purpose.
Regards,
Siddarth