Calculations using Contrl Break Statements

Hi,
My internal table consists of 7 columns and i want to add all the fields in column E at end of every field in column C.
How can i do that. i have used "at end of TXJCD" but it is not working.
  A       B             C                  D            E                F    G
2008  SG11  0500000000  0002400000  625.00-         003  H
2008  SG11  0500000000  0002400000  62.50-           004  H
2008  SG11  0500000000  0002400000  12500.00-      005  H
2008  SG11  0500000000  0002400000   625.00-         005  H
2008  SG11  0500000000  0002400000   3125.00-        005  H
2008  SG11  0500000000  0002400000   272.02-     003  H
2008  SG11  0500000000  0002400000   72.24-     003  H
2008  SG11  0600000000  0002400000   1450.00-     003  H
2008  SG11  0600000000  0002400000   1450.00     005  S
Please suggest the logic for that.
Regards,
Ramana

first of all internal table is sorted by A B C.
Loop at itab.
at new c.
clear v_sum.
endat.
v_sum = v_sum + itab-e.
at end of c.
V_SUM will contain the total sum at the end of "c".
endat.
endloop.
Reward if useful.

Similar Messages

  • What happen if i use controll break statement in between select & endselect

    Hi all,
    what happen if i use controll break statement in between select & endselect ?
    Thanks in Advance
    KR

    Hi for reference u can go through this code example
    data:
      fs_tab like sflight.
      data:
       t_tab like standard table of fs_tab.
       select * from sflight into table t_tab.
       loop at t_tab into fs_tab.
         write: / fs_tab-carrid.
       endloop.
       refresh t_tab.
       clear fs_tab.
       select * from sflight into fs_tab.
         at new fs_tab-carrid.
           append fs_tab to t_tab.
         endat.
       endselect.

  • How can I use control break statement in my requirement

    Hi ABAPers,
    In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
    internal table fields :
    audat  prdha  ipnum  netwr
    02      abc     1      100
    02      abc     2      200
    02      xyz     3      300
    03      abc     4      100
    03      xyz     5      300
    03      xyz     6      200
    i need output like this:
    audat  prdha  ipnum  netwr
    02      abc     1,2      300
    02      xyz     3         300
    03      abc     4         100
    03      xyz     5,6      500
    Can anyone suggest me logic for this by using control break statements
    Thanks in advance,
    Ankita
    Moderator Message: Duplciate Post.
    Edited by: kishan P on Apr 14, 2011 3:03 PM

    Hi ABAPers,
    In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
    internal table fields :
    audat  prdha  ipnum  netwr
    02      abc     1      100
    02      abc     2      200
    02      xyz     3      300
    03      abc     4      100
    03      xyz     5      300
    03      xyz     6      200
    i need output like this:
    audat  prdha  ipnum  netwr
    02      abc     1,2      300
    02      xyz     3         300
    03      abc     4         100
    03      xyz     5,6      500
    Can anyone suggest me logic for this by using control break statements
    Thanks in advance,
    Ankita
    Moderator Message: Duplciate Post.
    Edited by: kishan P on Apr 14, 2011 3:03 PM

  • Need help with a For loop that uses a Break statement

    I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
    public class Break
    public static void main ( String args []) (;
         int total = 0
         int counter = 0
         for { (int number = 100; total >=50; total --)
         if (counter == 0)
         break;
         } // end of for loop
         int output = number/counter
         system.out.printf("The number is" %d output/n)
         }// end of method main
    }// end of class Break

    Im sorry I didnt explain myself very well i do not need the break statement at all.
    I now have this code:
    public class BreakTest
       public static void main( String args[] )
          int count; // control variable also used after loop terminates
         for (int i = 100; i >= 50; i = ++count)
       if (i >= 50) {
        continue;
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
       } // end main
    } // end class BreakTest
    /code]
    and i get these error messages:
    F:\csc148>javac BreakTest.java
    BreakTest.java:9: variable count might not have been initialized
         for (int i = 100; i >= 50; i = ++count)
                                          ^
    BreakTest.java:15: variable count might not have been initialized
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
                                                                    ^
    2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Calculation using multiple select statements - APEX 4.0

    Hello,
    I am new to APEX, PL/SQL and have some SQL knowledge, but I pick up things quickly. I want to make a page item equal to the value of a Select statement minus another Select statement. The statements pull from the same tables and only differ slightly in the where clause. I do not know the best way to create this calculation. Can someone please assist.
    Select Statement #1
    select     sum(JE_TRANSACTIONS.DEBIT_AMOUNT) as "Release"
    from     "REVREC_FORMS" "REVREC_FORMS",
         "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
         "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and     "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and      "JOURNAL_ENTRIES"."RELEASE_TYPE" ='Release'
    and     "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and     "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_ID
    Select Statement #2
    select     sum(JE_TRANSACTIONS.DEBIT_AMOUNT) as "Deferral"
    from     "REVREC_FORMS" "REVREC_FORMS",
         "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
         "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and     "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and      "JOURNAL_ENTRIES"."RELEASE_TYPE" ='Deferral'
    and     "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and     "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_ID

    How about
    select   sum(decode(release_type,'Deferral',je_transactions.debit_amount)) - sum(decode(release_type,'Release',je_transactions.debit_amount)) as result
    from   "REVREC_FORMS" "REVREC_FORMS",
    "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
    "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and  "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and  "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and  "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_IDScott

  • Using contro; break statement

    Hi experts,
    I have a  interanl table with three fields  material no ,qunatity  and  price,
    my requiremenr is if same material in   ITAB  i want to add quantity & price   in same line.
    Use full rewads.....

    Hi,
    use the key word COLLECT
    check out the following code and check the values in teable lt_test2
    all the wrbtr values for a single matnr are added here
    TYPES : BEGIN OF ts_test,
            matnr TYPE matnr,
            wrbtr TYPE wrbtr,
      END OF ts_test.
    DATA : ls_test TYPE ts_test,
           lt_test TYPE TABLE OF ts_test,
           lt_test2 TYPE TABLE OF ts_test.
    ls_test-matnr = '23'.
    ls_test-wrbtr = '100.00'.
    APPEND ls_test TO lt_test.
    ls_test-matnr = '23'.
    ls_test-wrbtr = '103.00'.
    APPEND ls_test TO lt_test.
    ls_test-matnr = '23'.
    ls_test-wrbtr = '101.00'.
    APPEND ls_test TO lt_test.
    ls_test-matnr = '24'.
    ls_test-wrbtr = '102.00'.
    APPEND ls_test TO lt_test.
    LOOP AT lt_test INTO ls_test.
        COLLECT ls_test INTO lt_test2.
    ENDLOOP.

  • In alv report can i use control break events? if no .whay?

    Hi all,
    in alv report can i use control break events? if no .whay?

    hi,
    you can use control break statements in ALV report.
    for example: if one PO is having more than one line item, that time you need to display PO only once.

  • Control break statements in smart forms

    Hi,
    Can we use control break statements(at new,at end of) in smart forms?
    if no why?
    if yes, how?
    Regards,
    Sonika

    you can use control block statements in smartforms by using the SORT events.
    In TABLES go to to the SORT section.Here you can give the field by which you want the table to be sorted.There are two radio buttons available for sort : SORT BEGIN and SORT end.
    On selecting any one sort event are generated automatically and event nodes are created in smartforms.Inside these event nodes you can add text nodes or code nodes and write your code.
    SORT BEGIN works like AT NEW
    SORT END works like AT END OF.

  • Control Break Statements in HR-ABAP

    Hi Guru's
    I'm new to hr-abap i would like some guidance, can we use control break statements in abap-hr.
    Thanks & Regards
    Raj.

    Hi Raj,
    You mean AT .. ENDAT statements inside loops right?
    Yes, they are definitely used in HR-ABAP.
    REPORT ZTRIAL.
    INFOTYPES: 0022.
    GET PERNR.
    LOOP AT P0022.
    AT FIRST.
    WRITE: 'First record'.
    ENDAT.
    AT NEW SLART.
    WRITE: 'School type changed'.
    ENDAT.
    ENDLOOP.
    Regards,
    Dilek

  • Break statement does not work outside of switch or loop?

    I was just messing around in Xcode and I discovered that, when I tried to use the break statement to exit a block of code, I got an error ("break statement not within loop or switch"). I thought the break statement was supposed to be able to be used to exit any block of code at any time, so I opened my Mac OS X Programming book by Wrox (a bit outdated, uses older version of Xcode/Interface Builder, but applicable enough), and the book confirmed that I should be able to use the break statement within any block of code, not just switch/case construction and loops. I assume something has changed in the newer version of Xcode since this book has been published, but I'm curious, so can anyone explain this to me? Thanks!

    Yeah, that seems to be the case, and that's the only way I've ever used "break," but I did think it could be used to exit any block of code, especially having read it in the book I have. The book is Mac OS X Programming by Wrox, and on page 175 in the "The C Language" chapter, it says:
    "break" is not only useful for "switch" and "while" statements; it can actually be used anytime you want to escape a block of code enclosed in braces. Execution is immediately transferred to the closing brace, and continues from there."
    Anyways, I guess it is possible that in some older standard of C the "break" statement was allowed in these cases, since I can't imagine the book being out and out wrong, but you're right, it certainly seems to be -- interesting...

  • Bdc on vk11 using control break events

    hi
    have any one done bdc for vk11 using control break events.my flat file is
    ZTAX     X     IN     1000     1200     2000     A0
    ZTAX     X     IN     1000     1210     3000     A1
    ZTAX     X     US     7676     01     4000     L3
    ZTAX     X     US     7676     02     5000     s1
    i need the logic for this any sample code will be useful

    hi, check the sample code using Control break statements.
      LOOP AT IT_MAIN.
    WRITE : IT_MAIN.
    C_TABIX = SY-TABIX.
    <b>AT NEW LIFNR_001.</b>
    READ TABLE IT_MAIN INDEX C_TABIX.
    REFRESH IT_BDC.
    perform bdc_dynpro      using 'SAPMM06E' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM06E-BSTNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'EKKO-LIFNR'
                                  IT_MAIN-LIFNR_001.
    perform bdc_field       using 'RM06E-BSART'
                                  IT_MAIN-BSART_002.
    perform bdc_field       using 'RM06E-BEDAT'
                                  IT_MAIN-BEDAT_003.
    perform bdc_field       using 'EKKO-EKORG'
                                  IT_MAIN-EKORG_004.
    perform bdc_field       using 'EKKO-EKGRP'
                                  IT_MAIN-EKGRP_005.
    perform bdc_field       using 'RM06E-LPEIN'
                                  IT_MAIN-LPEIN_006.
    perform bdc_field       using 'RM06E-WERKS'
                                  IT_MAIN-WERKS_007.
    MOVE 1 TO CNT.
    <b>ENDAT.</b>
    perform bdc_dynpro      using 'SAPMM06E' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKPO-TXZ01(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    CONCATENATE 'EKPO-EMATN(' CNT ')' INTO FLD.
    perform bdc_field       using FLD IT_MAIN-EMATN_01_008.
    CONCATENATE 'EKPO-TXZ01(' CNT ')' INTO FLD.
    perform bdc_field       using FLD IT_MAIN-TXZ01_01_009.
    CONCATENATE 'EKPO-MENGE(' CNT ')' INTO FLD.
    perform bdc_field       using FLD IT_MAIN-MENGE_01_010.
    perform bdc_dynpro      using 'SAPMM06E' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM06E-EBELP'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    CNT = CNT + 1.
           IF CNT = 6.
            CNT = 1.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                                  '=P+'.
           ENDIF.
    <b>AT END OF LIFNR_001.</b>
    READ TABLE IT_MAIN INDEX C_TABIX.
    RECORD = IT_MAIN.
    perform bdc_dynpro      using 'SAPLSPO1' '0100'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    CALL TRANSACTION 'ME21' USING IT_BDC MODE 'A' MESSAGES INTO IT_MESSAGES.
      clear: cnt, C_tabix .
    <b>ENDAT.</b>
    ENDLOOP.

  • Best practice: Using break statement inside for loop

    Hi All,
    Using break statment inside FOR loop is a best practice or not?
    I have given some sample code:
    1. With break statement
    2. With some boolean variable that decide whether to come out of the loop or not.
    for(int i = 0; i < 10; i++){
    if(i == 5){
    break;
    boolean breakForLoop = false;
    for(int i = 0; i < 10 && !breakForLoop; i++){
    if(i == 5){
    breakForLoop = true;
    The example may be a stupid one. But i want to know which one is good?
    Thanks and Regards,
    Ashok kumar B.

    Actually, it's bad practice to use break anywhere other than in conjunction with a switch statement.Presumably, if you favour:
    boolean test = true;
    while (test)
      test = foo && bar;
      if (test)
    }overfor (;;)
      if (! ( foo && bar) ) break;
    }then you also favour
    boolean test = foo && bar;
    if (test)
    }overif (foo && bar)
    }Or can you justify your statement with any example which doesn't cause more complexity, more variables in scope, and multiple assignments and tests?

  • Using break statement

    Hi,
    I have a function, which has to check if any one of the 20 feelds are set - If so it has to return true.
    As of now i am doing lik this:
    boolean xyz(object a)
    result=false;
    if(isTure(a.A)
    result=true;
    if(isTrue(a.B)
    result=true;
    ....like this i am adding 20 if cinditions.. which doesn't lokk good.
    Can i use Break, so that if any one is true- It will break and return true.
    Please help me. I am new to java and want to now the effecient way to write this function

    Try to use If else statements.
    if(isTure(a.A){
         return true;
         break;
    else if(isTrue(a.B))
         return true;
         break;
    ...like this upto 20
    return false;Cheers.That's just plain silly code. No use in having a break following a return, break has no meaning outside a loop or a switch and don't need else-if if you're using return statements.
    3 options:
    1. Use else ifif (isTrue(a.A)) result = true;
    else if (isTrue(a.B)) result = true;
    //...2. Use return statementsif (isTrue(a.A)) return true;
    if (isTrue(a.B)) return true;
    // 20 more
    return false;3. Make it a real predicate functionreturn isTrue(a.A) || isTrue(a.B) || isTrue(a.C) // ...

  • Doubt in control break statement

    Hi All,
    Is there any way to trigger control break statements at new & at end of for non primary key fields.
    i want to trigger both control break statements for my requirement , not at change of, because i want to trigger at end of also. Please let me know if any possibility. Thanks
    regards
    vishal

    hi vishal,
    Variants:
    1. AT NEW f.
    2. AT END OF f.
    3. AT FIRST.
    4. AT LAST.
    Effect
    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.
    You can use these key words for control break processing with internal tables only if a loop is actively processing an internal table and reference is to the innermost currently active loop.
    The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant.
    At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:
    All character type fields (on the right) are filled with "*" after the current control level key.
    All other fields (on the right) are set to their initial values after the current control level key.
    Between AT and ENDAT, you can use SUM to insert the appropriate control totals in the numeric fields (see also ABAP Number Types) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level (AT FIRST, AT NEW f) and also the end of a control level (AT END OF f, AT LAST).
    At the end of the control level processing (i.e. after ENDAT), the old contents of the LOOP output area are restored.
    Notes
    When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
    If an internal table is processed only in a restricted form (using the additions FROM, TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
    With LOOPs on extracts, there are also special control break control structures you can use.
    Note
    Non-Catchable Exceptions:
    SUM_OVERFLOW: Overflow when calculating totals with SUM.
    Variant 1
    AT NEW f.
    Variant 2
    AT END OF f.
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.See Compatible Work Area with Control Level Processing and Field Symbols Not Allowed as Control Level Criterion.
    Effect
    f is a sub-field of an internal table processed with LOOP. The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before fhas a different value than in the preceding (AT NEW) or subsequent (AT END OF) table line.
    Example
    TYPES: BEGIN OF COMPANIES_TYPE,
            NAME(30),
            PRODUCT(20),
            SALES TYPE I,
          END   OF COMPANIES_TYPE.
    DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
                         NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
          WA_COMPANIES TYPE COMPANIES_TYPE.
    LOOP AT COMPANIES INTO WA_COMPANIES.
      AT NEW NAME.
        NEW-PAGE.
        WRITE / WA_COMPANIES-NAME.
      ENDAT.
      WRITE: / WA_COMPANIES-PRODUCT, WA_COMPANIES-SALES.
      AT END OF NAME.
        SUM.
        WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-SALES.
      ENDAT.
    ENDLOOP.
    The AT statements refer to the field COMPANIES-NAME.
    Notes
    If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name. If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.
    By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.
    A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.
    If you use AT within a LOOP with an explicitly-specified output area, the area must be compatible with the line type of the internal table so that it can be initialized properly (as described above) at the start of a new control level.
    You can restrict control break criteria further, regardless of whether they were defined statically or dynamically, by specifying offset and/or length.
    Variant 3
    AT FIRST.
    Variant 4
    AT LAST.
    Effect
    Executes the appropriate sequence of statements once during the first (AT FIRST) or last (AT LAST) loop pass.
    Example
    TYPES: BEGIN OF COMPANIES_TYPE,
            NAME(30),
            PRODUCT(20),
            SALES TYPE I,
          END   OF COMPANIES_TYPE.
    DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
                         NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
          WA_COMPANIES TYPE COMPANIES_TYPE.
    LOOP AT COMPANIES INTO WA_COMPANIES.
    AT FIRST.
    SUM.
    WRITE: 'Sum of all SALES:',
    55 WA_COMPANIES-SALES.
    ENDAT.
    WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-PRODUCT,
    55 WA_COMPANIES-SALES.
    ENDLOOP.

  • Control break statements

    Hi friends,
           pls explain , what is the use of control break statements( at first, at last, at new, at end of, on change of ) ? and practical difference applying at new and on change.
    Pls send me material or links related to control break statements.
    Thanks in advance.
    SR K

    Hello SR K,
    Just go through the following documentation.
    AT - Control breaks with extracts
                  Variants:
                  1. AT NEW f.
                  2. AT END OF f.
                  3. AT FIRST.
                  4. AT LAST.
                  5. AT fg.
    Effect        In a LOOP which processes a dataset created with EXTRACT, 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 is
                  executed whenever a control break occurs.
                  You can use these key words for control break processing with
                  extract datasets only if the active LOOP statement is
                  processing an extract dataset.
                  The control level structure with extract datasets is dynamic.
                  It corresponds exactly to the sort key of the extract dataset,
                  i.e. to the order of fields in the field group HEADER by which
                  the extract dataset was sorted.
                  At the end of a control group (AT END OF, AT LAST), there are
                  two types of control level information between AT and ENDAT:
                  -  If the sort key of the extract dataset contains a
                     non-numeric field h (particularly in the field group
                     HEADER), the field CNT(h) contains the number of control
                     breaks in the (subordinate) control level h.
                  -  For extracted number fields g (see also ABAP Number Types),
                     the fields SUM(g) contain the relevant control totals.
    Notes         1. The fields CNT(h) and SUM(g) can only be addressed after
                     they have been sorted. Otherwise, a runtime error may
                     occur.
                  2. The fields CNT(h) and SUM(g) are filled with the relevant
                     values for a control level at the end of each control group
                     (AT END OF, AT LAST), not at the beginning (AT FIRST, AT
                     NEW).
                  3. When calculating totals with SUM(g), the system
                     automatically chooses the maximum field sizes so that an
                     overflow occurs only if the absolute value area limits are
                     exceeded.
                  4. You can also use special control break control structures
                     with LOOPs on internal tables.
    Variant 1     AT NEW f.
    Variant 2     AT END OF f.
    Effect        f is a field from the field group HEADER. The enclosed
                  sequence of statements is executed if
                  -  the field f occurs in the sort key of the extract dataset
                     (and thus also in the field group HEADER) and
                  -  the field f or a superior sort criterion has a different
                     value in the current LOOP line than in the preceding (AT
                     NEW) or subsequent (AT END OF) record of the extract
                     dataset.
                  If f is not an assigned field symbol, the control break
                  criterion is ignored, and the subsequent sequence of
                  statements is not executed. If a field symbol is assigned, but
                  does not point to the HEADER field group, the system triggers
                  a runtime error.
    Example
                  DATA: NAME(30),
                        SALES TYPE I.
                  FIELD-GROUPS: HEADER, INFOS.
                  INSERT: NAME  INTO HEADER,
                          SALES INTO INFOS.
                  LOOP.
                    AT NEW NAME.
                      NEW-PAGE.
                    ENDAT.
                    AT END OF NAME.
                      WRITE: / NAME, SUM(SALES).
                    ENDAT.
                  ENDLOOP.
    Notes         1. If the extract dataset is not sorted before processing with
                     LOOP, no control level structure is defined and the
                     statements following AT NEW or AT END OF are not executed.
                  2. Fields which stand at hex zero are ignored by the control
                     break check with AT NEW or AT END OF. This corresponds to
                     the behavior of the SORT statement, which always places
                     unoccupied fields (i.e. fields which stand at hex zero)
                     before all occupied fields when sorting extract datasets,
                     regardless of whether the sort sequence is in ascending or
                     descending order.
    Variant 3     AT FIRST.
    Variant 4     AT LAST.
    Effect        Executes the relevant series of statements just once - either
                  on the first loop pass (with AT FIRST) or on the last loop
                   pass (with AT LAST).
    Variant 5     AT fg.
                   Addition:
                   ... WITH fg1
    Effect        This statement makes single record processing dependent on the
                   type of extracted record.
                   The sequence of statements following AT fg are executed
                   whenever the current LOOP record is created with EXTRACT fg
                   (in other words: when the current record is a fg record).
    Addition      ... WITH fg1
    Effect        Executes the sequence of statements belonging to AT fg WITH
                   fg1 only if the record of the field group fg in the dataset is
                   immediately followed by a record of the field group fg1.
    Reward If Helpful
    Regards
    Sasidhar Reddy Matli.

Maybe you are looking for