Loop break in an Internal table

Hello,
I have an internal table with many vendors and each vendor may have multiple line items. Now if a line item has incorrect data then that vendor shudnt get created and move on to the next vendor..As i show here
v1,12,ea,3444
v1,12,ea,3445
v1,12,ea,3446
v2,12,ea,3448
v2,12,ea,3447
If 3445 is incorrect then I shud move on to next vendor v2..How do i do this in an internal table.
Thanks
Viky

Hi,
You can make use of the AT control statements, something like this:
Loop at itab.
Check if the line item is ok.
IF OK.
  flag = Y.
ELSE.
  CONTINUE.
ENDIF.
AT END OF <vendor>.
check flag = Y.
Send vendor details.
ENDAT.
Endloop.
Hope this helps,
Sumant.

Similar Messages

  • Doubts with control break statements on internal table loops (AT/ENDAT)

    Hi, i've had a couple of doubts for a long while which I hope someone can clarify today:
    1) I know how to use the AT statements, however, i'm not sure I get correctly what this part of help regarding this commands means:
    <i>"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."</i>
    I've always sorted the internal table before the control break and it works that way. For example:
    SORT ITAB BY EBELN EBELP.
    LOOP AT ITAB.
      AT NEW EBELN.
    *   Code for the order header
      ENDAT.
    ENDLOOP.
    If I <b>don't</b> sort the internal table, it doesn't work! (i get dupplicated processing). In the example, if i have more than one register with the same EBELN and they're not consecutive, the header gets processed twice. I really don't get that part of the help text.
    2) I know this: <i>"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."</i>
    My doubt is: WHY is that this way? Because sometimes (most times) I need those fields INSIDE the statement! So when that happened i've solved it in one of three ways:
    LOOP AT ITAB INTO WA_ITAB.
      WA_ITAB_AUX = WA_ITAB.
      AT NEW FIELD.
        WA_ITAB = WA_ITAB_AUX.
    *   ...Rest of the code for the first register
      ENDAT.
    ENDLOOP.
    LOOP AT ITAB INTO WA_ITAB.
      AT NEW FIELD.
        READ TABLE ITAB INDEX SY-TABIX INTO WA_ITAB.
    *   ...Rest of the code for the first register
      ENDAT.
    ENDLOOP.
    * (Without AT)
    LOOP AT ITAB INTO WA_ITAB.
      IF WA_ITAB-FIELD <> FIELD_AUX.
        FIELD_AUX = WA_ITAB_FIELD.
    *   ...Rest of the code for the first register
      ENDIF.
    ENDLOOP.
    Is there any problem with this way of coding? Can be done better?
    Thank you very much in advance.

    Hi..,
    1)
    See if u sort the table on a field on which u r using AT ENDAT .. then all the records which are having the same value for that field will form a group or those reocrds will be at one place.. so when u sort the table for all the records  AT ENDAT  will get executed onli once..
    If u dont sort this table on this field then all these records will be at different places and in between there may be records with different value for this field.. so this AT ENDAT will get executed for each record !!
    2)
    No u cannot use the Right hand fields of the field in the table .. Because these AT events work as Group based operations... So till that field on which AT ENDAT is working it breaks that record into two groups.. One is the left hand fields including that field.. and right hand fields as another group.. and makes the right hand group as stars ****.  Thats y u can observe that even any one field in the left hand group changes the AT ENDAT will get executed  !!!!
    Hope u understood !!!
    regards,
    sai ramesh

  • Loop using index read ( internal table)

    Hi,
    I thought of impelementing loop at ITAB using read statements, Here it goes.
    REPORT Z_LOOP_IMPROVE.
    DATA : T_OUTPUT TYPE STANDARD TABLE OF MARC WITH HEADER LINE,
    L_TABIX TYPE SY-TABIX.
    DEFINE ILOOP.
    DO.
    IF SY-INDEX EQ '1'.
    READ TABLE &1 WITH KEY &2 = &3 BINARY SEARCH.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ELSE.
    L_TABIX = SY-TABIX + 1.
    READ TABLE &1 INDEX L_TABIX.
    IF SY-SUBRC NE 0 OR &1-&2 NE &3.
    EXIT.
    ENDIF.
    ENDIF.
    END-OF-DEFINITION.
    DEFINE IENDLOOP.
    ENDDO.
    END-OF-DEFINITION.
    DATA : T1 TYPE I, T2 TYPE I.
    SELECT * FROM MARC INTO TABLE T_OUTPUT.
    SORT T_OUTPUT BY WERKS.
    GET RUN TIME FIELD T1.
    ILOOP T_OUTPUT WERKS '0001'.
    WRITE : / T_OUTPUT-MATNR, T_OUTPUT-WERKS.
    IENDLOOP.
    GET RUN TIME FIELD T2.
    T2 = T2 - T1.
    WRITE : / T2.
    *C----
    But sadly it takes more time than a normal loop with
    where condition.
    can anyone suggest some ideas to improve execution speed?

    You can use a binary read to get the first record. Then read each record sequentially until you have proccessed all the records that meet your critera. You will have to have the internal table sorted so that the binary search and subsequent reads will work:
          READ TABLE itab WITH KEY
            field = whatever
            BINARY SEARCH.
          IF sy-subrc = 0.
            itab_index = sy-tabix.
            DO.
              IF sy-subrc = 0.
                IF itab_data-field = whatever
                  itab_index = itab_index + 1.
                  READ TABLE itab_data INDEX itab_index.
                ELSE.
                  EXIT.
                ENDIF.
              ELSE.
                EXIT.
              ENDIF.
            ENDDO.
          ENDIF.
    Rob

  • Loop at Conditions within internal table

    I have not been ABAPing long so primarily have been using keyword help...
    I am trying to loop round an itab and only select and process unique keys from within the table!
    However the table I am using to obtain the records has multiple records with the same reference and I am only interested in each unique occurrence of the IBASE_COMPONENT_GUID field.
    So there could be four items for one Appliance and four for another one. So of the eight records, I would only need to loop round and select the unique GUIDS.
    So there would only be two unique appliances I need to extract the records for.
    Basically I am trying to do something like this:
        LOOP AT GT_ITEM_DATA INTO GS_ITEM_DATA WITH UNIQUE KEY IBASE_COMPONENT_GUID.
    Is there a way to select each unique occurrence?

    Basically, I use the COLLECT statement when I need to get the unique field (character only) field from the internal table.
    Create a table with only one field, GUID.
    LOOP through your main table, assign its GUID to new table's field GUID
    Use COLLECT new_table.
    Other option is,
    Sort the table by GUID
    Loop through it and use AT NEW GUID or AT END OF GUID
    Fill out the table with this GUID.
    Regards,
    Naimesh Patel

  • Loop fields in an internal table

    Dear experts,
    I have a scenario where I have an internal table (created in an end routine) c of felds that are both characteristics and key figures. I would like to do is to modify this table so that I keep the value of the charactersitics but I set the value of all the key figures to 0. How can I acomplish this and what is the best way? Is there for example a way to loop all the fields in the work area when I am looping though the internal table and then dependant on the data type, set the key figues = 0?
    Thanks!
    -Cathrin

    Hi Cathrin,
    It will not be possible to set the key figures to zero based on data type.
    You will have to set each key figure in the loop.
    Example:
    LOOP ITAB INTO WA_ITAB.
        WA_ITAB-KEYFIGURE1 = 0.
        WA_ITAB-KEYFIGURE2 = 0.
        MODIFY ITAB FROM WA_ITAB.
    ENDLOOP.
    Regards,
    Hemant Khemani

  • Looping over fields from internal table

    In a FM I have to check records of two ITABs against each other. Most fields can be checked 1:1 but some must be checked according to some business logic.
    I first want to check field-by-field and then I want to deal with exceptions.
    Question: How can I loop over fields in an ITAB in such a manner that I can compare fields?

    Hi, you can loop thru the columns(fields) of an internal table like so.
    field-symbols: <fs>.
    loop at itab.
    do.
    * Here you can use the field name instead of SY-INDEX
       assign component sy-index of structure itab to <fs>.
       if sy-subrc <>.
       exit.
       endif.
    * Now that you have access to the field via field symbol, you can compare
    * this value.
    Write:/ <fs>.
    enddo. 
    endloop.
    Regards,
    Rich Heilman

  • Control break statements in internal tables

    explain the concept of at end of in internal example with siutable example.

    AT END OF f.
    Effect
    f is a sub-field of an internal table or extract dataset (EXTRACT) which is being processed with LOOP, i.e. the variants 1 and 2 only make sense within a LOOP.
    Both "AT NEW f." and "AT END OF f. " introduce processing blocks which are concluded by " ENDAT.".
    These processing blocks are processed whenever the contents of a field f or a sub-field defined before f change as a result of processing with LOOP. "AT NEW f." begins a new group of (table) lines with the same contents as the field f while "AT END OF f." concludes such a group.
    Within the AT ... ENDAT processing of internal tables, all argument fields following f are filled with "*".
    Examples
    1. AT for sub-fields of an internal table
    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.
    Check this , this is Quoted from SAP help.
    Regards
    Vijay

  • Events in internal tables

    what are the events in internal tables...

    Hi
    At new, At first, At end of, At last are called Control break events of internal table
    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.
    <b>
    Reward points for useful Answers</b>
    Regards
    Anji

  • What are the internal table events

    hi experts
    can u help me for this

    Hi ramesh,
    There are basically internal table events are as below...
    at first / endat
    at last / endat
    at new / endat
    at end of / endat
    sum
    on change of / endon
    Use the at first and at last statements to perform processing during the first or last loop pass of an internal table.
    Use the at new and at end of statements to detect a change in a column from one loop pass to the next. These statements enable you to execute code at the beginning and end of a group of records.
    Use the sum statement to calculate totals for the rows of a control level.
    Another statement you can use to perform control break processing is on change of. It behaves in a manner similar to at new.
    on change of differs from at new in the following respects:
    It can be used in any loop construct, not just loop at. For example, it can be used within select and endselect, do and enddo, or while and endwhile, as well as inside get events.
    A single on change of can be triggered by a change within one or more fields named after of and separated by or. These fields can be elementary fields or field strings. If you are within a loop, these fields do not have to belong to the loop.
    When used within a loop, a change in a field to the left of the control level does not trigger a control break.
    When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
    You can use else between on change of and endon.
    You can use it with loop at it where . . ..
    You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
    Any values changed within on change of remain changed after endon. The contents of the header line are not restored as they are for at and endat.
    <b>Reward Points if it useful....</b>
    Thanks and Regards
    Sreenivasa sharma k.

  • Reading the data from field symbol internal table //

    Hi,
    There are 2 internal tables defined as Fieldsymbols (type any) and I need to retrive data from second internal table based on a field value in first internal table.
    Let's assue the name internal table 1 is <it_itab1>, 2nd internal table name is <it_itab2> and the work areas are <wa_itab1> and <wa_itab2>.
    The existing logic :
    LOOP at <it_itab1> ASSIGNING <wa_itab1>.
      ASSIGN COMPONENT 'XYZ' OF STRUCTURE <wa_itab1> TO l_field6.
      LOOP AT <it_itab2> ASSIGNING <wa_itab2>.
        ASSIGN COMPONENT 'XYZ' OF STRUCTURE <wa_itab2> TO <p_field7>.
        IF <p_field7> = l_field6.
    do the required business.
        ELSE.
          *     do the required business.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
    The requirement of reading second internal table was achieved by putting loop on the internal table but its giving considerable effect on performance !!
    Is there any way to use READ statement in my case OR any way of putting WHERE condition on loop statement of second internal table ??
    Thank you !!

    Use the below Logic.
    Loop at Itab1 into wa_itab1.
        Loop at itab2 into wa_itab2 where p_field7 = wa_itab1-xyz or I_field6.
    do the required business.
        endloop.
        Loop at itab2 into wa_itab2 where p_field7 <> wa_itab1-xyz or I_field6.
    do the required business.
        endloop.
    endloop.
    Hope it is useful...

  • Insert into internal table

    Hi Experts,
    I am new comer to ABAP, have some very important task to be done, need help from all of you. I have a program which displays the results(inform about the infocubes). I want to insert the output of this prgm into an internal table, I am looking lot into the documentation, but so far not much help and i am not able to execute it. And one more task, I want to join this internal table and one database table and get the result, my question is , Is it possible to join this internal table and database table based on some common field.
      Any help will be of grt help
    Thanks,
    Hem.

    Hi,
    For joining internal table with database table,you need to write the logic as below.
    This is the pseudo code.
    select * from database into table itab2 where condition.
    loop at itab1 into wa1.
       move-corresponding wa1 to wa3.
       loop at itab2 into wa2 where field = wa1-field.
        move-corresponding wa2 to wa3.
       endloop.
       append wa3 to itab3.
    endloop.
    1. select the required data from database table into internal table.
    2. loop the first internal table which you already have.
    3. Based on the key fields in these two internal tables[database],place the condition in READ or LOOP statement for the second internal table inside the loop of the first internal table.
    4. If there are more records in second internal table for a single record in first internal table,then use LOOP the second internal table within the first internal table.Otherwise, read the second internal table within the first internal table.
    5.Then move the corresponding fields from both the internal tables inside the loop to third internal table.Append the record to the third internal table.
    Hope it helps.
    Regards,
    J.Jayanthi

  • Delete row from internal table using field symbol.

    Hi friends,
      I created dynamic internal table using field symbol. I want to delete some data using where clause.
    for example. i want to use like,
        DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
    Like the above statment it won't work. How i can use delete with where clause in field symbols.
    Hope any one can help me.
    Thanks and regards
    Srikanth. S

    hi Srikanth,
    I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
    LOOP at <itab> INTO <wa>.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
    CHECK <field> IS ASSIGNED.
    IF <field> EQ WA_KNA1-KUNNR.
    DELETE ...
    ENDIF.
    UNASSIGN <field>.
    ENDLOOP.
    hope this helps
    ec

  • Work area and internal table

    hi friends,
    Please let me know when do we use work area and when do we use internal table.
    Thanks in advance
    Tina Wilson

    Work areas are used with internal tables.  For example if you have an internal table defined like this.
    data: itab type table of mara.
    This internal table can hold many rows of data, right?  SO say you need to read this data.  Well you will need to LOOP or READ the internal table, since this internal table has no header line(please to put the read data), you need to have a work area to put the data into.
    <b>data: wa like line of itab.</b>
    Loop at itab <b>into wa</b>.
    endloop.
    Now if you defined the internal table with a header line, there is no reason to have the work area and you can just do the same like this.
    data: itab type table of mara <b>with header line</b>.
    Loop at itab.
    endloop.
    It is now best practice to use work areas instead of header lines because in ABAP OO, header lines are not allowed.
    Regards,
    Rich Heilman

  • Modify internal table embedded in internal table as field

    Hi Experts,
    I am using function module CRM_DNO_READ_ORDER_TEXT.
    One of the output table of this fm is  ET_ALLTEXTS whixh is of structure COMT_TEXT_TEXTDATA_T.
    This structure has two fields one is GUI and other is LINES which itself contains the table in it.
    I want to delete one row from the data of this LINES table in main table ET_ALLTEXTS .
    Actually, this LINES table contains the texts entered by user from some application. So i want to edit the text.
    Pls help me..this is very complicated.
    thnx
    DIvya

    I guess Nilesh is right, there is something wrong with your declaration. Me for one, I've tried to reproduce your problem and I don't see any problem here. How did you declare your internal table for example?
    When you want to delete a line from table LINES you can't just say:
    delete et_alltexts-lines index 1.
    Because this will give you the error message with 'table without header line....". Instead you first have to loop at this ET_ALLTEXTS internal table and only then you have access to the individual lines, which is an internal table as well. The following is only an example, but it should be helpful:
    DATA: gv_header_guid TYPE crmt_object_guid.
    DATA: gt_textdata    TYPE comt_text_textdata_t ,
          gt_alltexts    TYPE comt_text_textdata_t.
    FIELD-SYMBOLS: <alltext>     LIKE LINE OF gt_alltexts.
    CALL FUNCTION 'CRM_DNO_READ_ORDER_TEXT'
      EXPORTING
        iv_header_guid = gv_header_guid
      IMPORTING
        et_textdata    = gt_textdata
        et_alltexts    = gt_alltexts.
    LOOP AT gt_alltexts ASSIGNING <alltext>.
      DELETE <alltext>-lines INDEX 1.
    ENDLOOP.

  • Populating dynamic internal table with data

    Hi,
    I have an internal table with the data like the below
          profit  lineId  amount
          center
           s21     70     1000
           s21     80     1200
           s22     70      800
    In the above internal table the number of distinct lineIDs will be vary based on selection-screen creiteria.
    So for this I build a fieldcatalog and dynamic internal table like the following
    The data available in the above internal table should be placed into the dynamic internal table like the following.
         profit
         center  LineID70 LineID80 .....etc
          S21      1000     1200
          S22       800
    Can any one suggest how to proceed?
    Thanks in advance
    Nanda.

    Hi
    This is my first ever reply so I hope this works or gives you some ideas.
    DATA: l_idcount TYPE i,
                l_idvalue LIKE itab2-amount.
    *loop through the source internal table
    LOOP AT itab1.
    * increment count of id numbers in current profit center
      l_idcount = l_idcount + 1. 
    * run through the amount fields in target internal table
      DO ID_number TIMES VARYING l_idvalue
          FROM itab2-LineID70 NEXT itab2-LineID80.
        IF sy-index EQ l_idcount.
    *   change field value if id count same as field position
          l_idvalue = itab1-amount.
        ENDIF.
      ENDDO.
      AT END OF profit_center.
        itab2-profit_center = itab1-profit_center.
        APPEND itab2.
        CLEAR l_idcount.
      ENDAT.
    ENDLOOP.
    ID_number is the number of ids as a result of selection-screen criteria.

Maybe you are looking for

  • Different page formats in single Smartform

    Hello Experts, I have an requirement in my custom Smartforms. I want my first page as by default DINA4 page in where as from second onwards, I want DINA3 page format. Could it be possible? If yes, how I can achieve this? Thanks in advance.

  • Sound Distortion AP 11 and 12.

    I'm experiencing sound distortion and weak signal after AP upgraded to 11. I downloaded 12 and I still have the problem. Windows 7.

  • Can't download Safari because Windows Installer can't be accessed

    Any help would be appreciated as to why by computer can't access Windows Installer? Thanks

  • Move metadata storage?Syncronizing?

    Some questions on metadata: 1. As I experimented with Beta 4 I seem to have adjusted some files with both Bridge/CS2 and Lightroom. What adjustments will Lightroom 1.0 use? Can I choose? 2. My photos are all converted to DNG. In preferences I did not

  • CTS + Doubts

    Hi, IM planning to implement CTS+ as ECC & EP are component in my LAndscape. What's diff (Advantage /Disadvantage ) between Old CTS & CTS + ? Is same concept followed  for AS ABAP (ECC) system as old CTS? how can i call Transport Organizer Web UI (th