Current row number in internal table

HI,
How to find current number of record in internal table which is being processed.
Srini.

Hi Srinu,
Welcome to SDN...
The system field <b>SY-TABIX</b> will give the current number of record in an internal table.
If the internal table is iterated through LOOP...ENDLOOP then for each iteration the SY-TABIX will be incremented by one.
If the internal table is iterated through LOOP...ENDLOOP  WHERE <COND> then for each iteration the SY-TABIX will hold the condition met record number.
READ TABLE ITAB WITH KEY F1=<VAL> . The SY-TABIX will hold the record number of success record.
Thanks,
Vinay

Similar Messages

  • CONVERTING ROWS OF AN INTERNAL TABLE TO COLUMNS OF ANOTHER INTERNAL TABLE

    Hi,
    I hv an internal table itab as below with 3 columns.
      name           age         place
      sandeep       24           delhi
      ajay             22           bangalore
      abhishek      25           mumbai
    internal table itab can have any number of rows.
    from this internal table i want to make another internale table itab_new as
    sandeep     ajay            abhishek
    24              22                 25
    delhi          bangalore       mumbai
    thanks

    Hi,
    Check this example:
    data:p_temp(30)  TYPE c value 'ztmp_projectreport'.
    *data declaration
    DATA: it_tab TYPE filetable,
          gd_subrc TYPE i,
          answer TYPE c.
    TYPES: BEGIN OF t_abapcode,
      row(72) TYPE c,
    END OF t_abapcode.
    DATA: it_abapcode TYPE STANDARD TABLE OF t_abapcode INITIAL SIZE 0.
    data:it_prps like prps occurs 0 with header line.
    data:colum(20) type c.
    data:ncol type i.
    data:ccol type c.
    select * into corresponding fields of table
      it_prps from prps where
    append 'report ztmp_projectreport' to it_abapcode.
    append 'data:begin of it_prps2,' to it_abapcode.
    ncol = 1.
    loop at it_prps.
      ccol = ncol.
      concatenate 'colum' ccol '(20)' into colum.
      concatenate colum 'type c,' into it_abapcode.
      add 1 to ncol. 
    endloop.
    append 'data:end of it_prps2.' to it_abapcode.
    'All your code here to fill the internal table and alv grid
    'End of all your code
    INSERT REPORT p_temp FROM it_abapcode.
          SUBMIT (p_temp) AND RETURN.
          DELETE REPORT p_temp.
    Please provide points

  • Merging of multiple rows in an internal table as a single record

    Hi All,
    I have an internal table which has the following columns:
    text, date, time, user.
    it stores notes in the internal table.
    The problem is...when I save a note with multiple lines and spaces it saves each line of the note as a row in the internal table.
    Thus i get more no. of rows in the internal table compare to the no. of rows!
    I need to store each notes as single row in the internal table.
    Please advise how to approach this?
    Helpful answers will be rewarded.
    Thanks & Regards,
    Anshumita.

    You can create a deep internal table. You can declare one Column as an internal table and store the NOTES in that Internal table for each row.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    you can check the example in the link
    regards,
    abhishek

  • SWAP COLUMNS AND ROW IN AN INTERNAL TABLE to display in ALV

    Hi ,
    I want to swap all the rows in an internal table with the column of the internal table to display it horizontally in ALV grid.
    e.g
    1     2   3  (field names)
    A    P   X
    B    Q   Y
    C    R    Z
    should look like :
    D       A   B     C
    E      P   Q    R
    F       X    Y    Z
    Where D , E, F in first column is already apended in new table.
    Or else is there a way to rotate the ALV grid so that it can display rows as columns & columns as rows.
    regards

    hi,
    i have an internal table which is like
    f1  f2 f3  f4 (column header)
    A  1  2   3
    B  4  5   6
    C  7  8   9
    the values in o/p table should be
    A B C  ( column header)
    1  4 7 
    2  5 8
    3  6 9
    Please help!!

  • How to process a block for each row in an internal table....

    Hi experts....
    In po approval workflow the scenario is like this.... for each po there may be more than one approver. approvers list i am maintaining in the ztable. list of approvers(no of approvers) is decided by the po value. I have collected these approvers into internal table. now i have to process a block ( approving or rejecting the po... )in the workflow for each row in the internal table.
    how can i do this. based on the decision of the 1st approver  approves the po then it should go to next approver in the internal table...otherwise end the workflow.....
    Please help me......

    i have created an internal table in the workflow container in which i am getting the list of approvers....
    how can i loop the internal table in the workflow...?
    how can i know the index of the loop in the workflow.....(will sy-index work here....? so that i can use loop until step in the main workflow to call the subworkflow..so that if sy-index is greater than no of entires in the itab then i can come out of the loop)

  • Read first row of the internal table

    Dear All,
    Please let me know how to read the first row of the internal table?
    I used following read statement but it is not working
    READ TABLE t_cdhdr INDEX 1.

    Hi,
    i think you are not reading an internal table
    according to your code i think you are reading a type
    which may be declared as types...
    types are declared just for reference
    eg
    types: begin of t_cdhdr .
    include strucuture  cdhdr .
    types: end of t_cdhdr .
    types: t_it_cdhdr type standard table of t_cdhdr.
    data: git_t_cdhdr  type t_it_cdhdr.
    data: gwa_t_cdhdr type t_cdhdr.
    now have to fill the iternal table
    and
    read table git_t_cdhdr into gwa_t_cdhdr index 1.
    reward points if helpful
    thanks & regards,
    venkatesh

  • No. of  Rows in an internal table

    Dear Friends,
    Please let me know which ABAP System Field shall give me the no. of rows in an internal table. If it is sy-dbcnt kindly provide an example on how to use it in a program.
    Regards,
    Alok.

    Hi Alok,
    Use the Describe Statement.
    Sample Program :
    *TABLES ZVIJIRANK.
    *DATA : BEGIN OF IT OCCURS 10.
    *INCLUDE STRUCTURE zvijirank.
    *DATA : END OF IT.
    *data : lines1(4) type n,
          knd type c,
           n type i.
    *select * from zvijirank into table it.
    **describe table zvijirank lines lines1. -
    > Describe statement is only used for Internal Tables.....
    *write : / 'BEFORE DESENDING'.
    *LOOP AT IT.
    *WRITE : / IT-REG_NO , IT-NAME.
    *ENDLOOP.
    *ULINE.
    *describe table it lines lines1. "-----> To find No Of lines
    Write : lines1.
    Thanks.
    Message was edited by:
            Viji

  • Create an internal table with the rows of another internal table.

    Hi I want to know if posible to create an internal table structure with the  rows of another internal table?
    ex.
    If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
    Now I want that the structure of my internal table be: first, second, third

    Hi,
    If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
    Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
    Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
    Data: begin of second_table occurs 0,
    first type <first_table type>,
    second type <first_table type>,
    third type <first_table type>,
    end of second_table.
    Regards
    Prasenjit

  • Row number in pivot table

    Hi all,
    how can I add row number in pivot table? I tried with count but it is not working.
    Thanks

    Example (pivot):
    Rcount (1 by channel class) -> (ROWS)
    or
    Rcount(year by channel class) -> (ROWS)
    Year -> (ROWS)
    Channel Class -> (COLUMNS)
    Quantity Sold -> (MEASURES)
    ------------------------------QUANTITY SOLD
    Rcount-----Year--------Direct/Indirect/Others
    1 ------------2000 ----------10------40------40
    2 ------------2001 ----------50------20------40
    3 ------------2001 ----------80------50------40
    Regards
    Goran
    http://108obiee.blogspot.com

  • Count rows in an internal table

    Anybody how knows how I can count rows in my internal table?

    Hi,
    Data: lines like sy-tabix.
    DESCRIBE TABLE ITAB LINES LINES.
    where itab is your internal table.
    This will work out.
    Please award sutiable points .
    Regards,
    Irfan

  • Delete row in an internal table

    Hi,
    with key1 and key2 how do I delete a row in an internal table itab?
    I want to do something like (but dont succeed) this:
    DELETE itab WHERE x = key1 AND y = key2
    thanks in advance

    Hi Baran,
    Please try like this.
    DELETE TABLE itab WITH TABLE KEY x = key1
                                     y = key2.
    Regards,
    Ferry Lianto

  • Row number in the table.

    Hi:
    How can get the row number in its table?
    For example:
    I have table a:
    a1-a2
    5---a
    2---b
    7---c
    3---d
    I want for a1 value 7, I want to get 3 (the row number in the table).
    Regards
    Saad

    > You know there is ROWID, is there a way to know row number in the table by ROWID?
    No. ROWID is the physical address of the row. It specifies the location of the row on disk. Nothing more. There is no numbering involved.
    > Should there is a way, because there is some programs deal with the table row as it in
    the table.
    These programs are wrong.
    > Ok, I have a software (SmartCodeStudio) which deal with the database to print rows from
    a table but he deals with "record" which is row number in the table
    Wrong, wrong, wrong. A RDBMS is not a binary flat file. A row in a relational table is identified by its primary key. Period.
    There seems to be nothing smart about SmartCodeStudio if it is not capable of dealing with a relational design, and primary key identifiers.

  • How to set text and background color of current row in a adf table?

    Hi,
    In jdev 11.1.2.3,
    How to set text fond and background color of current row in a adf table?
    I tried to set Background color in table property, but that is not what i want.
    Thanks.

    Hi,
    We almost had the same requirement, but we just needed to color a specific column.
    Here goes the solution to that, you might do the same for your row highlighting
    Changes are required in jsff and one method to be added in backing bean
    1. JSFF :
    <af:column headerText="Amount"
                     id="c4" width="100"
                     inlineStyle="#{backingBeanScope.BackingBean.cellColor}">2. Backing Bean
    //searchResultTableVO is Table's VO
    public String getCellColor() {
          FacesContext ctx = FacesContext.getCurrentInstance();
          ExpressionFactory ef = ctx.getApplication().getExpressionFactory();
          ValueExpression ve = ef.createValueExpression(ctx.getELContext(), "#{row}", FacesCtrlHierNodeBinding.class);
          FacesCtrlHierNodeBinding node = (FacesCtrlHierNodeBinding)ve.getValue(ctx.getELContext());
          Row row = node.getRow();
        if(row.equals(searchResultTableVO.getCurrentRow())){
    //You can add your inline style for font-style too
          return "background-color:Red;";
             return null;
      }Hope this is helpful :)
    Regards,
    Neha..

  • How to compare each row in an internal table

    Hi,
    Say I have an internal table with 3 fields in each row, num1, num2, num3, each type of integer i, now I want to get the maximum of num1, num2, num3 and put this maximum number into num4, may I know how can I do that? Also, if say I need to pull out this num4 and play around with it, sould I just loop it into my workarea of internal table and assign a variable for whatever that is in the work area? Thanks a lot!
    Regards,
    Anyi

    Hi,
    Inside a loop of the table compare each field like this:
    loop at itab.
    l_num4 = itab-num1.
    if l_num4 < itab-num2. l_num4 = itab-num2. endif.
    if l_num4 < itab-num3. l_num4 = itab-num3. endif.
    Here you can play with the maximum number
    itab-num4 = l_num4.
    modify itab.
    endloop.
    You can also do the same using field-symbols (it's faster to assignations) :
    loop at itab assigning <a>.
    endloop.
    Regards.

  • Get records number from internal table with condition.

    Internal table itab got more than 1000 records,now i need to get the number of records with condition that itab-field1 = 'XXXX'.
    actully, i got an inefficient logic to count the number in a loop statement. is there better way to implement it?

    hello,
    Every time assigning data into temp table and delete may that may not be much efficient. You can check in loop logic how much time is taken. You can check the below code. here I am trying to check the numbers of plant for for one material.
    In this logic material is the first field. So if there is option to make the required field in to the 1 st position then it will be nice.
    TYPES: BEGIN OF x_count,
            matnr TYPE matnr,
            count TYPE i,
           BEGIN OF x_count.
    DATA: i_marc  TYPE STANDARD TABLE OF marc,
          i_count TYPE STANDARD TABLE OF x_count,
          wa_count TYPE x_count.
    FIELD-SYMBOLS: <wa_marc> TYPE marc.
    SELECT * UP TO 1000 ROWS
      FROM marc
      INTO TABLE i_marc.
    IF sy-subrc = 0.
      SORT i_marc BY matnr.
      LOOP AT i_marc ASSIGNING <wa_marc>.
        wa_count-count = wa_count-count + 1.
        AT END OF matnr.
          wa_count-matnr = <wa_marc>-matnr.
          APPEND wa_count TO i_count.
        ENDAT.
      ENDLOOP.
    ENDIF.
    Thanks
    Subhanakr

Maybe you are looking for