Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issue with LOOP

Former Member
0 Likes
672

Hi All,

I have an internal table ITAB where WBS element, SKF, Fiscal Period, Fiscal year and Quantity fields are present.

I want to append the WBS elements into other table (ITAB2) for processing the data into Function module to create a posting.

While looping, i have to append all these values for a particular period and then execute Function module.

Whenever a period changes i have to append again and then execute FMs.

Basically, the postings for multiple WBS for a particular Period should be done.

I believe while looping ITAB, i need to control this using a control break statement.

But how to incorporate the logic?

Your help will be appreciated....

Regards

Pavan

1 ACCEPTED SOLUTION
Read only

former_member451655
Active Participant
0 Likes
640

Hi ,

Sort your First ITAB with "period" and use AT-New statement inside a loop , to get the next change values.

Cheers ,

Dilum

5 REPLIES 5
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
640

you can use the control break statements like on change of / at new.

Read only

Former Member
0 Likes
640

you can use AT-NEW events to control the flow of your program and logic.

Regards

Read only

faisalatsap
Active Contributor
0 Likes
640

Hi, Sanganal

You can get much help about Control Break Statements after a little search, you can also get by writing AT in your ABAP Editor Press F1 and Double Click on AT - itab, ABAP Statement

Please Reply if any Issue,

Thanks and Regards,

Faisal

Read only

former_member451655
Active Participant
0 Likes
641

Hi ,

Sort your First ITAB with "period" and use AT-New statement inside a loop , to get the next change values.

Cheers ,

Dilum

Read only

Former Member
0 Likes
640

Hi,

Control break statements :

1. AT NEW f.

2. AT END OF f.

3. AT FIRST.

4. AT LAST.

In a LOOP which processes an internal table, you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT. The sequence of statements which lies between them is then executed if a control break occurs.

Example :

SORT it_final BY belnr.

*  To add the Local Currency Amount, Quantity and Quantity in EUn at new Document Number.

                   LOOP AT it_final INTO wa_final.
                     wa_final1 = wa_final.

                     AT NEW belnr.
                       g_belnr = wa_final1-belnr.


                     ENDAT.

                     IF wa_final1-belnr = g_belnr.
                       g_dmbtr_sum = g_dmbtr_sum + wa_final1-dmbtr.
                       g_menge_sum = g_menge_sum + wa_final1-menge.
                       g_erfmg_sum = g_erfmg_sum + wa_final1-erfmg.
                     ENDIF.

                     AT END OF belnr.
                       wa_final1-dmbtr = g_dmbtr_sum.
                       wa_final1-menge = g_menge_sum.
                       wa_final1-erfmg = g_erfmg_sum.
                       g_dmbtr_sum = 0.
                       g_erfmg_sum = 0.
                       g_menge_sum = 0.

                       APPEND wa_final1 TO it_final1.
                       CLEAR : wa_final,
                               wa_final1.
                     ENDAT.


                   ENDLOOP.

Hope this helps.

Thanks,