Decrease sy-tabix value in Loop

Hi Experts,
I need to know that is it possible that we can decrease or change value of SY-TABIX.
EXAMPLE:
I am using a;
loop at itab.  --> at this stage sy-tabix is 1.
for instance current value of sy-tabix is changed to 4 and now I want to make it 3.
in this case I want to read the 3 value in loop again.
So is it possible that I can change my SY-TABIX value from 4 to 3 and read that 3rd record in the loop?
endloop.
can anyone let me know.
thanks in advance.
Regards,
Yahya

Hi
this is not possible directly to change the values of system variables
but the other way is there
what you can do is to move the valuw of sy-tabix in a variable and then loop through the table to that value,
like:
lv_tabix like sy-tabix.
loop at itab into wa where sy-tabix = lv_tabix.
after loop statement.
lv-tabix = sy-tabix.
you code............
before enloop .
lv_tabix = sy-tabix - 1.
endloop.
I am not sure about the above code but you can try something like above.
Thanks
Lalit

Similar Messages

  • SY-TABIX value of a loop in other loop in other loop.

    Hello Gurus,
    I have a problem i want to modify some columns in final internal table and it is possible by using Transporting and Index but when i see SY-TABIX value it is not really giving particular loop iteration value. Because my present loop is in another loop and it is in another loop. Please gurus help me out
    or
    How to Insert particular filed columns  and how to use where clause in insert..
    Thanks.

    Hi !
    Here are things you could do:
    1. You can use nested loops with the WHERE statement on the inner loop. But this can be slow.
         This will look like this
                   loop at i_tab1 into wa1
                   loop at i_tab2 into wa2 where cond1 = wa1-cond1....
                     (   move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                   endloop.
                   endloop.
    2. You can use the parallel cursor technique as suggested above.
         This technique speeds up processing of data significantly. Here it is:
         data lv_tabix type i.
              sort i_tab1 by field1 ascending.
              sort i_tab2 by field1 ascending.
              loop at i_tab1 into wa1
              read table i_tab2 transporting no fields with key cond1 = wa1-cond1 binary search.
              lv_tabix = sy-tabix.
                   loop at i_tab2 into wa2 from lv_tabix.
                        if wa2-cond1 <> wa1-cond1.
                                   exit.       
                         endif.
                   ( move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                    endloop.
              endloop.
    Please let me know if you want more explanation

  • Sy-tabix value has changed...

    Hi Gurus,
    I  am using a code like dis...this is not the actual code m using instad m sendin u a sample program so that u can understand the problem
    There is a selecvtion for Customer.
    sort itab by kunnr.
    loop at itab.
    on change of itab-kunnr.
    wkunnr = itab-kunnr.
      read table zitab with key kunnr = itab-kunnr.
    endon.
    if itab-kunnr = wkunnr.
    wdmbtr = wdmbtr + itab-dmbtr.
    endif.
    at end of kunnr.
    ftab-kunnr = wkunnr.
    ftab-dmbtr = wdmbtr.
    append ftab.
    endat.
    endloop.
    Now my problem is that  AT END OF Kunnr is working fine for the first customer or say for single customer but when there are multiple customers  AT END OF kunnr is triggring for each entry.......
    In debug MOdei can see that as soon as read table  syntax is used the tabix value is changed....
    So Can anyone suggest what is the solution....
    Regards,
    Raman

    This is the Declaration
    DATA:  BEGIN OF ITAB OCCURS 0,
                      KUNNR      LIKE BSID-KUNNR,
                      BELNR      LIKE BSID-BELNR,
                      BUKRS      LIKE BSID-BUKRS,
                      GJAHR      LIKE BSID-GJAHR,
                      BUZEI      LIKE BSID-BUZEI,
                      SHKZG      LIKE BSID-SHKZG,
                      VALUT      LIKE BSID-ZFBDT,
                      SGTXT(70)  TYPE  C,
                      ZFBDT      LIKE BSID-ZFBDT,
                      ZBD1T       TYPE BSID-ZBD1T,
           ZBD2T       TYPE BSID-ZBD2T,
           ZBD3T       TYPE BSID-ZBD3T,
           REBZG       TYPE BSID-REBZG,
           NETDT       TYPE BSID-BUDAT,
                      ZUONR      LIKE BSID-ZUONR,
                       BLART      LIKE BSID-BLART,
                      DMBTR      LIKE BSID-DMBTR,
                      SPART       TYPE VBRK-SPART,
                      DAY    TYPE RFPOSX-VERZN,
                      FLAG TYPE C,
                      CITY        TYPE KNA1-ORT01,
           NAME1       TYPE LFA1-NAME1,
                     CR_DR1(4)  TYPE C,
                      PSWSL      LIKE BSID-PSWSL,
                      ZTERM      LIKE BSID-ZTERM,
                      VBELN      LIKE BSID-VBELN,
                      UMSKZ      LIKE BSID-UMSKZ,
                      KLIMK      LIKE KNKK-KLIMK,
                      VTEXT      LIKE TVZBT-VTEXT,
                      ADV        LIKE BSID-DMBTR,
                      REBZT       TYPE BSID-REBZT,
                      XBLNR      LIKE BSID-XBLNR,
                      VTEXT1(70) TYPE  C,
                       FKLIMK    LIKE KNKK-KLIMK,
                      ABC(4)     TYPE C,
                    AGRO(4)        TYPE C,
                      BIO(4)        TYPE C,
                      SKFOR      LIKE KNKK-SKFOR,
                      SSOBL      LIKE KNKK-SSOBL,
                      CTLPC      LIKE KNKK-CTLPC,
                      OEIKW      LIKE S066-OEIKW,
                      OLIKW      LIKE S067-OLIKW,
                      OFAKW      LIKE S067-OFAKW,
                     NAME1      LIKE LFA1-NAME1,
                      BUDAT      LIKE BKPF-BUDAT,
                      D_DMBTR    LIKE BSID-DMBTR,
                      S_DMBTR    LIKE BSID-DMBTR,
                      VORGN      LIKE BSEG-VORGN,
                      WERKS      LIKE BSEG-WERKS,
                      NAMESO     LIKE KNA1-NAME1,
                      NAMEAM     LIKE KNA1-NAME1,
                      NAMERM     LIKE KNA1-NAME1,
                       NAMEDR     LIKE KNA1-NAME1,
       END OF ITAB.

  • Outputting sy-tabix value in serial number.

    Dear expert,
    I have all the data stored in the internal table. I need to output it in the same serial number as it is in internal table along with the serial number (sy-tabix value) against this internal table data in report output display.
    Thanks in advance.

    Hi,
    Loop at itab.
    Itab-serialnum = sy-tabix.
    Modify Itab.
    endlloop.
    Naxt call alv display by passing the serial num filed catalog.
    Prabhudas

  • Problem in Sy-tabix value

    Hi Experts,
    I have a scenario like this
    Itab1
    A      | B | C
    1050 | 10  | 88
    1051 | 20  | 99
    itab2
    A      | D
    1050 | 1
    1050 | 2
    1050 | 3
    1051 | 4
    1051 | 5
    now I want to combine these values in itab3
    my reslut should be
    A     |  B  | C | D
    1050  10   88  1
    1050  10   88  2
    1050  10   88  3
    1051  20   99  4
    1051  20   99  5
    i did code like this
        LOOP AT i_tab1 INTO w_tab1.
          CLEAR w_tab3.
        w_tab3-A = itab1-A.
        w_tab3-B = itab1-B.
         w_tab3-C = itab1-C.
        APPEND w_tab3 TO i_tab3.
          loop at i_tab2 INTO w_tab2 where A = w_tab2-A.
          IF sy-tabix EQ 1.
             w_tab3-D = w_tab2-D.
             MODIFY i_tab3 INDEX sy-tabix FROM w_tab3 TRANSPORTING D.
          else.
             w_tab3-A = itab1-A.
            w_tab3-B = itab1-B.
            w_tab3-C = itab1-C.
          w_tab3-D = itab2-D.
            APPEND w_tab3 TO i_tab3
           ENDIF.
           CLEAR w_vttp.
           CLEAR w_vttk_tknum.
         endloop.
       ENDLOOP.
    ENDIF.
    Probelm:
    When I am pocessing 2 record of itab1, the value of sy-tabix for in internal table i_tab2 is not resetting, it's picking the old value.
    Can you please tell me how i can reset the sy-tabix of inner loop for the second pass of outer loop.
    Thnaks
    Krishan
    Edited by: Krishan Kumar on Aug 2, 2008 2:40 PM

    You can try it like this:
    data:
      count type i value 1,
      w_line type i.
    describe table i_tab1 lines w_line.
    do w_line time.
    read  i_tab1 into  w_tab1 index count.
      loop at tab2 into w_tab2 where A = itab1-A.
       w_tab3-A = itab1-A.
       w_tab3-B = itab1-B.
       w_tab3-C = itab1-C.
       w_tab3-D = itab2-D.
      APPEND w_tab3 TO i_tab3
      endloop.
    count = count + 1.
    enddo.
    With luck,
    Pritam.

  • How to refresh/initialize sy-tabix in a loop?????

    Dear all,
    Please do let me know how to refresh/initialize 'sy-tabix' for every new document in a loop statement.
    Thanx in advance.
    Alok.

    Never try to refresh or initialize system variable. It shall always lead to errors in the programs. For this I have an alternative way below.
    Please declare a variable for e.g
    data: <b>l_count</b> type sy-tabix.
    Inside loop you can write the code like this:
    say for eg. you need to refresh l_count for every new material.
    Loop at itab.
    on change of itab-material.
    clear : l_count.
    endon.
    l_count = l_count + 1.
    endloop.
    Hope this clarifies your issue.
    Lakshminarayanan

  • Sy-index / sy-tabix wrong within loop

    Hi friends,
    i do a loop over a a table and am writing out the field contents like this:
    LOOP AT <dyn_table> INTO <dyn_wa>.
            do.
          assign component sy-index
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    * Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
          endif.
      ENDLOOP.
    What now doesnt work is, that whenever i have the read statement uncommented the loop doesnt increment so i only get the first row but that n-times.
    any idea where the error is  ?
    thank you! i am awarding points generously

    LOOP AT <dyn_table> INTO <dyn_wa>.
            do.
          assign component sy-index
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
          endif.
      ENDLOOP.
    If i gt you rite..i would suggest this
    Data: l_tabix type sy-tabix.
    LOOP AT <dyn_table> INTO <dyn_wa>.
      l_tabix - sy-tabix.
          assign component l_tabix
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX l_tabix.
          endif.
      ENDLOOP.
    santhosh

  • Values in loops

    Hi. I have a while loop, that runs for some condition
    in this loop, i'm adding as many buttons as the condition holds.
    for each loop, i adds an action listener.
    the problem is when i want to use the action listener. it, of corse, respond to the last button in the loop. how can i make all the buttons work? i dont know ho many loops there will be, ergo i don't know how many buttons there will be... I mean, i have to store each of the values for later use, but how?
    read from file
    while (file is not empty)
    ImageButton = new ImageIcon (name from file);
    theButton = new JButton(imageButton);
    myPanel.add(theButton);
    theButton.addActionListener(this);
    buttonId = i++;
    in the action listener
    if (listener = theButton)
    //do something

    Hi. I have a while loop, that runs for some
    condition
    in this loop, i'm adding as many buttons as the
    condition holds.
    for each loop, i adds an action listener.
    the problem is when i want to use the action
    listener. it, of corse, respond to the last button in
    the loop. how can i make all the buttons work? i dont
    know ho many loops there will be, ergo i don't know
    how many buttons there will be... I mean, i have to
    store each of the values for later use, but how?[snip]
    in the action listener
    if (listener = theButton)
    //do somethingWhat is "listener" and "theButton" here? If you are only doing something for one particular button then that's the only button that will produce any action. You need to do something more like:// Determine which button was pressed
    // Do something (apologies if that's what you're doing already)
    Good Luck
    Lee

  • Get Map values using loops

    Hi,
    With a vector I can have a loop and to get the values with a index.
    Vector vec = new Vector()
    for(int idx=0; idx>vec.size(); idx++){
        System.out.println(vec.get(idx).toString());
    }I can do something similar with a map ? in other words have a loop and get the map values.
    I know that the map a other java.util Collections don't have a
    public Object get(int index)
    method as Vector, but How I can simulate this in a map.
    Some idea ??
    thanks

    what about using an iterator?
    Iterator it = map.values.iterator();
    while (it.hasNext()) {
    Object o = it.next();
    hf,
    dani

  • How to fetch data from an internal table by comparing the a value in loop

    i have an internale table with two fields like parvw and vtext.
    acc to valuue in parvw in loop we sholud fetch the corresponding value of vtext.
    we should not use loop in loop .
    ex code
    select parvw vtext from tpart into table i_vtext where spras = sy-langu.
        LOOP AT I_OUTPUT.
          CASE I_OUTPUT-tabname.
            WHEN 'VBPA'.
              IF I_OUTPUT-fname = 'KUNNR' OR
                 I_OUTPUT-fname IS INITIAL.
                MOVE I_OUTPUT-tabkey TO vbpa.
               READ TABLE i_vtext WITH table KEY parvw = vbpa-*parvw .
                IF sy-subrc = 0.
                  REPLACE '&' WITH i_vtext-vtext INTO I_OUTPUT-indtext.
                ENDIF.
              ENDIF.
            WHEN 'VBAP'.
              IF I_OUTPUT-fname IS INITIAL.
                REPLACE '&' WITH 'item' INTO I_OUTPUT-indtext.
              ENDIF.
          ENDCASE.
          IF I_OUTPUT-indtext(1) EQ '&'.
            REPLACE '&' WITH I_OUTPUT-ftext(40) INTO I_OUTPUT-indtext.
          ENDIF.

    Loop the main ITAB
    and then use READ TABLE to fetch a row from the 2nd ITAB.
    sort the main itab abd use binary search option in READ to improve the performance
    Narendra

  • Convert values in loop to correct data types

    I need to convert the values in a loop to the correct data types. It compiles, but I get an error. It says,
    Exception in thread "main" java.lang.NumberFormat Excepton: A
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at ExtFile.main(ExtFile.java:22)
    Here is the code:
    import java.text.* ;
    import java.io.* ;
    class ExtFile
    public static void main (String args[]) throws IOException
    // Open the external file whose file name was provided as a
    // command line program invocation argument.
    ExternalFile dataFile = new ExternalFile(args[0]);
    String dataLine = dataFile.getLine();
    char candidate;
    int curPrecinct;
    String precinctIn;
    while (!dataFile.havehitEOF())
    precinctIn = dataFile.getLine();
    candidate = dataLine.charAt(0);
    curPrecinct = Integer.parseInt(dataFile.getLine());
    // Get data line to process
    dataLine = dataFile.getLine();
    System.out.println(dataLine);
    } // EndWhile
    // Close the data file
    dataFile.close();
    } // EndMain
    } // Endclass ExtFile
    What does this exception mean and how might I fix it??

    Hello,
    The line of code:
    curPrecinct = Integer.parseInt(dataFile.getLine());accepts a String (stored in a file) and produces an int (an integer representation of the String). However, if you pass it a String which doesn't represent a integer an exception is thrown. For example, if you want to obtain an integer from the String "123a", an exception will arise because you can not parse "123a" into an int because 123a is not an int, that is, it has a letter 'a' in it - and ints do not.
    To correct this you must pass (make the line in the file) represent an int.
    I hope this works.

  • Using drop down list to set values in looped form

    I've got a form which loops through (currently) 10 copies of an input form for assets
    <form>
    <input name="assetModel[1]" type="text">
    <input name="assetSerial[1]" type="text">
    <cfselect name="assetRoom[1]">
    <input name="assetModel[2]" type="text">
    <input name="assetSerial[2]" type="text">
    <cfselect name="assetRoom[2]">
    <input name="assetModel[3]" type="text">
    <input name="assetSerial[3]" type="text">
    <cfselect name="assetRoom[3]">
    </form>
    I'm after a way to be able to set assetModel[all] = "51" (which shouldn't be too difficult) but also to set [1] = 46, [2]=35, [3]=42 etc.
    Current thinking is that I want to have a drop down box where I can select my all options and another to set where I want to copy the list of assets from another room as default values on this form.
    There are approx 20 fields on each iteration of the field and I'll probably have about 10 fields at the top to set the values I'm after some ofthese affecting multiple form fields.
    Thanks
    Mi-ul

    I've got a form which loops through (currently) 10 copies of an input form for assets
    <form>
    <input name="assetModel[1]" type="text">
    <input name="assetSerial[1]" type="text">
    <cfselect name="assetRoom[1]">
    <input name="assetModel[2]" type="text">
    <input name="assetSerial[2]" type="text">
    <cfselect name="assetRoom[2]">
    <input name="assetModel[3]" type="text">
    <input name="assetSerial[3]" type="text">
    <cfselect name="assetRoom[3]">
    </form>
    I'm after a way to be able to set assetModel[all] = "51" (which shouldn't be too difficult) but also to set [1] = 46, [2]=35, [3]=42 etc.
    Current thinking is that I want to have a drop down box where I can select my all options and another to set where I want to copy the list of assets from another room as default values on this form.
    There are approx 20 fields on each iteration of the field and I'll probably have about 10 fields at the top to set the values I'm after some ofthese affecting multiple form fields.
    Thanks
    Mi-ul

  • Layer 3 TTL value and loop

    Hi 
    If the TTL value in the ip header  will stop ip looping , why the same  not implmented in the frame ?
    Thanks 

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    Consider Ethernet Coax.  If you physically loop it, what's going to decrement a counter in the frame?
    Consider compatibility.  If you add a new "TTL" counter to the frame, older equipment may not understand the frame format.
    BTW, TTL won't avoid a loop, it would just keep the frame from looping endlessly.

  • Hidde database values when looping through jsp:useBean collection

    <jsp:useBean id="categories" scope="request" class="java.util.Collection"/>
    <c:forEach var="dto" items="${categories}">               
    <td width="375px" class="categoryContentTD">${dto.categoryName}</td>
    <td width="75px" class="categoryContentTD">${dto.categoryStatus}</td>
    <td width="75px" class="categoryContentTDEdit" align="center">
    edit
    </td>
    </c:forEach>
    When I view source I can see the values in my database. Is there anyway to hide these from view source?

    You can use an alias for the key values. For example, if you have a list of personIDs for your list as follows:
    325244,32156,51255 that you dont want on the displayed page, you can store those numbers in a two dimentional array in the user's session scope back on the server as follows:
    1 325244
    2 32156
    3 51255
    Now, you send 1,2,3 to the JSP page. When you get back 1,2, or 3, you use that two dimentional array to convert the number back to personID. Now you have personID you can use in your datbase sql statements.
    You can use a simliar array if you dont want to display the database table column names in the JSP page (so user's dont know info about your database schema).

  • Sy-tabix showing different value each time after ENDLOOP stmt

    Hi,
    when i am executing my program its having one loop statement . after finishing that loop
    below the Endloop statement.
    sy-tabix some time showing 1 and some time showing 2.
    why its chaging its value

    Hi,
    As per SAP online help on [LOOP statement|http://help.sap.com/saphelp_470/helpdata/EN/fc/eb381a358411d1829f0000e829fbfe/content.htm]
    When you leave the loop, SY-TABIX has the same value as when you entered it.
    So the value you are seeing in Sy-tabix after endloop is because of some internal table operations before the starting of that loop.
    You can check this by comparing the sy-tabix value before first Loop pass and after last loop pass.
    Hope this helps you.
    regards
    Karthik D

Maybe you are looking for

  • Business catalyst and  adobe web hosting in Japan

    Hi ! I am new to here and confused about differences for business catalyst in Japan and United States. I have been learning how to develop web page using Muse, Dream Weaver, HTML, etc..for trial creative cloud before I buy. I live in Japan and I am w

  • Cannot install iTunes, Windows 7; error 7

    I downloaded the last iTunes update and since then, have not been able to open iTunes.  I have followed the instructions from the community posts about uninstalling iTunes and all the ancillary programs several times and still cannot open iTunes.  Ea

  • How do I reopen and change an existing pdf file

    I have pdf files in acrobat.com I want to make changes to an existing file. Can you do this or do you have to rewrite the whole file?

  • Apple pro speakers specs?

    can anyone tell me the specifications of the apple pro speakers (the clear round things)? im having to upgrade from them and wanted to get something with at least the same output as these great little speakers so would love to know the specs to match

  • Control indicators for controlling area XYZ1 do not exist". Pls help.

    While Posting to the Customer Downpayment thru t code F-29. following error occured "Control indicators for controlling area XYZ1 do not exist". Pls help.