Logic- SUMMING UP -Control Break

Hi,
In the following code if value of the field (T_DATA-JUHGSBEST) is '999'. I don't want to consider while summing up .
How can we achieve this? Right now If I code like this..It is lready calculating the SUM.
SORT T_DATA BY MATNR SPTAG.
LOOP AT T_DATA.
    MOVE T_DATA TO WA_DATA.
      AT END OF MATNR.
        SUM.
        T_OUTPUT-MATNR = WA_DATA-MATNR .
        T_OUTPUT-MGVBR = T_DATA-MGVBR.
        T_OUTPUT-WGVBR = T_DATA-WGVBR.
        IF T_DATA-JUHGSBEST NE '999'.
        T_OUTPUT-JUHGSBEST = T_DATA-JUHGSBEST.
        ENDIF.
        APPEND T_OUTPUT.
        CLEAR T_OUTPUT.
        CLEAR : WA_DATA.
      ENDAT.
  ENDLOOP.
Regards
Vara
Message was edited by:
        Vara K

Hi,
         Try this code ...
DATA : TEMP_DATA  LIKE  T_DATA  OCCURS 0 WITH HEADER LINE.
TEMP_DATA[] = T_DATA[].
DELETE T_DATA WHERE JUHGSBEST EQ '999'.
SORT T_DATA BY MATNR SPTAG.
LOOP AT T_DATA.
MOVE T_DATA TO WA_DATA.
AT END OF MATNR.
SUM.
T_OUTPUT-MATNR = WA_DATA-MATNR .
T_OUTPUT-MGVBR = T_DATA-MGVBR.
T_OUTPUT-WGVBR = T_DATA-WGVBR.
IF T_DATA-JUHGSBEST NE '999'.
T_OUTPUT-JUHGSBEST = T_DATA-JUHGSBEST.
ENDIF.
APPEND T_OUTPUT.
CLEAR T_OUTPUT.
CLEAR : WA_DATA.
ENDAT.
ENDLOOP.
Regards,
Vind.

Similar Messages

  • How to catch the value in sum(control break statement).

    hi,
    can any one tell me how to catch the value in sum in control break satament.
    ex.
    at end of brtwr.
    sum.
    endat.
    I need to print the value in sum only.
    I tried to declare a varaible of type i and assigned sum to this variable.
    it is giving syntax error that sum is not identified.
    How should i do this.
    regards.

    Hi Siva,
    In control break statement when we use SUM. it added all the amount fields and stores its in the work area of that field.
    look below code.
    DATA : BEGIN OF itab OCCURS 0,
               name(10),
               num TYPE i,
           END OF itab.
    DATA : num TYPE i .
    itab-name = 'salman'.
    itab-num  = 100.
    APPEND itab.
    itab-name = 'salman'.
    itab-num  = 200.
    APPEND itab.
    itab-name = 'akshay'.
    itab-num  = 500.
    APPEND itab.
    LOOP AT itab.
      AT END OF name.
        SUM.
        WRITE : / itab-num.
      ENDAT.
    ENDLOOP.
    here the SUM value is stored in Workarea,
    the output will be 300 & 500.
    regards
    Kumar M

  • Control break logic

    Hi All,
    I have the following code written.
      SORT i_dberdl BY mwskz.
      LOOP AT i_erdk INTO wa_erdk.
        LOOP AT i_dberdl INTO wa_dberdl WHERE printdoc = wa_erdk-opbel.
          AT END OF mwskz.
            flg_end = c_x.
          ENDAT.
          lwa_nettobtr = lwa_nettobtr + wa_dberdl-nettobtr.
          IF flg_end = c_x.
            wa_vat2-mwskz = wa_dberdl-mwskz.
            wa_vat2-opbel = wa_dberdl-printdoc.
            wa_vat2-nettobtr = lwa_nettobtr.
            APPEND wa_vat2 TO i_vat2.
            CLEAR :lwa_nettobtr,wa_vat2, flg_end.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    for each document number(opbel) in i_dberdl,i need to sum up the nettobtr value having sinilar taxcode(mwskz).tha above logic is giving wrong result.
    Please let me know what is wrong in this.
    Rgds,
    Sai

    Sai,
    please use the SDN search option before throwing the thread i gave control break statement  i got my answer.
    Amit.

  • Sum of the sql query after a control break

    Hi all,
    I need some help about getting the final sum of the sql query after doing a control break in a dynamic report, ( the control break make me the sum of each report but didn't leave me the sum of all the query)
    Thanks in andvance for your help !!
    Eric

    Have a look at the text_io package:
    http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=f1_help/oraini/c_text_io.html&vtTopicId=
    cheers

  • Control break-statement: SUM

    Hi All,
    I am woking with Control break-statmens, SUM.
    LOOP AT IT_SELECT.
    AT NEW PSPNR.
    SUM.
    WRITE:/ IT_SELECT-WERKS,
            IT_SELECT-PSPHI,
            IT_SELECT-PSPNR,
            IT_SELECT-VERNA,
            IT_SELECT-KZWI2,
            IT_SELECT-DMBTR.
    ENDAT.
    ENDLOOP.
    WERKS from EKPO type Char & VERNA from PRPS type Char are displaying as ***************.
    How can I get the actual values instead of ********** for the above Char type fields?
    Thanks in advance,
    Kal Chand

    Hi,
    Go throught his link. This is same for all control break statements.
    Re: output not getting properly
    Hope this helps you
    Raj

  • Control break urgent

    difference between on change and at first.
    in which scenario which control break statement
    we have to use

    Hi Sunil!!
    ON CHANGE OF f.
    Addition:
    ... OR f1
    This statement is not allowed in an ABAP Objects context. See Prohibit ON CHANGE OF - ENDON.
    Effect
    Executes the processing block enclosed by the "ON CHANGE OF f" and "ENDON" statements whenever the contents of the field f change (control break processing).
    Normally, you use the statement to manipulate database fields during GET events or SELECT/ENDSELECT processing.
    Note
    There are special control structures for processing control breaks in LOOP s on internal tables or extract datasets (AT).
    ON CHANGE OF is unsuitable for recognizing control levels in loops of this type because it always creates a global auxiliary field which is used to check for changes. This global auxiliary field is only changed in the relevant ON CHANGE OF statement. It is not reset when the processing enters loops or subroutines, so unwanted effects can occur if the loop or subroutine is executed again. Also, since it is set to its initial value when created (like any other field), any ON CHANGE OF processing will be executed after the first test, unless the contents of the field concerned happen to be identical to the initial value.
    Example
    DATA T100_WA TYPE T100.
    SELECT * FROM T100
             INTO T100_WA
             WHERE SPRSL = SY-LANGU AND
                             MSGNR < '010'
                       ORDER BY PRIMARY KEY.
      ON CHANGE OF T100_WA-ARBGB.
        ULINE.
        WRITE: / '**', T100_WA-ARBGB, '**'.
      ENDON.
      WRITE: / T100_WA-MSGNR, T100_WA-TEXT.
    ENDSELECT.
    Displays all messages with their numbers in the logon language, provided the number is less than '010'.
    Each time the message class changes, it is output.
    Addition
    ... OR f1
    Effect
    Also executes the code whenever the contents of the field f1 changes.
    You can use this addition several times.
    Example
    Logical database F1S
    NODES: SPFLI, SFLIGHT, SBOOK.
    GET SBOOK.
      ON CHANGE OF SPFLI-CARRID   OR
                   SPFLI-CONNID   OR
                   SFLIGHT-FLDATE.
        ULINE.
        WRITE: /5 SPFLI-CARRID, SPFLI-CONNID,
                5 SFLIGHT-FLDATE, SPFLI-FLTIME,
                5 SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC.
      ENDON.
      WRITE: / SBOOK-CUSTOMID.
    The code between ON CHANGE OF and ENDON is executed only if at least one of the fields SPFLI-CARRID, SPFLI-CONNID or SFLIGHT-FLDATE has changed, i.e. there is a different flight connection (which also has bookings).
    Notes
    Between ON CHANGE OF and ENDON, you can use ELSE for case distinction.
    You can also use ELSEIF statements in conjunction with special implementation of ON, but should always try to avoid this because they may not be supported in future.
    Related
    AT - control breaks with internal tables
    AT - control breaks with extracts
    AT FIRST.
    Effect
    The variants AT FIRST make sense within a LOOP.
    The processing block between AT FIRST and ENDAT is executed before the individual lines are processed; the processing block between AT LAST and ENDAT is executed after all the individual lines have been processed.
    In AT FIRST or AT LAST ... ENDAT processing, all argument fields are filled with "*" (internal tables).
    When you are processing extract datasets, a control total SUM(n) can only be processed with AT END OF or AT LAST.
    Example
    DATA: BEGIN OF COMPANIES OCCURS 20,
            NAME(30),
            PRODUCT(20),
            SALES TYPE I,
          END   OF COMPANIES.
    LOOP AT COMPANIES.
      AT FIRST.
        SUM.
        WRITE:    'Sum of all SALES:',
               55 COMPANIES-SALES.
      ENDAT.
      WRITE: / COMPANIES-NAME, COMPANIES-PRODUCT,
            55 COMPANIES-SALES.
    ENDLOOP.
    kindly reward if useful

  • ANY SY-INDEX REFLECT CHANGES WHEN CONTROL BREAK STATEMENT PROCESS

    Dear Guru's,
                     I have a requirement where i have to move the values to variable when control break (AT END OF) process. So i want to move the values according to the end of Vendor so for that  i want to know is there any sy-index available which reflects changes when Control break (AT end of) process.
    LIKE Sy-subrc = 0 when select statement fetches record or sy-tabix is like counter for loop.
    Hope to get reply soon.
    Regards,
    Himanshu Rangappa

    Hi,
    There is no system Fields for it.
    But your requirement can be done with 'AT NEW' and 'AT END' statement.
    Refer this sample example,
    loop at otab.
        at new module.
          move otab-module to otab2-module.
        ENDAT.
          at END OF effort.
          sum.               "Do your calculations here
          move otab-count to otab2-count.
          append otab2.
        endat.
      endloop.

  • 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

  • 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.

  • Want to know more details about control breaks in reports

    hello all
    i want to know more details about control breaks AT First,
                                                                          AT Last,
                                                                          AT New,
                                                                          At End of and on change .
    can anybody tell with examples?

    Hi Swamy,
       Check the following.
    Control break statements are used to create statement blocks which process only specific table lines the LOOP – ENDLOOP block.
    You open such a statement block with the control level statement AT and close it with the control level statement ENDAT. The syntax is as follows:
    Table should be sorted when you use control-break statements
    You can break the sequential access of internal tables by using these statements.
    Syntax:
    At first.
    <Statement block>
    Endat.
    This is the first statement to get executed inside the loop (remember control break statements are applicable only inside the loop)
    So in this block you can write or process those statements which you want to get executed when the loop starts.
    At New carrid.
    Write:/ carrid.
    Endat.
    In this case whenever the new carrid is reached, carrid will be written.
    At End of carrid.
    Uline.
    Endat.
    In this case whenever the end of carrid is reached, a line will be drawn.
    At Last.
    Write:/ ‘Last Record is reached’.
    Endat.
    Processing of statements within this block is done when entire processing of entire internal table is over. Usually used to display grand totals.
    You can use either all or one of the above control break statements with in the loop for processing internal table.
    At end of carrid.
    Sum.
    Endat.
    In above case the statement SUM (applicable only within AT-ENDAT) will sum up all the numeric fields in internal table and result is stored in same internal table variable.
    Hope this helps you.
    Any queries, get back to me.
    Regards,
    Chandra Sekhar

  • 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.

  • Control break statements in Scripts

    Hi All
    Please help me.
    What are the control break statements are possible in SAP Scripts for Main Window.
    Regards
    Praveen

    This gives over view of almost all control commands.
    ADDRESS               Formatting of addresses
    BOTTOM, ENDBOTTOM     Define footer text in a window
    BOX, POSITION, SIZE   Boxes, lines and shading
    CASE, ENDCASE         Case distinction
    DEFINE                Value assignment to text symbols
    HEX, ENDHEX           Hexadecimal values
    IF, ENDIF             Conditional text output
    INCLUDE               Include other texts
    NEW-PAGE              Explicit forms feed
    NEW-WINDOW            Next window MAIN
    PRINT-CONTROL         Insert print control character
    PROTECT, ENDPROTECT   Protect from page break
    RESET                 Initialize outline paragraphs
    SET COUNTRY           Country-specific formatting
    SET DATE MASK         Formatting of date fields
    SET SIGN              Position of +/- sign
    SET TIME MASK         Formatting of time fields
    STYLE                 Change style
    SUMMING               Summing variables
    TOP                   Set header text in window MAIN

  • Control Break in normal report regions

    Can I somehow insert kind of a control break for normal report regions?
    I use it within serveral interactive reports. Now I have a normal report region displaying projects of all department. The users want to have them grouped with a sum by department, which would be easy to do within an interactive report using a control break.
    But how can I do this in a normal report region?
    BR & thank you,
    Lena
    Edited by: Lena F on Mar 30, 2011 6:04 AM
    --> already found the solution - sorry :-(
    Edited by: Lena F on Mar 30, 2011 6:18 AM

    Please post solution

  • Control Break Statements ----- Please Help me

    I have some idea about the control-break statements(AT-ENDAT). Can any one please give me the example ?
    Thanks in Advance. Points will be rewarded immediately.

    sample program for AT events
    Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
    DATA: BEGIN OF ITAB OCCURS 0,
    F1 TYPE I,
    F2(6) TYPE C,
    F3(10) TYPE N,
    F4(16) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: SUB_TOT(10) TYPE P DECIMALS 3.
    **--1
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 30.
    ITAB-F4 = '3000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    *--2
    ITAB-F1 = 2.
    ITAB-F2 = 'TWO'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 2.
    ITAB-F2 = 'TWO'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 3.
    ITAB-F2 = 'THREE'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 3.
    ITAB-F2 = 'THREE'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    SORT ITAB BY F1.
    LOOP AT ITAB.
    AT FIRST.
    WRITE: /35 ' MATERIAL DETAILS:'.
    ULINE.
    ENDAT.
    AT NEW F1.
    WRITE: / 'DETAILS OF MATERIAL:' COLOR 7 , ITAB-F1.
    ULINE.
    ENDAT.
    WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
    SUB_TOT = SUB_TOT + ITAB-F4.
    AT END OF F1.
    ULINE.
    WRITE: / 'SUB TOTAL :' COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
    CLEAR SUB_TOT.
    ENDAT.
    AT LAST.
    SUM.
    ULINE.
    WRITE: 'SUM:', ITAB-F4.
    ULINE.
    ENDAT.
    ENDLOOP.
    Reward points if helpful.
    Rgds,
    Abhishek

  • Control break stmts

    Can anyone explain the concepts of Control break statements
    Give me a small simple sample program..

    Hi ,
    Check in 21 days of ABAP book or in abap docu.
    Control break statements are used to stop the control at a particular point.
    1. AT NEW f.
    2. AT END OF f.
    3. AT FIRST.
    4. AT LAST.
    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 them is then executed if a control break occurs.
    You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing 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 start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:
    All default key 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 number fields (see also ABAP/4 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 LOOP s on extracts, there are also special control break control structures you can use.
    Note
    Runtime errors
    SUM_OVERFLOW : Overflow when calculating totals with SUM .
    Variant 1
    AT NEW f.
    Variant 2
    AT END OF f.
    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 f has a differnt value than in the preceding ( AT NEW ) or subsequent ( AT END OF ) table line.
    Example
    DATA: BEGIN OF COMPANIES OCCURS 20,
    NAME(30),
    PRODUCT(20),
    SALES TYPE I,
    END OF COMPANIES.
    LOOP AT COMPANIES.
    AT NEW NAME.
    NEW-PAGE.
    WRITE / COMPANIES-NAME.
    ENDAT.
    WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.
    AT END OF NAME.
    SUM.
    WRITE: / COMPANIES-NAME, 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.
    Note
    Runtime errors
    AT_BAD_PARTIAL_FIELD_ACCESS : Invalid sub-field access when dynamically specifying the control break criterion.
    AT_ITAB_FIELD_INVALID : When dynamically specifying the control break criterion via a field symbol, the field symbol does not point to the LOOP output area.
    ITAB_ILLEGAL_COMPONENT : When dynamically specifying the control break criterion via (name) the field name does not contain a valid sub-field name.
    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
    DATA: BEGIN OF COMPANIES OCCURS 20,
    NAME(30),
    PRODUCT(20),
    SALES TYPE I,
    END OF COMPANIES.
    LOOP AT COMPANIES.
    AT FIRST.
    SUM.
    WRITE: 'Sum of all SALES:',
    55 COMPANIES-SALES.
    ENDAT.
    WRITE: / COMPANIES-NAME, COMPANIES-PRODUCT,
    55 COMPANIES-SALES.
    ENDLOOP.
    ON CHANGE OF and AT NEW are same and we don't use On change of now.
    All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table
    FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.
    Some time you will get * when mopving data from this int table to other table using these commands
    so you have to use
    READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them
    DATA: sflight_tab TYPE SORTED TABLE OF sflight
    WITH UNIQUE KEY carrid connid fldate,
    sflight_wa LIKE LINE OF sflight_tab.
    SELECT *
    FROM sflight
    INTO TABLE sflight_tab.
    LOOP AT sflight_tab INTO sflight_wa.
    AT NEW connid.
    WRITE: / sflight_wa-carrid,
    sflight_wa-connid.
    ULINE.
    ENDAT.
    WRITE: / sflight_wa-fldate,
    sflight_wa-seatsocc.
    AT END OF connid.
    SUM.
    ULINE.
    WRITE: / 'Sum',
    sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
    SKIP.
    ENDAT.
    AT END OF carrid.
    SUM.
    ULINE.
    WRITE: / 'Carrier Sum',
    sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
    NEW-PAGE.
    ENDAT.
    AT LAST.
    SUM.
    WRITE: / 'Overall Sum',
    sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
    ENDAT.
    ENDLOOP.
    regards,
    Prabhu
    Reward if it is helpful

Maybe you are looking for

  • Data Services EnglishNorthAmerica_DataCleanse - dictionary person_firm_en

    We're trying to use the EnglishNorthAmerica_DataCleanse.  Symptons are: Dictionary table DC_DICTIONARY is empty No output fields show up in the DataCleanse transform. Validation complains about a missing dictionary, person_firm_en How do we get and i

  • Unable to Adjust Sub Menu

    Hi, I am unable to 'permanently' adjust my sub menu on any of the x,y,z axis to align it to my preference. After moving it to my liking, when I click away from the menu it snaps back to original position?! Another guy back in april 2012 had this issu

  • Labview Calling DLL with 2D array input and output

    Hi all,     I have to call  a dll which a 2D double array as an input and also a 2D double array as an output.The dll is made by me and written in c language , I need it to work  efficiently. If i define the program in labview like this The 2 2Darray

  • Kernel Panics when booted to external FW using 10.4.8

    Using 10.4.7 things worked fine whether I booted on internal drive or external LaCie D2 FW I upgraded to 10.4.8 on the PB G4 15", a PB G4 12" and an external LaCie 2D 3-port firewire The PB 15" and the PB 12" work fine, read/write, etc and backed up

  • Sudden, repeated, unavoidable crashes in certain programs...

    Hi everyone, I use a certain set of chemical drawing tools for my job on a daily basis. Recently a new version of this software suite was released, and promised to fix a number of issues. I installed the new suite along side my older versions - Somet