How to append records between two internal tables

hi all,
im trying to append from an internal table to another internal table with same structure. i tried the following but it overwrites previous contents of i_dest:
move i_src to i_dest
thanks,
sid

hey u try to move it record by record
<b>itab2 = itab.
append itab2.</b>
This should work I guess
just check the code below, if u want to move the whole itab into itab2 then use <b>itab2[] = itab.</b>
<b>loop at it_pgm.
  read table itab with key obj_name = it_pgm-pgm_name.
  if sy-subrc = 0.
    itab_final-obj_name = itab-obj_name.
    itab_final-func_spec = itab-func_spec.
    itab_final-func_area = itab-func_area.
    itab_final-dev_class = itab-dev_class.
    append itab_final.
else.
   itab_alt-pgm_name = it_pgm-pgm_name.
   append itab_alt.
  endif.</b>
please reward points if found helpful

Similar Messages

  • How to get records into two internal tables from 1 internal table?

    VERME                                                                     LGPLA
    252.000  EA  300     0149A                                  410     0149
    276.000  EA  300     0149A                                  410     0107
    516.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    I have above records in my one internal table ITAB.
    I want to divide these records in to two internal tables ITAB1 and ITAB2. and this is based on LGPLA and VERME.
    If there is same LGPLA (last column) and different VERME (1st column) available, then it should append ITAB1
    Otherwise it should append ITAB2.
    ITAB1 should contain ,
    516.000  EA  300     0149A                                  400     3013
    ITAB2 should contain ,
    252.000  EA  300     0149A                                  410     0149
    276.000  EA  300     0149A                                  410     0107
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    I have tried with this code
    Loop at itab….
    IF lv_prev_lgpla = wa-lgpla and lv_prev_verme <> wa-verme.
          APPEND wa TO itab1.
    else.
          APPEND wa TO itab2.
    endif.
    lv_prev_lgpla = wa-vlpla.
    lv_prev_verme = wa-anfme.
    Endloop.
    But it contains,
    516.000  EA  300     0149A                                  400     3013
    in table ITAB2 which I don’t want.
    Points rewarded soon.
    Regards,
    Ronn

    Dear Ronny,
    i am gining the solution below.But would request you to change your ITAB STRUCTURE LIKE THIS BEFORE USING THE CODE
    VERME LGPLA
    252.000 EA 300 0149A  0149 410
    276.000 EA 300 0149A  0107 410
    516.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    then do as follows.
    SORT ITAB BY LGPLA VERME.
    LOOP AT ITAB INTO WITAB.
    W_INDEX = SY-TABIX.
    here take all the abOve fields in temp fieds.
    LW_VERME = WITAB-VERME..AND SO ON.
      AT END OF LGPLA.
       MOVE: all LW fields to work area of ITAB1
       APPEND work area of ITAB1 TO ITAB1.
       DELETE ITAB INDEX W_INDEX
      ENDAT.
    ENDLOOP.
    Basically what u r doing here is thet u r using processing event.
    So whenerv VERME changes this event will be triggered.
    Just try this out...something like this only will be he logic.
    Please let me know further

  • How to pass data between two internal sessions using ABAP memory?

    Hi,
    How to pass data between two internal sessions using ABAP memory?
    It would be fine if you could explain with an example.
    And also let me clear about the data passing between two main sessions and two external sessions with specific examples.
    Thanks.

    Hi ,
      check the example.
    Reading Data Objects from Memory
    To read data objects from ABAP memory into an ABAP program, use the following statement:
    Syntax
    IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.
    This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.
    You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.
    In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.
    PROGRAM SAPMZTS1.
    DATA TEXT1(10) VALUE 'Exporting'.
    DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
    DO 5 TIMES.
      ITAB-BOOKID = 100 + SY-INDEX.
      APPEND ITAB.
    ENDDO.
    EXPORT TEXT1
           TEXT2 FROM 'Literal'
      TO MEMORY ID 'text'.
    EXPORT ITAB
      TO MEMORY ID 'table'.
    SUBMIT SAPMZTS2 AND RETURN.
    SUBMIT SAPMZTS3.
    The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)
    Example for SAPMZTS2:
    PROGRAM SAPMZTS2.
    DATA: TEXT1(10),
          TEXT3 LIKE TEXT1 VALUE 'Initial'.
    IMPORT TEXT3 FROM MEMORY ID 'text'.
    WRITE: / SY-SUBRC, TEXT3.
    IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.
    WRITE: / SY-SUBRC, TEXT1.
    Example for SAPMZTS3:
    PROGRAM SAPMZTS3.
    DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
    IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
    LOOP AT JTAB.
      WRITE / JTAB-BOOKID.
    ENDLOOP.
    The output is displayed on two successive screens. It looks like this:
    and
    The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.
    The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.
    Pls. reward if useful.....

  • How to delete records from dynamic internal table.

    Hi Experts,
    Need urgent help!!!
    Issue is with Dynamic internal tables.
    Below is code written by me :
    FORM select_query USING Lw_tabnam
                      TYPE  t682i-kotabnr.
      DATA :  lw_line  TYPE REF TO data,
              lw_line1 TYPE REF TO data.
        CREATE DATA Lw_line    TYPE (lw_TABNAM).
        ASSIGN      Lw_line->* TO   <WA_tbl>.
        CREATE DATA LW_LINE    TYPE STANDARD TABLE OF (Lw_tabnam)
                               WITH NON-UNIQUE DEFAULT KEY.
        ASSIGN      Lw_line->* TO <TBL>.
        SELECT * FROM  (Lw_tabnam)
                 INTO CORRESPONDING FIELDS OF TABLE <TBL>
                 WHERE (t_keys).
    Endform.
    code is working fine.
    here even the table name and where condition are dynamic,everything is fine upto this point.
    Now i have to delete some record from <TBL> based on some conditons.
         for ex : ( here lc_fieldname is KUNNR)
          loop at t_kunnr.
              lw_tabix = sy-tabix.
            Read table <tbl>
                    with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.
            If sy-subrc = 0.
            *Delete
            delete <tbl> from <wa_tbl>
    delete <tbl> index  lw_tabix.
            Endif.
         Endloop.
    The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.
    Can you help me ab't how to delete records in Dynamic internal table?
    Other option that i am thinking of is to create a static table of type dynamic table.
    means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?
    Thanks in advance ,
    If you have any suggestion ab't this then do let me know.
    bye,
    Gaurav.

    Hi
    I wrote this code and it works fine:
    DATA LW_TABNAM(10) VALUE 'LFA1'.
    DATA : LW_LINES TYPE REF TO DATA,
           LW_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <TABLE> TYPE TABLE,
                   <WA>    TYPE ANY.
    CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN LW_LINES->* TO <TABLE>.
    CREATE DATA LW_LINE TYPE (LW_TABNAM).
    ASSIGN LW_LINE->* TO <WA>.
    DO 10 TIMES.
      APPEND INITIAL LINE TO <TABLE>.
    ENDDO.
    SY-TABIX = 4.
    DELETE <TABLE> INDEX SY-TABIX.
    WRITE SY-SUBRC.
    I hope it help you
    Max

  • Find if there is any common record in two internal tables

    hi,
    I have two internal tables of same structure... say A and B.
    I need to know if there are any common lines in them.
    one way is to loop in any one of them and keep executing a read on the other.
    can anyone suggest a better way.
    thanks,
    Arindam.

    Hi Arindam,
    To find common records in two internal tables, they can be compared
    If INT_DATA1 EQ INT_DATA2.
    endif.
    The first criterion for comparing internal tables is the number of lines they contain. If two internal tables contain the same number of lines, they are compared line by line, component by component.
    If the internal tables contain the same number of records and are sorted on the same key, the comparison stops at the line where the records are not common. For example, if the number of common records is 4, the comparison stops at the 5th line and sy-tabix becomes 5.
    Hope it helps.
    Regards,
    Nupur

  • How to delete the matching records from two internal tables

    Hi ,
    I have two internal tables say A and B of the same type. If A has 10 records and B has 4 records , I want to delete the 4 records in B from A .
    loop at B into wa .
    delete A where key = wa - key .
    endloop.
    takes a long time if the table B is huge. how can I improve the performance.
    Thanks.
    Gayathri

    Hi Gayathri,
    You could try field-symbols. It reduces the data transfer from the internal table B to the work area.
    field-symbols <fs_itab_b> like line of B.
    loop at B assigning <fs_itab_b>.
      delete A where key = <fs_itab_b>?-key.
    endloop.
    Regards,
    <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=zwcc%2fwm4ups%3d">anand Mandalika</a>.

  • Find the difference between two internal table

    how can i see the difference between two interal tables?
    The requirement is as follows
    1. We have a transparent table, which stores the employee data with EMP ID as key.
    2. We load the transp table data into a interal table (B).
    3. We get data from legecy system as file and it gets loaded into another internal table (A) (this also has the same EMP ID key and this will have latest addition/update to those emplyees).
    Now we need to seperate out these data into three interal table Inserted (I), Deleted (D) and Updated (U).
    We want to do followign things
    I = A - B
    D = B - A
    Both A and B will have around 40k records. Hence we are trying to avoid the looping.
    Please suggest the best option for us.
    Thank you in advance.
    Raghavendra

    >
    RAGHAV URAL wrote:
    > how can i see the difference between two interal tables?
    > The requirement is as follows
    >
    > 1. We have a transparent table, which stores the employee data with EMP ID as key.
    > 2. We load the transp table data into a interal table (B).
    > 3. We get data from legecy system as file and it gets loaded into another internal table (A) (this also has the same EMP ID key and this will have latest addition/update to those emplyees).
    >
    > Now we need to seperate out these data into three interal table Inserted (I), Deleted (D) and Updated (U).
    >
    > We want to do followign things
    > I = A - B
    > D = B - A
    >
    > Both A and B will have around 40k records. Hence we are trying to avoid the looping.
    >
    > Please suggest the best option for us.
    >
    > Thank you in advance.
    > Raghavendra
    Hi Raghavendra,
      Currently as of my knowledge, these operations are only possible through LOOPs. But LOOPign can be really fast here if you properly utilize the SORTING, READ with BINARY SEARCH and FIELD-SYMBOLS usage. I would say:-
    Steps for Insert:-
    SORT: A, B.
    LOOP AT A ASSIGNING <WA_A>.
      READ TABLE B WITH TABLE KEY key = <WA_A>-key BINARY SEARCH.
      IF SY-SUBRC NE 0.
        APPEND <WA_A> TO I.
      ENDIF.
    ENDLOOP.
    Steps for Delete:-
    SORT: A, B.
    LOOP AT B ASSIGNING <WA_B>.
      READ TABLE A WITH TABLE KEY key = <WA_B>-key BINARY SEARCH.
      IF SY-SUBRC NE 0.
        APPEND <WA_B> TO D.
      ENDIF.
    ENDLOOP.
    Regards,
    Ravi.

  • How to insert record inside the internal table in below code

    Hi all,
    My requirement is to find the sub-total and need to insert in between the internal table.
    You can see the output ....where I want the sub-total F2 when 1 & 2 combindely , 3 , 4& 5 combindely .Please check it and let me know is it possible
    when i am using modification  it is not creating extra row inside the table instead it is modifying one row and putting the total there.
    For ex: the origianl output is
    F1   F2       F3
    A      1          1
    B      1          1
    F      2          1
    D      3          1
    E      4          1
    C      5          1
    We want to display all the total of f2 of 1-2 , 3 , 4-5
    so expcected output is
    F1   F2       F3
    A      1          1
    B      1          1
    F      2          1
         *              3  ->This is the sub-total of 1& 2 of f2
    D      3          1
            *           1 ->this is the sub-total of 3
    E      4          1
    C      5          1
          *             2 -> this is the sub-total of 4 & 5
    = space
    But coming output is
    A 1          1
    B 1          1
    *             3 -> it is modifying the F row and inserting the total .Total is comong correct but is shoule insert  instead of modifying the record!!
      *           1
    E  4          1
    *             2
    Please help how to insert the row total at the end of the chage of field
    Please find the below code ..Due to space problem i am attaching below
    Sas

    Here is the solution ....i Got the answer Thanks for your helping hands friends
    REPORT  YTEST_MODIFY.
    DATA: BEGIN OF ITAB OCCURS 1,
    TOT TYPE C,
    F1 TYPE C,
    F2 TYPE C,
    F3 TYPE I ,
    END OF ITAB.
    DATA: BEGIN OF JTAB OCCURS 1,
    F1 TYPE C,
    F2 TYPE C,
    F3 TYPE I ,
    END OF JTAB.
    START-OF-SELECTION.
      ITAB-F1 = 'A'.
      ITAB-F2 =  1.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'B'.
      ITAB-F2 =  1.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'C'.
      ITAB-F2 =  5.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'D'.
      ITAB-F2 =  3.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'E'.
      ITAB-F2 =  4.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'F'.
      ITAB-F2 =  2.
      ITAB-F3 =  1.
      APPEND ITAB.
      SORT ITAB BY F2.
      LOOP AT ITAB.
        WRITE:/1 ITAB-F1 ,
              8 ITAB-F2 ,
              10 ITAB-F3 .
      ENDLOOP.
      LOOP AT ITAB.
        IF ITAB-F2 = 1 OR ITAB-F2 = 2.
          ITAB-TOT = 1.
          MODIFY ITAB.
        ELSEIF ITAB-F2 = 3.
          ITAB-TOT = 3.
          MODIFY ITAB.
        ELSEIF ITAB-F2 = 4 OR ITAB-F2 = 5.
          ITAB-TOT = 4.
          MODIFY ITAB.
        ENDIF.
      ENDLOOP.
      SKIP 2.
      SORT ITAB BY TOT.
      DATA : L_SUM(2) TYPE C,
             L_ROW(2) TYPE C.
      LOOP AT ITAB.
        MOVE-CORRESPONDING ITAB TO JTAB.
        APPEND JTAB.
        L_SUM = L_SUM + ITAB-F3 .
        AT END OF TOT.
          CLEAR JTAB.
          JTAB-F3 = L_SUM .
          APPEND JTAB.
          CLEAR L_SUM.
        ENDAT.
      ENDLOOP.
      LOOP AT JTAB.
        WRITE:/1 JTAB-F1 ,
              8 JTAB-F2 ,
              10 JTAB-F3 .
      ENDLOOP.
    *  DATA: a TYPE i , b .
    *  LOOP AT itab.
    *    IF b = 0.
    *      a = a + itab-f3.
    *    ENDIF.
    *    AT END OF tot.
    *      MOVE space TO itab-f1.
    *      MOVE space TO itab-f2.
    *      MOVE a TO itab-f3.
    *      MODIFY itab .
    *      CLEAR a.
    *      b = 1.
    *    ENDAT.
    *    b = 0.
    *  ENDLOOP.
    *  LOOP AT itab.
    *    MOVE-CORRESPONDING itab TO jtab.
    *    APPEND jtab.
    *  ENDLOOP.
    *  ULINE.
    *  LOOP AT jtab.
    *    WRITE: / jtab-f1 , jtab-f2 , jtab-f3.
    *  ENDLOOP.

  • Compare multiple variable selections between two internal tables

    I am trying to work out the syntax for the following, however i am stumped on the 2nd part of the requirement....
    I have two internal tables.  and i need to compare the records.
    1st, line by line, which i can do, however the 2nd requirement, i need to check a range of data against the same table...
    here is an example of the tables:
    Internal Table1 has the following records.
    TL1
    TL2
    TL3
    TL4
    TL5
    TL6
    Internal table 2 has the following records...
    LDOC1     TL1
    LDOC1     TL2
    LDOC1     TL3
    LDOC1     TL7
    LDOC2     TL1
    LDOC2     TL5
    LDOC3     TL6
    LDOC3     TL7
    but for the 2nd requirement, i have to group the LDOC1 (2, 3)  and search for all TL* and report if they all exist, some exist or none exist within the 1st internal table.
    so for requirement 1, the answer would be yes (as i can do a read table using the TL*), however i am not sure how i can check "for all entries" for TL1, Tl2, TL3, TL7 and return that only some entries exist....  LDOC1 should return "some", LDOC2 should return "all" and LDOC3 should return "none".
    Hopefully that makes sense???
    Can someone give me a keyword to investigate as i am not sure the At new would work....  Unless i do an at new and then loop and maybe add the record to a "range" to then compare and log the result as it runs through each result...
    so if Itab1 = itab2 then variable = yes. else None.
    if variable = yes, and itab1 = itab2 then variable = yes.
    if variable = yes and itab1 <> itab2 then variable = some.
    would that work??  i am worried about performance too as there could be 1000's of records....
    and can i have an "at end" so at end, if variable = yes, then variable = all?
    i have written all the rest of the report to get all the data into these tables...  i am just a little baffled as to how i can validate and compare the multiple selection....  :o(

    Hi,
    It is really confusing :-).. But i have tried to figure out.. may be this could be useful for you.
    Internal Table1 has the following records.
    TL1
    TL2
    TL3
    TL4
    TL5
    Internal table 2 has the following records...
    LDOC1 TL1
    LDOC1 TL2
    LDOC1 TL3
    LDOC1 TL7
    LDOC2 TL1
    LDOC2 TL5
    LDOC3 TL6
    LDOC3 TL7
    itab3[] = itab2[]
    sort itab3 by field1.
    delete adjacent duplicates from itab3 comparing field1.
    itab3
    LDCO1 
    LDCO2
    LDCO3
    loop at itab3.
    clear: lv_flag, index, ind.
    loop at itab2 where field1 = itab3-field1.
    index = index + 1.
    read table itab1 with key field1 = itab2-field2.
    if sy-subrc NE 0.
    lv_flag = 'X'.
    ind = ind + 1.
    endif.
    endloop.
    if lv_flag = 'X'.
    if ind = index.
      lv_val = 'NONE'.
    elseif ind NE index.
      lv_val = 'SOME'.
    endif.
    else.
      lv_val = 'ALL'.
    endif.
    "here you can modify itab3 with lv_val in one field, so that you can figure out which is SOME, NONE, ALL
    endloop.
    Regards,
    senthil

  • Data Transfer between two internal tables

    Hi SDN,
    If I have two internal tables itab_a and Itab_b and I want to copy a subset of itab_a to itab_b using a conditional statement, is it possible and how?
    Second, what if I want to append the smaller internal table itab_b to itab_a, how would you do that.
    My task is to take some of the rows from a into b, change one field and append back to a. So if a had 100 rows, now it would have 110.
    Please help.
    Thanks.
    Saf.

    If I have two internal tables itab_a and Itab_b and I want to copy a subset of itab_a to itab_b using a conditional statement, is it possible and how?
    LOOP AT ITAB_A.
      IF ITAB_A-SOME_FIELD = SOME_VALUE.
         MOVE-CORRESPONDING ITAB_A TO ITAB_B.
         APPEND ITAB_B.
      ENDIF.
    ENDLOOP.

  • DIFFERENCE BETWEEN TWO INTERNAL TABLES,THESE TABLES HAVE SAME FILEDS

    TYPES: BEGIN  OF
    TY_AS_UP,
    WERKS  LIKE  
                      MARC-WERKS,
    MATNR LIKE  
                       MARC-MATNR,
    LGORT LIKE  
                      MARD-LGORT,
    LABST(13) TYPE C,             
    (MARD-LABST)
    END OF TY_AS_UP.
    TABLES:
    1) FLAT FILE DATA.:
    DATA: WA_FILEDATA 
                 TYPE TY_AS_UP,
    I_FILEDATA TYPE STANDARD TABLE OF TY_AS_UP INITIAL SIZE 0.
    2) SAP DATA (SELECT QUREY)
    DATA: WA_SAPDATA
                  TYPE TY_AS_UP,
    I_SAPDATA TYPE STANDARD TABLE OF TY_AS_UP INITIAL SIZE 0.
    NOTE:
    I brought data to above table(2) from two internal tables I_MARC and I_MARD .
    My requirement is to display difference between  tables  1) and 2) based on quantity field(MARD-LABST)..
    report layout:
          top-of-page
    plant  diff qty  distri.qty   sap  
    01       -20       30        50  
            end-of-page
              page no 1.
    Kindly help me,it is urgent

    hi micky,
         thanks for your solution.
    another problem:
    I could not understand below
    requirement, could you please
    explain me.
    8)     Format the report based on the display options specified in the selection screen.
    a)     Display option “EQUAL IN QTY” show report lines where the difference is between the distributor file quantity and the SAP quantity is 0.
    b)     Display option “DIFFERENCE IN QTY” show report lines where the difference between the distributor file quantity and the SAP quantity is not 0.
    c)     If both options are selected, show report lines where the difference is both 0 and not 0.
    d)     Display SKUs in the distributors file not found in SAP as “Missing SKUs”
    regards,
    saritha.

  • How to fetch records between two seq uence numbers?

    We have thousands of records with seq uence numbers in the oracle database, we need to retrieve a number of records between two seq uence numbers, i.e. to retrieve records between 100 and 200 seq uence numbers. Could some one help me to find a query to fetch records.
    I'll be waiting for your response..
    Edited by: sumant on Jul 27, 2010 12:42 PM

    Is this is what you are looking for?
    SQL> create table tab1 (id number);
    Table created.
    SQL> insert into tab1 values (1);
    1 row created.
    SQL> insert into tab1 values (2);
    1 row created.
    SQL> insert into tab1 values (3);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from tab1;
            ID
             1
             2
             3
    SQL> select round(dbms_random.value(max(id)+1,max(id)+50)) random_number
      2  from tab1;
    RANDOM_NUMBER
               43
    SQL> select round(dbms_random.value(max(id)+1,max(id)+50)) random_number
      2  from tab1;
    RANDOM_NUMBER
               39
    SQL> select round(dbms_random.value(max(id)+1,max(id)+50)) random_number
      2  from tab1;
    RANDOM_NUMBER
               13 This will generate a random number that will be greater then the maximum value in the table and lower then the maxvalue + 50. Having the range starting from maxvalue in the table you will never get a number generated which already exists in the table.
    As you see in the above number genrated they are all between 4 and 53.
    If you want to increase the range from where the number are generated just increase the value 50 that I used in the query.

  • Cann't move data between two internal table in Unicode program

    Hello expert,
    I import a program from old sap system to new system, but syntax error occurred --- ' L_T_S776[] = T_DATA_RECORDS[]. ',
    it is said ' internal table L_T_S776 and T_DATA_RECORDS are not mutually convertible, in unicode program, two internal tables must have the same structure layout'.
    The coding is:
    DATA: L_T_S776 LIKE S776 OCCURS 0 WITH HEADER LINE.
    DATA: L_T_S777 LIKE S777 OCCURS 0 WITH HEADER LINE.
    FIELD-SYMBOLS: <F_S776> TYPE S776.
    FIELD-SYMBOLS: <F_S777> TYPE S777.
    IF NOT ZCL_USEREXIT=>IS_ACTIVE( PROJN = 11 EXITN = 34 ) IS INITIAL.
      CASE I_RMCP2-SCTYP.
        WHEN 'Z776'.
          L_T_S776[] = T_DATA_RECORDS[].
          LOOP AT L_T_S776 ASSIGNING <F_S776>.
            <F_S776>-ZZCUSER = SY-UNAME.
            <F_S776>-ZZCDATE = SY-DATUM.
            <F_S776>-ZZCTIME = SY-TIMLO.
          ENDLOOP.
         T_DATA_RECORDS[] = L_T_S776[].
        WHEN OTHERS.
      ENDCASE.
    internal table T_DATA_RECORDS is defined to like INDX.
    this program is in function module EXIT_SAPMMCP6_011, it is a user_exit.
    I also confuse the meaning of this part of coding, could anybody help me?
    reward if got useful reply, thank you.
    H.B

    Hi,
    The structure are different thats why you getting this error. But there must be some fields common to which you want to move data. So you change in that way.
    And there will be no impact whatsoever because of such change.
    Regards,
    Atish

  • Can we apply join between two internal tables?

    Itab has fields A,B,C.
    Data: begin of itab occurs 1,
             A  type I,
             B type I,
             C type I,
             End of itab.
    Jtab has fields A, I, J.
    Data: begin of itab occurs 1,
             A  type I,
             I type I,
             J type I,
             End of itab
    The common field between itab and jtab is u201CAu201D.
    Now I need to collect A,B,C,I, J in another internal table ktab.
    How should I be doing this.
    If I use a SELECT query with inner join between itab and jtab it says u201Citab is not a database tableu201D.
    How should I get the result  ktab with A B C I J fields?
    Please help, nay help will be highly appreciated?

    a®s wrote:
    >
    > sort itab_all by A
    > delete adjacent duplicates from itab_all comparing A.
    >
    >
    Do you have the above code in ?
    Here A is common field between both tables, first we are appending itab_1 & itab_2 into table itab_all then deleting the adjacent duplicates from itab_all. then we are reading itab_1 & itab_2 for possible matches and update the same values in itab_all
    so there will NOT be a chance of duplicates in itab_all

  • How to append data from an internal table to an external table.

    HI everyone,
    I am trying to update an DB table type 'c'from the data captured in my internal table. can any one tell me as to how to do this.the contents of the DB table needs to be erased completly before i send in new data.
    Regards,
    Vj

    Assuming that you table has 1 character field(?) besides the MANDT field
    MANDT
    FIELD
    you need to update this db table with values from ITAB which I assume has one field of type c.
    To first delete all of the data from DB table.
    * Yes there are other ways of doing this.
    tables: ztable.
    select * from ztable.
    delete ztable.
    endselect.
    Then simply LOOP your internal table and update the table.
    loop at itab.
      ztable-field = itab-field.
      insert ztable.
    endloop.
    Regards,
    Rich Heilman

Maybe you are looking for

  • How do I open movies made with older versions of iMovie?

    I have newer iMac with iMovie 10.0.02 and would like to open movies created with an older version of iMovie.  I was informed by the people at the Apple Store this could be done.  Does anyone know how?  In the end I would like to create high def copie

  • Spry Validation Text Box - Playing Nicely w/ Javascript

    Greetings- I'm using the Spry Validation Text Fields in a registration form I'm designing. I really like the validation they provide. However, I'm trying to get them to play nicely with a password validation Javascript code that gets called when the

  • Networked Printers on Win XP

    I have an HP Photosmart D7360 connected to my Gateway tablet (running WinXP) via USB Cable. I have enabled printer sharing but do not know how to access the printer from my Macbook Pro over the network. How do I access and then print to that printer

  • Sess_sh sucessful,while deployejb fail

    Hi, I meet two problems when I try to deploy ejb in oracle 8.1.6. 1. when I use sess_sh to test the service,like: sess_sh -u system -p manger -s sess_iiop://machinename:2481:oracle. It sucessfully enter the shell. but when I try to deployejb,use: cal

  • Why can't I hear the phone ring when I call somebody, but if I put the speaker on it works

    Why can't I hear the phone ring when I call somebody, but if I put the speaker on I can hear the ringing?