Looping a Z-Table

Hi All..
I need to find out a particular line of Z-Table and modify that line..
How to do it ...???
Ex: Ztable contains 4 fields and one among is 'Ticket No'. Let assume that table contains 100 Records..
I want to modify the particular line where Ticket no= 10.

Hi,
  If you are planning to modify the ZTABLE then do the following..
1) SELECT SINGLE * FROM ZTABLE
          WHERE TICKET_NO = '10'.
   ZTABLE-FIEL2 = 'ABC'.
   MODIFY ZTABLE.
2) UPDATE ZTABLE SET FIELD2 = 'ABC'
          WHERE TICKET_NO = '10'.
  If you are planning to modify the internal table of the ZTABLE.
  SELECT * FROM ZTABLE INTO ITAB.
  READ TABLE ITAB WITH KEY TICKET_NO = '10'.
  IF SY-SUBRC  = 0.
    V_TABIX = SY-TABIX.
    ITAB-FIELD2 = 'ABC'.
    MODIFY ITAB INDEX V_TABIX
                TRANSPORTING FIELD2.
  ENDIF.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran

Similar Messages

  • Error looping at a table

    Greetings Abapers
    Im trying to loop at a table for certain criteria. My code is:
    Loop at the relationships table and get dates for each salescode BP
       loop at lt_hrp1001 where lt_/ccdev01/a2scode-partner EQ lt_hrp1001-sobid
       and lt_hrp1001-sclas EQ 'BP'.
    I get the following error though:
    "No component exists with the name lt_/ccdev01/a2scode-partner"
    -partner is a field in my local table and all tables have been declared. Please help.

    Don't put the table name in the loop where clause
    loop at lt_hrp1001
      where sobid = lt_/ccdev01/a2scode-partner
         and sclas EQ 'BP'.

  • BRF : Looping through a table (e.g. Do Until or While, etc..)

    Hello Colleagues,
    In BRFPLus I understand we can create Loop Expressions that allow you to loop through a table and perform different Actions based  on the retrieved contents of the table.
    We are not using BRFPLus (but the old BRF instead). Does anyone know how to build Loop Expressions in BRF without the use of ABAP Function Modules?
    Your feedback would be really appreciated.
    Thanks in advance.
    Regards,
    Ivor M.

    Hello Colleagues,
    In BRFPLus I understand we can create Loop Expressions that allow you to loop through a table and perform different Actions based  on the retrieved contents of the table.
    We are not using BRFPLus (but the old BRF instead). Does anyone know how to build Loop Expressions in BRF without the use of ABAP Function Modules?
    Your feedback would be really appreciated.
    Thanks in advance.
    Regards,
    Ivor M.

  • Declaring a message in abap and looping at a table

    Greetings all
    I would like to display an error message once some sort of validation is done. The code for my method is as follows:
    method if_ex_hrbas00infty~before_output.
    *Data declaration
    data: lt_hrp1001 type table of hrp1001,
    lv_sobid type sobid,
    lv_sclas type sclas,
    lv_rsign type rsign,
    lv_relat type relat,
    lv_otjid type otjid.
    Clear the local table and local variables
    refresh lt_hrp1001.
    clear: lv_sobid, lv_sclas, lv_rsign, lv_relat, lv_otjid.
    *Store the separated strings
    lv_sclas = old_innnn-vdata+0(2).
    lv_sobid = old_innnn-vdata+2(10).
    lv_rsign = old_innnn-subty+0(1).
    lv_relat = old_innnn-subty+1(3).
    lv_otjid = old_innnn-otype.
    *Check for existing relationships with other external objects
    select * from hrp1001 into table lt_hrp1001
    where plvar = old_innnn-plvar
    and sobid = lv_sobid
    and sclas = lv_sclas
    and rsign = lv_rsign
    and relat = lv_relat
    and otjid = lv_otjid.
    *Loop through the table and compare the existing relationship with the new one
    loop at lt_hrp1001 where.
    old_innnn-sobid = hrp1001-sobid.
    old_innnn-sclas = hrp1001-sclas.
    old_innnn-rsign = hrp1001-rsign.
    old_innnn-relat = hrp1001-relat.
    old_innnn-otjid = hrp1001-otjid.
    If statement to compare the start and end dates
    if lt_hrp1001-begda > old_innnn-endda
    or old_innnn-endda < lt_hrp1001-begda
    *Issue a warning informing the user about the overlap
    message 'ZEXERCISE' type 'E' number '000'.
    endif
    endloop.
    break lmandimika.
    endmethod.
    Ive created my message class which is ZEXERCISE but i have to declare the message somewhere using MESSAGE-ID ZEXERCISE. The only problem is that i cant declare it within this method. Any help as to where i can declare it.
    In addition to that, my loop at doesnt work because it tells me LOOP AT itab one of the additions INTO, ASSIGNING or TRANSPORTING NO FIELDS is required. I want to loop through the local table lt_hrp1001 and compare old_innn with all the entries in the table.
    Any help would be greatly appreciated.

    1. create a workarea like
    *Data declaration
    data: lt_hrp1001 type table of hrp1001,
            wa_hrp1001 type hrp1001 .
    in ur code                *Loop through the table and compare the existing relationship with the new one
    loop at lt_hrp1001 where.
    old_innnn-sobid = hrp1001-sobid.
    old_innnn-sclas = hrp1001-sclas.
    old_innnn-rsign = hrp1001-rsign.
    old_innnn-relat = hrp1001-relat.
    old_innnn-otjid = hrp1001-otjid.
    here u r checking this only for one time ,
    better u write like
    loop at lt_hrp1001 into wa_hrp1001 .
    *now check the condition .
    if                 old_innnn-sobid = wa_hrp1001-sobid     AND
                      old_innnn-sclas = wa_hrp1001-sclas        AND
                      old_innnn-rsign = wa_hrp1001-rsign         AND
                      old_innnn-relat = wa_hrp1001-relat          AND
                     old_innnn-otjid = wa_hrp1001-otjid       .
    *another  If statement to compare the start and end dates
    if lt_hrp1001-begda > old_innnn-endda
    or old_innnn-endda < lt_hrp1001-begda
         here give a message like
    message i001(ZEXERCISE).          " No need of defining message class in report
    endif.
    ENDIF.
    clear wa_hrp1001.
    endloop.
    2 . here we have to compulosry use a workarea , while making use of loop - Endloop .
    3 . You had not specified wether  "  old_innnn  "  is a table or just fields defined separately .
    Thanks ,
    reward poins if helpful.

  • How we can loop the screen table.

    Hi All,
    We are used loop the screen table but it is a structure how we are able to do this what sap doing behind this can any body please tell me.
    Thanks,
    Saleem.

    Hi
    SCREEN is a structure only.
    But when you create a screen or selection-screen; the program which controls your screen or selection-screen creates an internal table with header line of type SCREEN.
    So in your program SCREEN is an internal table, you can always loop it.
    To understand it better, write some parameters and select-options in a report program; in debugging mode see the details of SCREEN table.
    Regards
    Surya.

  • Loop through a table

    Is it feasible to write code that loops through a table in a form? I'm currently writing separate sections of code for each row of a five-row table to validate data entries.

    Hi,
    It would be easier if your table contained one row that repeated with an initial count of five (this is set in the binding tab of the Object palette).  This will change the XML generated but assuming that is not a problem your could loop though your table with the code;
        var rows = this.resolveNodes("Table1.Row1[*]");
        for (var i=0; i<rows.length; i++)
            var currentRow = rows.item(i);
    If you do need the rows uniquely named then you could pass i and the result of "this.resolveNodes("Table1.Row"+i)" into a function.
    This is you form back ... with only the first validation converted to the new approach.
    https://acrobat.com/#d=akb0*Ptvdr3KSYN0VP*7zA
    Hope this gets you started.
    Regards
    Bruce

  • Avoiding performance issue due to loop within loop on internal tables

    Hi Experts,
                    I have a requirement where in i want to check whether each of the programs stored in one internal table are called from any of the programs stored in another internal table. In this case i am looping on two internal tables (Loop within a loop) which is causing a major performance issue. Program is running very very slow.
    Can any one advise how to resolve this performance issue so that program runs faster.
    Thanks in advance.
    Regards,
    Chetan.

    Forget the parallel cursur stuff, it is much to complicated for general usage and helps nearly nothing. I will publish a blog in the next days where this is shown in detail.
    Loop on loop is no problem if the inner table is a hashed or sorted table.
    If it must be a standard table, then you must make a bit more effort and faciliate a binary search (read binary search / loop from index exit)
    see here the exact coding Measurements on internal tables: Reads and Loops:
    /people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
    And don't forget, the other table must not be sorted, the loop reaches anyway every line. The parallel cursor requires both tables to be sorted. The additional sort
    consumes nearly the whole advantage of the parallel cursor compared to the simple but good loop in loop solutions.
    Siegfried

  • Loop at internal Table inside Script

    Hi
       I am filling a table in a subroutine in a program  and calling it through 'Perform' from my Script,now the main issue is , How to display the table in my script ? 
                I want to loop through an internal table & display its content on my script , but i can't make changes in the calling program by any means.

    Hi Ajitabh ,
    With PERFORM inside SAPSCRIPT you can only pass individual fields and also get back individual fields .
    Check This
    http://help.sap.com//saphelp_470/helpdata/EN/d1/802fd3454211d189710000e8322d00/frameset.htm
    Only "USING" and CHANGING" options are allowed and that too only symbols available / defined in sapscript can be passed .
    Even if you populate an internal table in the program you are calling with "PERFORM" there is no way to pass this internal table back to sapscript , also in SAPSCRIPT there is no way to loop .
    If you are sure about the no of lines you are going to populate and all lines have only one column ( only one field ) you can try something like this .
    /: PERFORM GET_VALUE IN PROGRAM <ZNAME>
    /: USING &VAR1&
    /: USING &VAR2&
    /: CHANGING &ITAB1&
    /: CHANGING &ITAB2&
    /: CHANGING &ITAB3&
    /: CHANGING &ITAB4&
    /: ENDPERFORM
    Anothe way is to loop in the main print program and call WRITE_FORM . But I guess your main print program is a SAP std program which you dont want to copy and change.
    Cheers.

  • Sy-subrc = 8 when looping through a table...

    i am looping one table and reading other.
      now sy-subr = 8,it is showing what can be the reason.
    Thanks in advance.
    Edited by: Julius Bussche on Feb 24, 2009 10:50 AM
    Subject title improved

    Hi,
    If
    sy-subrc = 4 No lines were read.
    sy-subrc = 8 The search key was not fully qualified.
    So u can add the logic for sy-subrc = 8 or u can change the logic as
    if sy-subrc is initial.
    else.
    endif.
    Keerthi.

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • Object Services - How to loop at a table ' osreftab ' ?

    Hi Object Services Gurus,
    I'm try to transform a table selected via object services (transaction service) to a table with type VRM_VALUES (the one necessary to fill selection screen listbox parameters).
    So, i have a table with type 'osreftab' and i need to loop it accessing the attributes of its lines (which i just know at runtime). How can i proceed with this? Below is what i'm trying..
    * (This is a method of a global class which pretends to transform a variable 'osreftab' into a variable 'vrm_values').
    DATA: l_wa_value TYPE VRM_VALUE,
               l_i_values TYPE VRM_VALUES.
    DATA: l_o_tax_code TYPE OSREF.
    * im_tax_codes type is osreftab
    LOOP AT im_tax_codes INTO l_o_tax_code.
    *l_wa_value-KEY = l_o_tax_code->?
    *l_wa_value-text = l_o_tax_code->?
      APPEND l_wa_value TO l_i_values.
    ENDLOOP.

    You can't cast b/w data reference which l_tax is and object reference which l_o_tax_code is.
    osref is a generic object type and you store a reference to some object in it, right? So the question is: what kind of object you store there? Please note - this must be an object reference , not data reference .
    i.e
    "here goes some class
    class zcl_spfli definition.
    endclass.
    class zcl_spfli implementation.
    endclass.
    "here is an OBJECT REFERENCE for it, (so I refer to a class) i.e persistent object to table SPFLI
    data oref_spfli type ref to zcl_spfli.
    "but here I have a DATA REFERENCE (so I refer to some data object) i.e DDIC structure SPFLI
    data dref_spfli type ref to spfli.
    So my OSREF can hold only oref_spfli but it not intended for dref_spfli . That's why you get this syntax error. Once you have stored reference to zcl_spfli in osref then you will be able to dereference it and access this object's attributes.
    data: osref type osref.
    create object osref_spfli.
    osref = osref_spfli.
    "now osref holds reference to object, you can deference it
    oref_spfli ?= osref.
    osref_spfli->some_attribute = ....
    OSREFTAB is just a table whose line is of type OSREF (so can hold multiple object references - one in each line).
    Regards
    Marcin

  • Regarding looping of a table

    how can we loop a table with respect to the index values of the table i want to loop the table upto an index 5 how can i do it.
    thanks in advance

    hi
    Sample Code:
    READ TABLE T_MARC1 INTO WA_MARC WITH KEY WERKS = P_WERKS.
    IF SY-SUBRC EQ 0.
    L_TABIX = SY-TABIX + 1.
    ADD 1 TO COUNT.
    LOOP AT T_MARC1 INTO WA_MARC FROM L_TABIX.
    IF WA_MARC-WERKS NE P_WERKS.
    EXIT.
    ENDIF.
    ADD 1 TO COUNT.
    ENDLOOP.
    ENDIF.
    If you look at the above code, first we read the record which appears first in the list of records, hence the index of that entry is stored in a local variable, further records can be read using index from loop which is very fast in access.
    regards
    Satish

  • Looping through a table

    how do I loop through the following table and get it to insert records into another depending on the number that it finds in the value column. eg if there is 8 in the value column, 8 records should be inserted into another table with the same ID
    i forgot to paste an example table
    ID
    Name
    Value
    1
    john
    12
    2
    sarah
    20
    3
    Tom
    5
    I want it to look at the value column and if it is 12 it should add 12 rows with the same ID into another table. eg in the new table there will be 12 rows for John with an ID of 1. For Sarah there will be 20 rows with an ID of 2.
    sukai

    Sure!
    DECLARE @sourceTable TABLE (ID INT, Name VARCHAR(20), Value INT)
    INSERT INTO @sourceTable (ID, Name, Value) VALUES (1, 'john', 12),(2, 'sarah', 20),(3, 'Tom', 5)
    This mocks up your source table (where your data is coming from). We're simply creating a table variable, and populating it with your example data.
    DECLARE @numbers TABLE (value INT)
    WHILE (SELECT COUNT(*) FROM @numbers) < (SELECT MAX(Value) FROM @sourceTable)
    BEGIN
    INSERT INTO @numbers (value) VALUES ((SELECT COUNT(*) FROM @numbers)+1)
    END
    This creates an example numbers table. The while causes the code to loop until there are as many rows as the maximum value for the Value column in your example data. Each time the loop iterates it inserts a row, causing the COUNT(*) to be one more each time,
    we add one to that, and insert it into the numbers table.
    INSERT INTO destinationTable
    SELECT s.ID, s.Name, s.Value
    FROM @sourceTable s
    INNER JOIN @numbers n
    ON s.Value >= n.value
    ORDER BY s.ID
    This performs an insert select to a made up table. We join the rows from @sourceTable (your example data) to the @numbers table where the Value column from @sourceTable is less than or equal to the value column in the numbers table. If s.Value is 1
    we'll perform this join once. If it's 2, twice and so on. This works because of the way we set up the numbers table. If we had insert multiple 1's it would cause additional joins.
    A numbers table is a handy tool to have for things like this were you need iterations. Create a database (or schema) on your database and call it something like 'Toolbox'. In that database/schema you can put things like this that have little to do with your
    actual data, but come in handy. You can make your numbers table as long as you need. It totally wouldn't hurt at all to have a numbers table with hundreds of thousands of rows. They're just int's, they don't eat much :).
    Let me know if you'd like anything clarified more.

  • Looping at internal table is taking lots of time

    Hi,
    I have two internal tables IT_1 and IT_2. My requirement is as below:-
    For record in table IT_1 if no record is found in table IT_2 then appned to the third table IT_3.
    I am using the below code for the same.
      LOOP AT tbl_articles INTO tbl_articles.
        READ TABLE tbl_prix_art WITH KEY matnr = tbl_articles-matnr.
        IF sy-subrc <> 0.
          MOVE tbl_articles TO tbl_articles_2.
          APPEND tbl_articles_2.
        ENDIF.
        CLEAR : tbl_articles, tbl_articles_2.
      ENDLOOP.
    But is taking huge amount of time due to larger number of records in tbl_articles .
    Is there any other way through which i can get the same functionality.
    Regards
    Sachin

    Sachin,
    Some food for thought.
    Irrespective of how you define the table it has to go through the n number of rows in tbl_articles because that is the basic functioanlity.
    I think your READ TABLE is what is delaying your process here. So try a Binary Search as below.
    Line 1 of change --> SORT tbl_prix_art asc ASCENDING matnr. 
    LOOP AT tbl_articles INTO tbl_articles.
    Line 2 of change --> READ TABLE tbl_prix_art BINARY SEARCH  WITH KEY matnr = tbl_articles-matnr.
    IF sy-subrc 0.
    MOVE tbl_articles TO tbl_articles_2.
    APPEND tbl_articles_2.
    ENDIF.
    CLEAR : tbl_articles, tbl_articles_2.
    ENDLOOP.
    I am confident this will solve your long run times.
    Thanks
    Mani

  • Looping at internal table

    Hi, I work on SAP BW and need guidance on the functionality from the below code:
    l_s_datapak_line[] = datapak[].
        l_s_datapak[] = datapak[].
        sort l_s_datapak_line by pernr endda descending.
    loop at l_s_datapak.
       read table l_s_datapak_line with key pernr = l_s_datapak-pernr
       endda = '99991231'.
       if sy-subrc = 0.
    pernr = l_s_datapak_line-pernr.
            curr_compcode = l_s_datapak_line-bukrs.
            curr_job = l_s_datapak_line-stell.
            curr_mastcctr = l_s_datapak_line-kostl.
            curr_orgunit = l_s_datapak_line-orgeh.
            curr_persarea = l_s_datapak_line-werks.
            curr_perssubarea = l_s_datapak_line-BTRTL.
            curr_position = l_s_datapak_line-plans.
            curr_chief = l_s_datapak_line-zzchiefpernr.
            curr_supervisor = l_s_datapak_line-zzsupervisor.
            modify i_curr index i_index.
           exit.
          endif.
        endloop.
    In the above code, I want the loop to run only once for each pernr. If there are 10 records in l_s_datapak with pernr = 100, then the loop would run 100 times although there would be only one record in l_s_datapak_line with endda = '99991231'. I want the loop to run only once , assign the values and then l_s_datapak-pernr should become 101. How do I do it?
    Any help is highly appreciated and thanks for the help in advance.

    Hi,
    Use Control Break statements i.e. AT NEW....ENDAT as shown below.
    l_s_datapak_line[] = datapak[].
    l_s_datapak[] = datapak[].
    sort l_s_datapak_line by pernr endda descending.
    loop at l_s_datapak.
    <b>AT NEW pernr.</b>
    read table l_s_datapak_line with key pernr = l_s_datapak-pernr
    endda = '99991231'.
    if sy-subrc = 0.
    pernr = l_s_datapak_line-pernr.
    curr_compcode = l_s_datapak_line-bukrs.
    curr_job = l_s_datapak_line-stell.
    curr_mastcctr = l_s_datapak_line-kostl.
    curr_orgunit = l_s_datapak_line-orgeh.
    curr_persarea = l_s_datapak_line-werks.
    curr_perssubarea = l_s_datapak_line-BTRTL.
    curr_position = l_s_datapak_line-plans.
    curr_chief = l_s_datapak_line-zzchiefpernr.
    curr_supervisor = l_s_datapak_line-zzsupervisor.
    modify i_curr index i_index.
    exit.
    endif.
    <b>ENDAT.</b>
    endloop.
    Reward points if the answer is helpful.
    Regards,
    Mukul

  • Looping through a table Help needed ....Forms 10g..... When Button Pressed

    Hye craig, hamid, christian and all ...........
    i have a user access interface which i create where there are two fields username and password and a button,
    i have also created a table USERS for users which have username and password fields ..... On useraccess interface i coded on WHEN BUTTON PRESSED like this
    declare
    go_block('users');
    execute_query;
    declare
    begin
         if :useraccess.username=:users.username and
              :useraccess.password=:users.password then
              go_block('MAINPAGE');
              else
              go_block('USERACCESS');
              MESSAGE('SORRY WRONG PASSWORD OR NOT A REGISTERED USER');
              MESSAGE('SORRY WRONG PASSWORD OR NOT A REGISTERED USER');
              end if;
    end;
    This code works for a single user in USERS table but for multiple users there has to be some looping system
    which matches the USERACCESS and USERS tables fields thoroughly ....

    Hi Majid,
    I can suggest you a workaround for this. raise a ON-LOGON trigger and you can use the LOGON_SCREEN builtin to flash the logon screen at runtime. And then try capturing the username and password.
    DECLARE
      connected BOOLEAN := FALSE;
      tries     NUMBER  := 3;
      un        VARCHAR2(30);
      pw        VARCHAR2(30);
      cs        VARCHAR2(30);
    BEGIN
      SET_APPLICATION_PROPERTY(CURSOR_STYLE, 'DEFAULT');
      WHILE connected = FALSE and tries > 0
      LOOP
        LOGON_SCREEN;
        un := GET_APPLICATION_PROPERTY( USERNAME );
        pw := GET_APPLICATION_PROPERTY( PASSWORD );
        cs := GET_APPLICATION_PROPERTY( CONNECT_STRING );
        LOGON( un, pw || '@' || cs, FALSE );
        IF FORM_SUCCESS
        THEN
          connected := TRUE ;
        END IF;
        tries := tries - 1;
      END LOOP;
      IF NOT CONNECTED THEN
        MESSAGE('Too many tries!');
        RAISE FORM_TRIGGER_FAILURE ;
      END IF;
    END ;   a sample piece of coding to help you out.
    Regards,
    Manoj Chakravarthy

Maybe you are looking for

  • MacBook Pro Mid 2012 freezes when plugged in

    Hi. My Mid 2012 MBP which runs on Yosemite 10.10.2 keeps freezing even when just browsing on Chrome so I uninstalled Chrome and used Safari. I was still having problems after switching browsers so I restored my device to its factory settings but the

  • Accessing old Iphoto library on external hard drive in new iphoto

    We recently bought a new macbook pro with iphoto 9.5.1.  Previously, we had a 2008 macbook and had transferred the very large iphoto library onto our Toshiba external harddrive.  After downloading Tuxera NTFS to be able to use the external hard drive

  • Customize file output

    Say I want to create a custom template for exporting data from LabVIEW.  Currently I am using DAQmx and using the write to measurement file vi.  This is not allowing me to customize what goes in each column and so forth.  Is there an easier way for m

  • Dbca: how to change template location ?

    my disk (windows partition) is corrupted, can't create any file on it. Want to save my database using dbca (create template with file) - save the templates on another partition or USB-disk. But I have to change the location where the template will to

  • Regarding olap cache

    Hi,    Can anyone kindly tell olap cache realtime issues.         Thanks in advance. Edited by: Muddus on Mar 10, 2010 7:48 AM Edited by: Muddus on Mar 10, 2010 7:48 AM