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.

Similar Messages

  • 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)

  • Comparing each value of two internal tables

    HI  everybody,
    i have two internal tables  itab1 and itab2 same structure
    both r having four fields each and field with values
    now i need to compare the two internal tables
    and if every value of itab1 matches itab2
    then i have to write one select quirie  for the following given description
    compare past and current shipping point
    compare internal_table2 and internal_table3
    if entry in internal_table2 and internal table3 match
    variable_tknum = internal_table2-tknum
    endif.
    for each entry that matches:
    select vlabdata into zi_vlabdata from vlbl where vbeln = variable_tknum and vlbl-vlabtyp = 'ZIBOOKNO'.
    plz give me solution for this
    thanks
    hridhayanjili.

    sort : ITAB1 by f1,f2,f3,f4,
           ITAB2 by f1,f2,f3,f4.
    LOOP AT ITAB1.
      READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1
                                F2 = ITAB1-F2
                                F3 = ITAB1-F3
                                F4 = ITAB1-F4 BINARY SEARCH.
      IF SY-SUBRC = 0.
    *--all the fields of ITAB1 and ITAB2 are matching .
    *--write your logic here
      ELSE.
    *--ITAB1 and ITAB2 records are not matching.
      ENDIF.
    ENDLOOP.
    Regards
    Srikanth
    Message was edited by: Srikanth Kidambi

  • How to compare a ztable and an internal table

    Hi, experts.
    I have a transparent table ztable and an internal table itab, with same fields. What I need to do is: if those records in itab are not existing in ztable, append them to ztable; if these records in itab has been existing in ztable, update them in ztable.
    How to write codes to do above task in ABAP program?
    Thank you very much.
    Tom

    Hi
    DATA : itab1 type ztable.
    if values in itab not in itab1.
    append itab values to itab1.
      endif.
    if values exist in itab and itab1.
    modify itab1 with respect to itab
    endif.
    finally
       modify ztable from itab1.

  • 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

  • How to compare two rows in PL/SQL?

    Hi All,
    How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?
    Any feedback would be highly appreciated.

    PhoenixBai wrote:
    Hi All,
    How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?What "rows" are you referring to?
    If you're talking of rows within a PL/SQL associative array there are techniques as described in the documentation... e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type v1 is table of number;
      3    r1 v1 := v1(1,2,4);
      4    r2 v1 := v1(1,2,3);
      5  begin
      6    if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
      7      dbms_output.put_line('Same');
      8    else
      9      dbms_output.put_line('Different');
    10    end if;
    11* end;
    SQL> /
    Different
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type v1 is table of number;
      3    r1 v1 := v1(1,2,3);
      4    r2 v1 := v1(1,2,3);
      5  begin
      6    if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
      7      dbms_output.put_line('Same');
      8    else
      9      dbms_output.put_line('Different');
    10    end if;
    11* end;
    SQL> /
    Same
    PL/SQL procedure successfully completed.
    SQL>If you're talking about rows on a table then you can use the MINUS set operator to find the rows that differ between two sets of data...
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    14 rows selected.
    SQL> select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    7 rows selected.
    SQL> select * from emp
      2  minus
      3  select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
    7 rows selected.If you actually need to know what columns data is different on "non-matching" rows (based on your primary key) then you'll have to compare column by column.

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • 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

  • How to log the messages in an internal table n display

    Hello guys,
    This is my first post in SDN.
    I am uploading some data from application server. I am doing lot of varifications, based on that I have to display the messages.
    So I asked not to use the write statements to display the messages but asked me to create an internal table and display the messages afterwards..
    like I am using some BAPI to upload after the bapi call i have to log the result for each record into an internal table and show...
    can anyone guide me how to do it?

    Thanks for your info Azad,
    here I am posting my code... can u go through it once and lemme me whether i am in right track or not?
    FORM FORM_POST_DATA.
      IF X_POST = 'X'.
        CALL FUNCTION 'BAPI_ACC_BILLING_POST'
          EXPORTING
            DOCUMENTHEADER          = WA_DOCUMENTHEADER
           CUSTOMERCPD             = WA_CUSTOMERCPD
    IMPORTING
      OBJ_TYPE                =
      OBJ_KEY                 =
      OBJ_SYS                 =
          TABLES
            ACCOUNTRECEIVABLE       = IT_ACCOUNTRECEIVABLE
            ACCOUNTGL               = IT_ACCOUNTGL
            ACCOUNTTAX              = IT_ACCOUNTTAX
      CRITERIA                =
      VALUEFIELD              =
            CURRENCYAMOUNT          = IT_CURRENCYAMOUNT
            RETURN                  = IT_RETURN
      SALESORDER              =
      SALESAMOUNT             =
           EXTENSION1              = IT_EXTENSION1
        LOOP AT IT_RETURN.
          MOVE-CORRESPONDING IT_RETURN TO IT_MESSAGES.
        ENDLOOP.
      ENDIF.
    WRITE: / 'Result of Post:'.
      WRITE : / REF_TYPE,REF_KEY,REF_SYS.
      PERFORM FORM_SHOW_MESSAGES.
    ENDFORM.              "FORM_POST_DATA
    FORM FORM_SHOW_MESSAGES.
      IF IT_RETURN[] IS INITIAL.
        WRITE: / 'no messages'.
      ELSE.
        SKIP 1.
        LOOP AT IT_RETURN.
          WRITE: /    IT_RETURN-TYPE,
                 (2)  IT_RETURN-ID,
                      IT_RETURN-NUMBER,
                 (80) IT_RETURN-MESSAGE,
                    IT_RETURN-LOG_NO
                    IT_RETURN-LOG_MSG_NO
                    IT_RETURN-MESSAGE_V1
                    IT_RETURN-MESSAGE_V2
                    IT_RETURN-MESSAGE_V3
                    IT_RETURN-MESSAGE_V4
                 (20) IT_RETURN-PARAMETER,
                 (3)  IT_RETURN-ROW,
                      IT_RETURN-FIELD.
                    IT_RETURN-SYSTEM
        ENDLOOP.
      ENDIF.
      ULINE.
    ENDFORM.                               " Show_messages
    Nisha...

  • How to do parallel processing with dynamic internal table

    Hi All,
    I need to implement parallel processing that involves dynamically created internal tables. I tried doing so using RFC function modules (using starting new task and other such methods) but didn't get success this requires RFC enabled function modules and at the same time RFC enabled function modules do not allow generic data type (STANDARD TABLE) which is needed for passing dynamic internal tables. My exact requirement is as follows:
    1. I've large chunk of data in two internal tables, one of them is formed dynamically and hence it's structure is not known at the time of coding.
    2. This data has to be processed together to generate another internal table, whose structure is pre-defined. But this data processing is taking very long time as the number of records are close to a million.
    3. I need to divide the dynamic internal table into (say) 1000 records each and pass to a function module and submit it to run in another task. Many such tasks will be executed in parallel.
    4. The function module running in parallel can insert the processed data into a database table and the main program can access it from there.
    Unfortunately, due to the limitation of not allowing generic data types in RFC, I'm unable to do this. Does anyone has any idea how to implement parallel processing using dynamic internal tables in these type of conditions.
    Any help will be highly appreciated.
    Thanks and regards,
    Ashin

    try the below code...
      DATA: w_subrc TYPE sy-subrc.
      DATA: w_infty(5) TYPE  c.
      data: w_string type string.
      FIELD-SYMBOLS: <f1> TYPE table.
      FIELD-SYMBOLS: <f1_wa> TYPE ANY.
      DATA: ref_tab TYPE REF TO data.
      CONCATENATE 'P' infty INTO w_infty.
      CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
      ASSIGN ref_tab->* TO <f1>.
    * Create dynamic work area
      CREATE DATA ref_tab TYPE (w_infty).
      ASSIGN ref_tab->* TO <f1_wa>.
      IF begda IS INITIAL.
        begda = '18000101'.
      ENDIF.
      IF endda IS INITIAL.
        endda = '99991231'.
      ENDIF.
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = pernr
          infty           = infty
          begda           = '18000101'
          endda           = '99991231'
        IMPORTING
          subrc           = w_subrc
        TABLES
          infty_tab       = <f1>
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        subrc = w_subrc.
      ELSE.
      ENDIF.

  • How to process each records in the derived table which i created using cte table using sql server

    I want to process each row from the CTE table I created, how can I traverse from first row to second row and so on....
    how to process each records in the derived table which i created using  cte table using sql server

    Ideally you would be doing a set based processing rather than traversing row by row as thats more efficient. To answer it specific to your scenario we may need more info. Can you explain with some sample data your exact requirement?
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to get the row count of a Table DATA?

    Hi,
      In my Adobe form layout, I have a Table node which is bound to an internal table. Now at runtime, I want to determine the number of rows that the internal table has, i.e the row count of the DATA node of the Table. How will I be able to determine the no. of rows of the internal table at runtime using Javascript? I am not being able to find any suitable answer in this forum. Please suggest. Thanks in advance.

    Hi,
    If you bind the interactive form table to the internal table and specify some properties, the table will vary its row size according to the number of data available in the internal table.
    You have to wrap the table in a sub form,  check 'allow page break with contents' and property 'flowed'.
    the table will automatically increase its row size...
    Is this the reason for which you wanted for the row count..?
    If so, this will help you..
    Regards.
    Surya

  • Compare two rows in a same table

    Dear all
    I need to compare two rows in the same table, I dont know hoe to do it in pl/sql. Some one please help me on this.
    example:
    tr br price
    xya0001 ama7 12
    xya0003 ama6 14
    xya0004 ama7 16
    in the table tr is a unique value for each row, I need to compare price column and see whether the first value is less or greater than the next value and, if it is greater put the corresponding br value to a variable and if it is smaller put the corresponding br value to another variable. I dont know a method to do it, as I'm new to pl/sql. Some one please help me in this

    not sure what you intend to do as you have mentioned that "TR" is unique and you just want to compare each record with just the next record. Hope below query helps. The value "G" or "L" in flag would indicate if the current records price is greater than or less than the price in next record.
    select tr,br,price,col4, case when price> col4 then 'G'  when price< col4 then 'L' end flag from (
    select tr,br,price,lag(price,1,0) over(order by tr) col4 from testcomp
    )

  • 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

Maybe you are looking for

  • Error message requesting a plugin for IE Tab V2

    I'm running Firefox 5 on a Ubuntu 10.10 Maverick Meerkat OS with the IE Tab V2 extension. Every time I try to open a site in the tab, I get a message saying I have to install a plugin for it to work. I click the "Install Missing Plugins" button then

  • Crop marks non-functional in CS5

    I was given an 8.6"x11.1" PS doc to be printed with a full bleed, down to 8.5x11. When I set the crop marks, they appear correctly on-screen in the print preview, and their locations clearly change based on the dimensions I input in setup, but, when

  • Retrieving Images Embedded In XML (from rss using xsl)

    I am trying to comsuem and rss feed into my site but i dont seem to see an "image" element in the Item node. can someoen tell me how to retrieve Images Embedded In XML dreamwaever. i am using an xsl fragment on a pap server. Doh

  • Get DDL of objects in another schema without access to their content

    Hi, is there any object privilege which could be granted to a user A so that he can get only the user's B object definitions (DDL) but without accessing their content or executing them (in case of packages/procedures/functions)? E.g. to get the user

  • Additional PDF file conversion

    HI All, I see that Adobe XI doesn't convert Outlook files (.PST), is there a way to buy bolt/add on's that would allow for the expansion of file types that XI will convert? Would you know if there are any other tricks/add ons that Adobe can do with r