Loop in TABLE

hi,
anybody tell me how to define LOOP in TABLE in SMARTFORMS.
thanks
RP

Hi,
You candefine loop like this:
click on the window go to create>flowlogic->loop.
In OUTPUT OPTION tab of loop you can define the LOOP into Work_area Statement.
Alternate option:
If you are using Table in Main window then you can provide LOOP into Work_Area statement in DATA tab & no need of creating separate loop.
Ashvender

Similar Messages

  • How do I loop through tables, not columns in a table?

    Sorry if this is a long one. My problem is actually quite simple. I am trying to write either an ad hoc PL/SQL block or a stored procedure to loop 18 times (thru 18 tables) and perform a SQL query on those tables, returning 18 resultsets. I would like the results to show up on the screen (or in a spool file, whatever).
    So far I have tried 3 different approaches, none of which have worked.
    1. I tried to assign the select query to a variable (qry) and use EXECUTE IMMEDIATE qry. This forced me thru a variety of errors to declare variables and assign the result to them--EXECUTE IMMEDIATE qry into nm0, nm1, nm2...
    The problem with that was the resultset returned more than the variable was built for as there might be no rows returned, or it might be a thousand rows of data. So I tried changing the variables to VARRAYS, but it gave me a type mismatch as the underlying columns were NUMBER and VARCHAR2.
    DECLARE
         ctr number;
         TYPE NUMLIST IS VARRAY (1000) OF NUMBER;
         TYPE VARLIST IS VARRAY (1000) OF VARCHAR2(15);
         nm0 NUMLIST NOT NULL DEFAULT 1;
         nm1 VARLIST;
         nm2 NUMLIST NOT NULL DEFAULT 1;
         nm3 VARLIST;
         nm17 NUMLIST NOT NULL DEFAULT 1;
         qry VARCHAR2(2000) := 'klx_uln_p000_cells';
    BEGIN
    FOR ctr IN 1..17 LOOP
         IF ctr < 10 THEN
              qry := 'SELECT
              A.DIM_0_INDEX,
              S0.SYM_NAME,
              A.DIM_1_INDEX,
              S1.SYM_NAME,
              A.DIM_2_INDEX,
              S2.SYM_NAME,
              A.DIM_3_INDEX,
              S3.SYM_NAME,
              A.NUMERIC_VALUE,
              B.NUMERIC_VALUE
              FROM
              KHALIX.klx_uln_p00'||ctr||'_cells A,
              KHALIX.klx_ucn_p00'||ctr||'_cells B,
              KHALIX.KLX_MASTER_SYMBOL S0,
              KHALIX.KLX_MASTER_SYMBOL S1,
              KHALIX.KLX_MASTER_SYMBOL S7
              WHERE
              A.DIM_0_INDEX=B.DIM_0_INDEX AND
              A.DIM_1_INDEX=B.DIM_1_INDEX AND...
              A.DIM_7_INDEX=S7.SYM_INDEX';
         ELSE
              qry := 'SELECT
              A.DIM_0_INDEX...
              A.DIM_7_INDEX=S7.SYM_INDEX';
         END IF;
         BEGIN
         dbms_output.put_line('SELECT FOR KLX_ULN_P00'||ctr||'_CELLS');
         dbms_output.put_line(nm16);
         dbms_output.put_line(nm17);
         EXECUTE IMMEDIATE qry into nm0,nm1,nm2,nm3,nm4,nm5,nm6,nm7,nm8,nm9,nm10,nm11,nm12,nm13,nm14,nm15,nm16,nm17;
    --     dbms_output.put_line(qry);
         dbms_output.put_line(nm16);
         dbms_output.put_line(nm17);
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
                   dbms_output.put_line('No data found for Query '||ctr);
         END;
    END LOOP;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
              dbms_output.put_line('No data found for Query '||ctr);
    END;
    2. So then I used REF CURSOR to create a stored procedure and return the values. That allowed me to run my query AND tokenize the tablenames with a counter so that it would loop through the different tables! However, I still could not get it to display the results without going to SQL Plus and typing 'print c;'.
    3. So, finally I tried to create a looping wrapper around the ref cursor to have some variable (ctr) increment so my query would get performed on table0_cells through table17_cells. This, too, did not work.
    If I manually go to SQL Plus and type:
    variable ctr number
    begin
    :ctr := 1;
    end;
    exec dupe_find(1,:c);
    it will execute for the first table (klx_uln_p001_cells) and I can then type 'print c' to see what was returned. But when I try putting this within a wrapper PL/SQL block with a Loop to make ctr go from 0 - 17 (to loop through table_names klx_uln_p000_cells to klx_uln_p017_cells), it does not work.
    Help! It should be very simple to loop through tables, shouldn't it? I just want a script that will loop through tables, perform a query on each table and display the results. For some reason, I can only find documentation examples on looping through columns that are all in the same table.
    Dave

    Here's a working example using your first strategy ...
    create table t1 (id number);
    create table t2 (id number);
    insert into t1 values (100);
    insert into t1 values (101);
    insert into t2 values (200);
    insert into t2 values (201);
    declare
    v_table_name user_tables.table_name%type;
    type ttab_id is table of t1.id%type index by binary_integer;
    tab_id ttab_id;
    begin
    for i in 1 .. 2 loop
    v_table_name := 't' || i;
    execute immediate 'select id from ' || v_table_name
    bulk collect into tab_id;
    dbms_output.put_line('query from ' || v_table_name);
    for j in 1 .. tab_id.count loop
    dbms_output.put_line(tab_id(j));
    end loop;
    end loop;
    end;
    There are many other ways to do this (especially if you need to do more than just print out the data).
    Richard

  • Loop through table in XI

    Hi Guys,
    I have scenario where i call a BAPI and get return parameter as a table. I want to loop through this table in XI/BPM. Can i get some help on how to loop thorugh table in XI?

    Hi yashpal,
    Bloack Step in a BPM is used to process a sequence of steps repeatedly  for different information.
    The block step can be processed using FOR EACH and PAR FOR EACH. For each will process the info one after the other and PAR FOR EACH will do it in parallel.
    For more info on the Block Step Type in particular and the BPM in XI , check these links,
    http://help.sap.com/saphelp_nw04/helpdata/en/f6/e1283f2bbad036e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/62/dcef46dae42142911c8f14ca7a7c39/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/831620a4f1044dba38b370f77835cc/content.htm
    Hope this helps,
    Regards,
    Bhavesh

  • Loop Internal Table Performance

    Hi I am from BW and not much familiar with ABAP. I have written the following code in BW. I have around 1.5 million records coming into BW and the code I have written needs to go through 1.5 million times. Hence the data load is taking long time. I would like someone to please go through the code below and suggest if any for performance improvement.
    data: i_datapackage like DATA_PACKAGE occurs 0 with header line,
          i_index like sy-tabix,
          j_index like sy-tabix,
          i_employee like /bi0/memployee occurs 0 with header line,
          i_begda like /bi0/memployee occurs 0 with header line.
          prev_job like i_employee-job,
          prev_position like i_employee-hrposition,
          curr_job like i_employee-job,
          curr_position like i_employee-hrposition,
          job_datefrom like i_employee-datefrom,
          position_datefrom like i_employee-datefrom,
          prejob_datefrom like i_employee-datefrom,
          prepos_datefrom like i_employee-datefrom,
          prejob_dateto like i_employee-datefrom,
          prepos_dateto like i_employee-datefrom.
    i_datapackage[] = DATA_PACKAGE[].
    sort i_datapackage by employee calmonth ascending.
    select * from /bi0/memployee into table i_employee.
    sort i_employee by employee dateto descending.
    i_begda[] = i_employee[].
    sort i_begda by employee datefrom ascending.
    delete adjacent duplicates from i_employee comparing employee.
    loop at i_datapackage.
    *collecting current job,position, previous job, position
        read table i_employee with key employee = i_datapackage-employee
        dateto ='99991231'.
        if sy-subrc = 0.
          curr_job = i_employee-job.
          curr_position = i_employee-hrposition.
        endif.
       read table i_begda with key employee = i_datapackage-employee.
       if sy-subrc = 0.
         prev_job = i_begda-/bic/zhr_pjob.
         prev_position = i_begda-/bic/zhr_ppost.
       endif.
    *end of collecting current job and position
    sort i_begda by employee datefrom descending.
    read table i_begda with key employee = i_datapackage-employee
    binary search.
    if sy-subrc = 0.
      i_index = sy-tabix.
    endif.
    read table i_begda index i_index.
    if i_begda-employee ne i_datapackage-employee.
      exit.
    endif.
    code for populating service award tenure
    if i_begda-/bic/zhr_srvdt is not initial.
    i_datapackage-/bic/zhr_hrtnr = sy-datum+0(4) -
    i_begda-/BIC/ZHR_SRVDt+0(4).
    if sy-datum4(4) lt i_begda-/bic/zhr_srvdt4(4).
       i_datapackage-/bic/zhr_hrtnr = i_datapackage-/bic/zhr_hrtnr - 1.
    endif.
    endif.
    code for current hire tenure
    if i_begda-/bic/zhr_curdt is not initial.
    i_datapackage-/bic/zhr_crtnr = sy-datum+0(4) -
    i_begda-/BIC/ZHR_CURDT+0(4).
    if sy-datum4(4) lt i_begda-/BIC/ZHR_CURDT4(4).
       i_datapackage-/BIC/ZHR_CRTNR = i_datapackage-/bic/zhr_crtnr - 1.
    endif.
    endif.
    code for current supervisor tenure
    if i_begda-/bic/zhr_csbdt is not initial.
    i_datapackage-/bic/ZHR_CSTNR = sy-datum+0(4) -
    i_begda-/BIC/ZHR_CSBDT+0(4).
    if sy-datum4(4) lt i_begda-/BIC/ZHR_CSBDT4(4).
       i_datapackage-/bic/ZHR_CSTNR = i_datapackage-/bic/ZHR_CSTNR - 1.
    endif.
    endif.
    code for previous supervisor tenure
    if i_begda-/bic/zhr_psbdt is not initial.
    i_datapackage-/bic/ZHR_PSTNR = sy-datum+0(4) -
    i_begda-/BIC/ZHR_PSBDT+0(4).
    if sy-datum4(4) lt i_begda-/BIC/ZHR_PSBDT4(4).
       i_datapackage-/bic/ZHR_PSTNR = i_datapackage-/bic/ZHR_PSTNR - 1.
    endif.
    endif.
    Code for populating Years in current job
    and current position
      sort i_begda by employee datefrom ascending.
        clear j_index.
        read table i_begda with key employee = i_datapackage-employee.
        if sy-subrc = 0.
          j_index = sy-tabix.
        endif.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-job eq curr_job ) and
          ( curr_job is not initial ).
            job_datefrom = i_begda-datefrom.
            prejob_dateto = i_begda-datefrom - 1.
            exit.
          endif.
        endloop.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-hrposition eq curr_position ) and
              ( curr_position is not initial ).
              position_datefrom = i_begda-datefrom.
              prepos_dateto = i_begda-datefrom - 1.
              exit.
          endif.
        endloop.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-job eq prev_job ) and
             ( prev_job is not initial ) and
             ( i_begda-datefrom ne '10000101').
              prejob_datefrom = i_begda-datefrom.
              exit.
          endif.
        endloop.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-hrposition eq prev_position ) and
             ( prev_position is not initial ) and
             ( i_begda-datefrom ne '10000101').
              prepos_datefrom = i_begda-datefrom.
              exit.
          endif.
        endloop.
    i_datapackage-/bic/zhr_cjtnr = sy-datum+0(4) -
    job_datefrom+0(4).
    if sy-datum4(4) lt job_datefrom4(4).
       i_datapackage-/bic/zhr_cjtnr = i_datapackage-/bic/zhr_cjtnr - 1.
    endif.
    if position_datefrom+0(4) is not initial.
    i_datapackage-/bic/zhr_cptnr = sy-datum+0(4) -
    position_datefrom+0(4).
    if sy-datum4(4) lt position_datefrom4(4).
       i_datapackage-/bic/zhr_cptnr = i_datapackage-/bic/zhr_cptnr - 1.
    endif.
    endif.
    if prejob_datefrom is not initial.
    i_datapackage-/bic/zhr_pjtnr = prejob_dateto+0(4) -
    prejob_datefrom+0(4).
    if prejob_dateto4(4) lt prejob_datefrom4(4).
       i_datapackage-/bic/zhr_pjtnr = i_datapackage-/bic/zhr_pjtnr - 1.
    endif.
    endif.
    if prepos_datefrom is not initial.
    i_datapackage-/bic/zhr_pptnr = prepos_dateto+0(4) -
    prepos_datefrom+0(4).
    if prepos_dateto4(4) lt prepos_datefrom4(4).
       i_datapackage-/bic/zhr_pptnr = i_datapackage-/bic/zhr_pptnr - 1.
    endif.
    endif.
    modify i_datapackage transporting /bic/zhr_hrtnr /bic/zhr_crtnr
    /bic/zhr_cstnr /bic/ZHR_PSTNR /bic/zhr_cjtnr /bic/zhr_cptnr
    /bic/zhr_pjtnr /bic/zhr_pptnr.
    endloop.
    DATA_PACKAGE[] = i_datapackage[].
    Thanks.

    i_datapackage[] = DATA_PACKAGE[].
    i_begda[] = i_employee[].
    How larger are these internal tables ?
    If large, then
    > sort i_begda by employee datefrom descending.
    > read table i_begda with key employee = i_datapackage-employee binary search.
    the resorting and
    the nested loops
    => will kill your performance
    Please reconsider the whole logic, I have only some hints
    + Binary search does not help anything if you have to sort everytime you use it.
    + Never use a sort of a larger table inside a larger loop, it is always avoidable!
    + Check whether you can break down the big piece into smaller one, try to
       do the break down in the database already to save memory
    =>  Please provide your code in better layout, and explain what you actually want
          to do.
    Siegfried

  • Loop at table with unspecified type but with where-condition

    Hi,
    Doing a loop over an internal table with unspecified type and in addition using a condtion may be done as follows: Thereby the
    condition would be "... WHERE parentid EQ i_nodeid" if the type of <it_htab> would be static. However dynamic specification of a component through bracketed character-type data objects is not possible.
    FIELD-SYMBOLS: <it_htab> TYPE STANDARD TABLE,
                                    <wa_htab> TYPE ANY,
                                    <parentid> TYPE rsparent.
      ASSIGN me->ref_htab->* TO <it_htab>.
      LOOP AT <it_htab> ASSIGNING <wa_htab>.
        ASSIGN COMPONENT 'PARENTID' OF STRUCTURE <wa_htab> TO <parentid>.
        CHECK <parentid> EQ i_nodeid.
      ENDLOOP.
    Since you have to loop over the whole table and to check within the loop whether the condition is fullfilled, this is rather bad for performance.
    Questions: Are there any tricks to do this better?
    Best Regards and Thank you,
    Ingo

    >
    Lalit Mohan Gupta wrote:
    > you can put the condition in the where clause....
    only if you have the upcoming 7.0 EhP2 (Kernel 7.02 or 7.20) the following dynamic where works:
    DATA cond_syntax TYPE string.
    cond_syntax = `parentid = i_nodeid`.
    LOOP AT <it_htab> ASSIGNING <wa_htab>
                           WHERE (cond_syntax).
    in older releases you would have to use program generation to achieve a dynamic where... .
    Kind regards,
    Hermann

  • Issue with loop in table control

    Hello experts,
    I have 20 entries in my table control  but the loop is going through only for 10 entries..please help me?
    Thanks

    Hi
    In PBO
    module status_your_screen_number.
    loop at itab with control tc.
    endloop.
    in PAI.
    loop at itab.
    module modify_itab
    endloop.
    in Program
    Module status_your_screen_Number.
    describe table itab lines tc-lines -
    > THis will give you Scroll Bars for Table Control
    endmodule
    module modify_itab. -
    > If Required ( If you are modifying the Data of table control )
      DESCRIBE TABLE itab LINES lin.
      IF tc-current_line > lin.
        APPEND itab.
      ELSE.
        MODIFY itab INDEX tc-current_line. ---> This Ensures your data both Upward And Downward Scrolling
      ENDIF.
    endmodule
    Cheers
    Ram
    Edited by: Ramchander Krishnamraju on Oct 28, 2009 8:59 AM
    Edited by: Ramchander Krishnamraju on Oct 28, 2009 9:26 AM

  • How to use loop inside table in smart form

    Hi All
    i have to use page break at the end of each pernr. i got table in smart form and print cells on event on sort begin. it is working ok . i have an other itab in  as well .which i want to the same page with respect to the pernr no.
    but the problem is as i loop the 2nd itab. it prints all the record what it has.
    e.g  i have two pernr 54 and 55.
    the records of itab1 prints on page1 and page 2 properly. now i loop at itab2 it also have relevent records of above said pernrs. but i m unable to control those pernrs and loop print all the records on both pages.
    if u get some thing out of it kindly help me
    Regards
    ammad

    hi,
    Place the second loop ie. itab2 inside the first loop of itab1.  And in the conditions tab of looping itab2 give the condition for checking the pernr.
    try to implement this logic.
    loop itab
      at new pernr
        new-page
      endat.
        loop at itab2 where pernr eq itab-pernr.
       endloop.
    endloop.
    revert back for further queries.
    regards
    Rajitha.

  • For loop or table cast to collection variable

    Hi ,
    I have a collection variable (Table type) which can have at-most 20 variables in it. I want to fetch one particular record.
    Which is more efficient; a For loop* or a table cast* ?
    Thanks,

    @Karthick, The requirement is like I have a query (with 2 joins in it) in a procedure which is executing about 50Lac times, and out of 50Lac execution it is fetching same data for say 25000 records.
    I mean query output is same for 25000 records (not fixed) and then it is same for next 25000 records. So I took a collection variable and did a BULK COLLECT to a variable and trying to process (fetch) data in memory instead of hitting the query again (and table ) again.
    Also query is taking 0.001 sec per execution but it is running for so many times thats why procedure is taking time. Oracle performs 2 type of I/O
    1. Physical I/O
    This happens when oracle picks up the data blocks from the data file and puts it in the Data buffer (SGA)
    2. Logical I/O
    This happens when oracle picks up data block from Data buffer (SGA)
    In Data Buffer the data is stored in FIFO basis. So when you hit a table for the first time oracle goes for a physical I/O the subsequent time it will go for Logical I/O.
    What you are trying to do oracle does it already. You don't have to use a collection. Collection uses expensive private memory (PGA).
    And again the basic question is why are you executing a procedure 50,00,000 times?

  • Loop through tables based on data dict values

    Hi,
    I working on an old v7.3.4 database that I'm not familiar with and I want to loop through the tables and count the occurrence of a field value based on table names i've retrieved from the data dictionary. None of the tables have relational keys defined.
    In a cursor I can loop thru all_tab_columns and load variables with the table, column names, and the datatype, but then I want to use these values in a second nested cursor to loop through each table found by the first cursor.
    When I do :
    Select var_colname from var_tabname
    i get
    The following error has occurred:
    ORA-06550: line 23, column 10:
    PLS-00356: 'V_TABNAME' must name a table to which the user has access
    ORA-06550: line 22, column 5:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 22, column 12:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 27, column 7:
    PL/SQL: SQL Statement ignored
    so it would seem I can't use a variable to substitute the table name in the 'from' clause. Does anyone know of a way round this ?
    Thanks in advance

    Hi,
    You will have to use dynamic sql to create your second cursor.
    DECLARE
         v_sql_query VARCHAR2(400);
         TYPE cur_typ IS REF CURSOR;
         c1 cur_typ;
         mYRec MyTable%rowtype;
    BEGIN
         v_sql_query := 'select * from MyTable';
         OPEN c1 FOR v_sql_query;
              LOOP
              FETCH c1 INTO mYRec;
                   EXIT WHEN c1%NOTFOUND;
                   EXIT WHEN c1%NOTFOUND IS NULL;
    /*processing here*/
              END LOOP;
         CLOSE c1;
    END;
    Regards

  • Loop JCO.Table row

    public Reservation makeReservation() throws CustomException{
              Reservation outgoingRes = new InvReservation();
                   JCO.Function function = null;
              JCO.Client client = null;
                        String functionName="ZMM_OSB_RESERVATION";
              try{
                   function = con.createFunction(functionName);
                   client = JCO.getClient(con.getConnectionPool());
                   System.out.println("AFTER CREATEFUNCTION:" + function );
                   if (function != null) {
                         JCO.ParameterList list = function.getImportParameterList();
                         list.setValue(this.getMATNR(), "MATNR");
                         list.setValue(this.getMENGE(), "MENGE");
                                             list.setValue(this.getSERNR(), "SERNR");
                         list.setValue(this.getWERKS(), "WERKS");
                         list.setValue(this.getLGORT(), "LGORT");
                         list.setValue(this.getKOSTL(), "KOSTL");
                         list.setValue(this.getGSBER(), "GSBER");
                         System.out.println("after set successful");
                         client.execute(function);     
                         int  count= function.getExportParameterList().getFieldCount();
                        JCO.Field ZSUBRCField=function.getExportParameterList().getField("ZSUBRC");
                        JCO.Field ZEMSGField=function.getExportParameterList().getField("ZEMSG");
                         for(int i=0; i<count; i++) {
                        //for(JCO.FieldIterator e = returnStructure.fields(); e.hasMoreElements(); ) {
                           if(ZSUBRCField.getName().equals("ZSUBRC")){
                                  outgoingRes.setZSUBRC(ZSUBRCField.getString()); 
                             }else if(ZEMSGField.getName().equals("ZEMSG")){
                                  outgoingRes.setZEMSG(ZEMSGField.getString()); 
                            // System.out.println(RSNUMField.getName() + ":t" + RSNUMField.getString());
                        System.out.println(ZSUBRCField.getName() + ":t" + ZSUBRCField.getString());
                        System.out.println(ZEMSGField.getName() + ":t" + ZEMSGField.getString());
                         JCO.Table returnStructure=function.getTableParameterList().getTable("RETURN");
                         //JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");
           //---------how to loop table table row------
              //loop columns           
                        for(JCO.FieldIterator e = returnStructure.fields(); e.hasMoreElements(); ) {
                             JCO.Field field = e.nextField();
                             if(field.getName().equals("RSNUM")){
                                  outgoingRes.setRSNUM(field.getString());
                             }else if(field.getName().equals("MATNR")){
                                  outgoingRes.setMATNR(field.getString()); 
                             }else if(field.getName().equals("SERNR")){
                                  outgoingRes.setSERNR(field.getString());
                             }else if(field.getName().equals("MENGE")){
                                  outgoingRes.setMENGE(java.lang.Double.parseDouble(field.getString())); 
                             }else if(field.getName().equals("ZSUBRC")){
                                  outgoingRes.setZSUBRC(field.getString()); 
                             }else if(field.getName().equals("ZEMSG")){
                                  outgoingRes.setZEMSG(field.getString()); 
                             System.out.println("CHECK OUTPUT:" +field.getName() + ":t" + field.getString());
                        System.out.println("all ok");
                        //String currentDir = System.getProperty("user.dir");
                        //props.load(this.getClass().getClassLoader().getResourceAsStream("res/path.properties"));
              }catch(Exception ex){
                   System.out.println("Caught an exception: n" + ex);
                   throw new CustomException(ex);
              }finally{
                   if (client != null) {
                        System.out.println("Connection Closed");
                        JCO.releaseClient(client);
                        //throw new CustomException("ex");
              return outgoingRes;
    i need to loop to JCO.Table
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme

    Start by combining all those queries into 1 query and join
    the applicable tables. If you don't know how to do that, I have
    heard good things about the book, "Teach Yourself SQL in 10
    Minutes" by Ben Forta.

  • Help withe loop on tables

    Hallow in my table itab I have employee (sobid employee number and names ex. 80 emp) in my loop(b_itab) I get all he employee that doing the course (their sobid just 3 emp) how can I use b_itab to write to other table (d_itab) to write all the employee that don’t doing the course .I need a  general solution.
    <b>Ex.i have a table with 80 emp and I doing a loop on this table and find 3 employee that doing course how can I do  comparison in the 2 table that if the employee not in b_itab(emp doing course) write them in d_itab(oteer table).</b>    .if u need more details  please let me now.
    regards

    Loop at itab.
    Specify the condition here if they are doing the course
    if (Condition here)
    append itab to b_itab.
    else
    append itb to d_tab.
    endif.
    endloop.
    The other option will be:
    loop at itab.
    read table b_itab with key course = itab-course.
    if sy-subrc NE 0.
    append itab to d_itab.
    endif.
    endloop.
    Can you try these options? If not, please give the structure of the internal table to know exactly you want to do.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • Loop the table entry and for every entry perform some action.

    Hello Experts,
    I have a requirement where there are let say n no. of entries in my ITAB and now for every entry i have to check certain field value and based on that i have to send respective mail.
    Now this has to run in background mode and the job will run on daily basis so the entries of table that are already processed should not be reprocessed.The scenario is every day the new entries will be added to ITAB and the newly added entries should be processed only.
    Please provide some sample code if possible.
    Thanks,
    Naveen

    Hi,
    I can not add a new field to the existing ztable. Crating a copy of ztable with addtional field status and setting it as processed against the record whenever i populate ITAB from ztable could be a solution but seems very lenthy method.
    There is one filed zdate  so write the code as below:-
    loop at itab where zdate = sy-datum
    email code------
    endloop.
    OR can i make use of
    loop at itab into wa
      ON change  of <filed1>
    email code-----
       ENDON
    endloop.
    Thanks,
    Naveen

  • How to pass parameter to cursor for loop having table type?

    Hi Friends,
    I am wondering how to pass a parameter into second for loop in the example code below.Please see the bold statements and answer my queries.
    Thanks a lot .Here is the code .
    declare
    l_bom_header_tbl BOM_BO_PUB.BOM_HEADER_TBL_TYPE ; ---TABLE TYPE
    V_bom_header_tbl Bom_Bo_Pub.Bom_Head_Rec_Type := Bom_Bo_Pub.G_MISS_BOM_HEADER_REC; ---Record type
    v_bom_components_tbl Bom_Bo_Pub.Bom_Comps_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL;---nested table type
    c:=0 number ;
    k:=1 number ;
    begin
    BOMPXINQ.Export_BOM(
    P_org_hierarchy_name => l_org_hierarchy_name,
    P_assembly_item_name => l_assembly_item_name,
    P_organization_code => l_organization_code,
    P_alternate_bm_designator => '1Test',
    P_Costs => l_costs,
    P_Cost_type_id => l_cost_type_id,
    X_bom_header_tbl => l_bom_header_tbl,
    X_bom_revisions_tbl => l_bom_revisions_tbl,
    X_bom_components_tbl => l_bom_components_tbl,
    X_bom_ref_designators_tbl => l_bom_ref_designators_tbl,
    X_bom_sub_components_tbl => l_bom_sub_components_tbl,
    X_bom_comp_ops_tbl => l_bom_comp_ops_tbl,
    X_Err_Msg => l_Err_Msg,
    X_Error_Code => l_Error_Code);
    if l_Error_Code = 0 then
    for i in 1 .. l_bom_header_tbl.COUNT LOOP
    V_bom_header_tbl.organization_code :='DSC';
    Can we assign a table type to record type like below statement?
    V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
    k:=1;
    I want to pass parameter  l_bom_header_tbl(i).assembly_item_name  into the for statement below: How to achieve this?
    for j in 1 .. l_bom_components_tbl.COUNT LOOP
    Can we assign a table type to table  type like below statement?
    v_bom_components_tbl(k).Assembly_Item_name := l_bom_header_tbl(i).assembly_item_name ;
    k := k + 1;
    end LOOP;
    end loop;
    end;
    Edited by: ILovePlSql on Mar 22, 2010 7:51 AM
    Edited by: ILovePlSql on Mar 22, 2010 8:16 AM

    ILovePlSql wrote:
    V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
    v_bom_header_tabl is a record type and l_bom_header_tbl is a table type .So is the above statement ok?I asked you for type definition. Please provide definition of BOM_BO_PUB.BOM_HEADER_TBL_TYPE and Bom_Bo_Pub.Bom_Head_Rec_Type. If BOM_BO_PUB.BOM_HEADER_TBL_TYPE is table of Bom_Bo_Pub.Bom_Head_Rec_Type then your statment is OK. For example:
    SQL> declare
      2      type BOM_HEADER_TBL_TYPE is table of emp%rowtype index by binary_integer;
      3      l_bom_header_tbl BOM_HEADER_TBL_TYPE;
      4      V_bom_header_tbl emp%rowtype;
      5  begin
      6      select * bulk collect into l_bom_header_tbl from emp;
      7      for i in 1 .. l_bom_header_tbl.count loop
      8        V_bom_header_tbl.ename := l_bom_header_tbl(i).ename;
      9      end loop;
    10  end;
    11  /
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Looping within table query

    Hi all,
    I've run into a problem... Is there anyway where we can do looping in a table in a single SQL query. Basically the scenario is like this :
    *Consider a table with sample data as follows:
    SQL> select * from TEST2;
    EMPNO JOB REL_DT
    1 SALESMAN 01-NOV-06
    2 MANAGER 01-NOV-06
    1 SALESMAN 01-OCT-06
    2 MANAGER 01-OCT-06
    1 CLERK 01-SEP-06
    *Basically the table has a relationship start date i.e. b/w an Employee and a job title.
    *Is there anyway to know the previous job title held by an employee. Basically the logic is as follows:
    get the max(rel_dt) and get the empno.
    for the same empno. traverse the table for rel_dt<max(previous rel_dt) and where job<>previous job.
    Basically this involves looping within the table to find a previous job. This can be done with a procedure. But is there a way we can construct a single SQL query to meet this requirement?
    Thanks in advance :)

    Woops... Okay.. there's a slight problem .. :(
    consider the table below with sample data:
    SQL> select * from test2;
    EMPNO JOB REL_DT
    1 SALESMAN 01-NOV-06
    2 MANAGER 01-NOV-06
    1 SALESMAN 01-OCT-06
    2 MANAGER 01-OCT-06
    1 CLERK 01-SEP-06
    1 HOUSEKEEPING 23-SEP-06
    How do I select the first date that empno=1 was a 'SALESMAN'? In the above table, he was a 'SALESMAN' first on '01-OCT-06' and was 'HOUSEKEEPING' before this?
    *Basically how do i retrieve empno=1 his first REL_DT for his CURRENT job title?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • PL/SQL Looping a table and copying some values to another one...

    hi all!!!
    i'm totally new to pl/sql, and i need to create an interaction to do the following..
    my scenario is:
    i have a table called "references" that contains 2 columns (new_id, old_id).
    then i have another table called "ref" which also contains 2 columns (old_id, other_id).
    ok the point is this:
    in the table references i have stored the references between 2 products (the old one and the new one) by storing their ids.
    now what i have to do by knowing this, is to insert in the table "ref" a new entry for every old_id that is already stored there, but changing it with the new_id that i can get from the other table (references).
    let's see an example:
    table references:
    new_id - old_id
    11 - 3
    12 - 7
    13 - 5
    table ref:
    old_id - other_id
    3 - tu7r
    7 - asduih
    7 - anotherone
    7 - 44444
    5 - 6754f
    so the result that i want is that the new ids (11,12,13) has to be copied to the table "ref" with the same "other_id" as their correspondants in "references" table.. the result would be:
    table ref:
    old_id - other_id
    3 - tu7r
    7 - asduih
    7 - anotherone
    7 - 44444
    5 - 6754f
    11 - tu7r
    12 - asduih
    12 - anotherone
    12 - 44444
    13 - 6754f
    i don't know how to build up a loop or something to reach this aim!!
    thanks for your time guys!!!
    Edited by: ElMazzaX on Nov 17, 2011 3:15 PM

    You do not need pl/sql to do this.
    If I understand your datamodel correctly, this join will get you those records you need to insert:
    select
    references.new_id, ref.other_id
    from references
    join ref
       on ref.old_id = references.old_id;Try that select - it it works, then you can simply do:
    insert into ref (old_id, other_id)
    select
    references.new_id, ref.other_id
    from references
    join ref
       on ref.old_id = references.old_id;SQL is quite enough - no PL/SQL loop necessary ;-)

Maybe you are looking for

  • Regarding work flow in MM - really urgent

    Hi friends, Iam new to workflow. Iam trying to create a  simple wf that should be triggered when ever a new material is created  and send a mail to the initiator. I did the following steps. 1)created an activity .In that task i have attached a busine

  • TS3274 iPad has a vertical line on the screen ?

    Monitor has a constant vertical line and does go go away

  • WD ABAP: Problems with localhost netweaver

    Hi, first of all I'm not very sure of that I'm asking my question in the right group so I would like to apologize for any inconvenience. I'm working with the sneak preview of the sap netweaver (abap version), I've installed succesfully in a computer

  • Caching in kodo

    Hi, We are using tomcat 4.0 for our application.We have jsps and java classes.I wanted to know that if we intend to use caching, can we use in our current environement. I mean, are EJBs compulsory to use caching. And do we have to use the Id class fo

  • Can't see itunes

    My itunes does not display correctly, here is what it looks like - http://koeltzow.googlepages.com/itunes I have reinstalled itunes twice with two different versions and reinstalled my video drivers, and I still get the same results. Can anyone think