Copying internal table

hi,
   iam having two internal tables itab1 and itab2.i have to copy contents of table itab1 to itab2 and delete the duplicate entries in itab2.
please provide the code for this.
thanks in advance

If you have defined your tales with the OCCURS 0.
data: itab1 like mara occurs 0 with header line,
itab2 like mara occurs 0 with header line.
itab1[] = itab2[].
sort itab2.
delete adjacent duplicates from itab2.
If you have defined tables with the types than:
data: itab1 type standard table of mara ,
itab2 type standard table of mara .
itab1 = itab2.
sort itab2.
delete adjacent duplicates from itab2.
Regards,
Naimesh Patel
Message was edited by:
        Naimesh Patel

Similar Messages

  • Using Provide-endprovide copy internal table

    Hi,
    I have problem that is if i want to copy the data from infotype to internal table means
    Provide * from p9012 between  pn-begda  and  pn-endda.
    if p9012-zz_client_c EQ itemp-z_client_c.
    MOVE: p9012-begda TO it9012-begda,
               p9012-zz_dept_c TO it9012-z_dept_c,
               SORT IT9012 BY z_dept_c.
               append it9012.
    endif.
    endprovide.
    this one not copying data from infotype to internaltable.
    what i can do?
    Thanks,
    Regards,
    Nandha

    HI Use this code example..
    plz reward poins if it helps you..
    & Report  ZSAPHR_PNP
    Report ZSAPHR_PNP.
    TABLES : PERNR.
    *Infotype Declaration
    INFOTYPES: 0002, "PERSONAL DATA
               0006, "ADDRESS
               0008, "
               0000, "
               0001. "ACTIONS
    DATA : BEGIN OF ITAB  OCCURS 10,  "INTERNAL TABLE DECLARATION
           NACHN  LIKE  P0002-NACHN,
           VORNA  LIKE  P0002-VORNA,
           GESCH  LIKE  P0002-GESCH,
           GBDAT  LIKE  P0002-GBDAT,
           FAMST  LIKE  P0002-FAMST,
           HSNMR  LIKE  P0006-HSNMR,
           STRAS  LIKE  P0006-STRAS,
           LOCAT  LIKE  P0006-LOCAT,
           PSTLZ  LIKE  P0006-PSTLZ,
           LAND1  LIKE  P0006-LAND1,
           PLANS  LIKE  P0001-PLANS,
           ORGEH  LIKE  P0001-ORGEH,
           BET01  LIKE  P0008-BET01,
           WAERS  LIKE  P0008-WAERS,
           PERNR  LIKE  P0000-PERNR,
           END OF ITAB.
    DATA: G_REPID LIKE SY-REPID."Report name
    INITIALIZATION.
      G_REPID = SY-REPID.
      PNPTIMED = 'D'.
    **********************************************START OF
    SELECTION*****************************************
    START-OF-SELECTION.
    GET PERNR.
      PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
        ITAB-PERNR = P0000-PERNR.
        ITAB-NACHN = P0002-NACHN.
        ITAB-VORNA = P0002-VORNA.
        IF P0002-FAMST = '0'.
          ITAB-FAMST = 'S'.
        ELSE.
          ITAB-FAMST = 'M'.
        ENDIF.
        ITAB-FAMST = P0002-FAMST.
        IF P0002-GESCH = '1'.
          ITAB-GESCH = 'M'.
        ELSE.
          ITAB-GESCH = 'F'.
        ENDIF.
        ITAB-GBDAT = P0002-GBDAT.
        ITAB-HSNMR = P0006-HSNMR.
        ITAB-STRAS = P0006-STRAS.
        ITAB-LOCAT = P0006-LOCAT.
        ITAB-PSTLZ = P0006-PSTLZ.
        ITAB-LAND1 = P0006-LAND1.
        ITAB-ORGEH = P0001-ORGEH.
        ITAB-PLANS = P0001-PLANS.
        ITAB-BET01 = P0008-BET01.
        ITAB-WAERS = P0008-WAERS.
        APPEND ITAB.
      ENDPROVIDE.
    END-OF-SELECTION.

  • Copying internal tables

    If I want to copy full contents of one internal table itab1 to another itab2, what is the best method?
    I see,
    Loop at itab1.
    Append itab1 to itab2.
    clear itab1.
    endloop.
    is ok. Is there any other simpler method using assigning etc?
    Thanks.

    hi Nuren,
    1. One way is
    itab2[] = itab1[].
    2. The other way is
    Loop at itab1.
    move-corresponding itab1 to itab2.
    append itab2.
    Endloop.
    Regards,
    Santosh

  • To fetch selective fields from DATABASETABLE into Internal TABLE

    Hi Friends,
    I have declared an internal table with fields for e.g. A , B , C , D.
    This does not have any records as of now.
    I have to fetch data from a DATABASE TABLE with fields A , B , X , Y , Z having records .
    I only need records for fields A B fron DB table.Can any one pls tell how can I do that with performance issues in mind as lots of records are there.
    I had written a query where:
    SELECT A B from dbtab
                        into CORRESPONDING FIELDS of table it_table.
    It_table i had defined with only two fields A B.
    Is this correct?
    Please tell wats the way to do it as I am new to ABAP.
    THANKS in ADVANCE..

    Hi.....
    What mentioned in all above answers is very helpful for ur requirement...
    and...
       Here some Steps to increase the performence of your programs...
    >Use Select Single when only one row is expected
    >Use Select Where rather than Selectu2026Check
    >Use Select with aggregate functions (SUM, MAX, MINu2026)
    >Use a View instead of nested Selects
    >Use Select column specific instead of select * for few fields
    >Use Selectu2026Into Table rather than Select...Move Corru2026Apend
    >Use Join extension with Select if possible
    >Use special operators (CO, CA, CS) rather than code your own
    >Use Delete Adjacent Duplicates rather than manual processing
    >Specify key fields for Readu2026Binary Search
    >Use Loop At Where rather than Loop Atu2026Check
    >Copy Internal Tables with TAB_DEST() = TAB_SRC()
    >Specify the sort key as restrictively as possible
    >Use Append To, Insert Into, Collect Into rather than Move
    >Compare tables with If Tab1() = Tab2()u2026
    >Use Delete ITAB Whereu2026 instead of Loop At ITAB Whereu2026Delete..
    >Use Case statements instead of If-constructions
    >Use Call Functions wisely, Performs use less memory
    >Use While instead of Do Exit
    >Use Type I for Indices
    >Keep Occurs clause realistic or use 0
    >Use COMMIT WORK as appropriate to free the Data Base and preserve work
    >
    >Avoid:
    >Using Shift inside a While-loop
    >Leaving unneeded declarations in your program
    >Using Move-corresponding for just a few fields
    >Excessive nested includes within function calls
    >Using DB field names if the value will be changed
    >Using Occurs clause if only the header is needed
    Thanks,
    Naveen.I

  • Copy a certain row of data into the next row in a same internal table ??

    HI, guys.
    May i know how to copy a certain row of data into the next row in a same internal table ?? Bcz I plan to update a certain colum of data in the row just now into another value..
    For example:-
    *at first...
    ebeln1   ebelp1   xblnr1
    ebeln2   ebelp2   xblnr2
    ebeln3   ebelp3   xblnr3
    *after that, become...
    ebeln1   ebelp1   xblnr1
    ebeln2   ebelp2   xblnr2
    ebeln2   ebelp2   xblnr4
    ebeln2   ebelp2   xblnr5
    ebeln3   ebelp3   xblnr3
    Thanks in advance.

    hi,
    If you have this kind of requirement then you must be having 2 internal tables ,one existing data and 2nd from which you have to insert the records into 1st table.
    so in this case,
    loop at itab1.
      v_index = sy-tabix.
      loop at itab2 into wa where pri_key = itab1-pri_key.
      v_index = v_index + 1.
      insert  wa into itab index v_index.
      endloop.
    endloop.
    Using this code ,your data records similar to your 1st tables primary key records will get inserted into table.

  • Copying data from a table in the Database to an internal table.

    Hello,
    How do I copy data that is a table that is in the database and and then load the data to an internal table in the ABAP/4 Aditor.
    Please help.

    hi,,
    do this way ...
    tables : mara.
    parameters : p_matnr like mara-matnr,
    start-of-selection.
    select <fields>  from mara into table it_mara
         where matnr = p_matnr.
      if sy-subrc = 0.
    endif.

  • Copy columns of an internal table

    hi,
    i want to copy columns of an internal table into another internal table, now i loop the original table to one workarea and then get the field i need, and then append to destination table.
    is there any more effective way ?

    hi,
    use move corresponding statement.
    Example:
    MOVE-CORRESPONDING ADDRESS TO NAME.
    and also use
    <itab2> = <itab1>.
    *if useful reward with points.*

  • Copying Dynamic Internal Table

    Hi All,
            I have created a Dynamic internal table using field symbols.  Now i need to copy that dynamic itab to another internal table, because I am not familiar with field symbols. Can anybody tell me how can i copy that dyn_itab to another itab.
    code which I used to create dyn_table:
    LS_FIELDCATALOG-FIELDNAME = 'CHINA_TOT'.
    LS_FIELDCATALOG-INTTYPE = 'I'.
    append LS_FIELDCATALOG to LT_FIELDCATALOG.
    assign LT_DATA to <FS_DATA>.
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = LT_FIELDCATALOG
         importing
           ep_table = <FS_DATA>
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    if sy-subrc <> 0.
    endif.
    So <FS_1> now points to our dynamic internal table.
    assign <FS_DATA>->* to <FS_1>.
    HERE <FS_1> is a dynamic itab.

    First you need to create another table with the structure that you have.
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = LT_FIELDCATALOG
         importing
           ep_table = <FS_DATA2>
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    field-symbols  : <fs_line1>, <fs_line2>, <fs_tmp1>, <fs_tmp2>.
    assign <FS_DATA2->* to <FS_2>.
    Now FS_1 and FS_2 are the tables.
    Also create work areas for the tables.
    CREATE DATA gw_line1 LIKE LINE OF <fs_1>
    CREATE DATA gw_line2 LIKE LINE OF <fs_2>.
    ASSIGN gw_line1->* TO <fs_line1>.
    assign gw_line2->* to <fs_line2>.
    With field symbols, you cannot move the rows directly, you will have to move it field by field.
    Once all the values are populated in the first table, copy it with the following logic.
    loop at <fs_1> into <fs_line1>
    Loop at   LT_FIELDCATALOG into LS_FIELDCATALOG.
    ASSIGN COMPONENT ls_fieldcatalog-fieldname OF STRUCTURE <fs_line1> TO <fs_tmp1>.
    ASSIGN COMPONENT ls_fieldcatalog-fieldname OF STRUCTURE <fs_line2> TO <fs_tmp2>.
    <fs_tmp2> = <fs_tmp1>
    endloop.
    append <fs_line2> to <fs_2>
    endloop.

  • Copying an  internal table data to a field symbol(only corresponding field)

    Hi,
       Iam having field symbol type standard table which has 4 fields in it already.
    I am having an internal table which has 10 columns in it.
    Now i want to copy the data from internal table to field symbol .But the problem is the fields which are matched in field symbol alone should be copied from the internal table.
    for eg.
    field symbol type table.
    field1.
    field2.
    field3.
    itab type internal table.
    field1
    field2
    field3
    field4
    field5
    field6.
    i want to copy the first 3 fields alone from the internal table itab to the field symbols. Can anyone help me on  how to do this. thanks...
    Regards,
    Rose.

    Hi,
    Chk below example, and match with ur scenario.
    data: begin of itab,
          a , b ,c , d,e,
          end of itab,
          wa like itab,
          jtab like table of itab,
          begin of fsy,
          a, b ,c,
          end of fsy.
    field-symbols:<fs> type any.
         assign fsy to <fs>.
         wa-a = 'x'. wa-b = 'y'. wa-c = 'z'. wa-d = 'r'.
         append wa to jtab.
          loop at jtab into wa.
            move-corresponding wa to <fs>.
          endloop.
    REGARDS,
    SENTHIL KUMAR.S

  • How to copy complete internal table into main dababase table

    please tell me how to copy complete internal table into main dababase table by overwriting all the entries of the main DBtable.

    HI,
    you can use<b> Insert Or  Modify statement ..</b>
    <b>Modify updates the existing record, insert creates a new one. ...</b>
    insert ZDBTAB from table itab.
    Modify ZDBTAB from table Itab.
    The structure of itab should be exactly the same as the z table.
    You should not update standard tables directly though.
    rewards if usefuyl
    regards,
    nazeer

  • How to Copy data from field symbol to Dynamic Internal Table

    Hi,
    I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
    REPORT  ztest.
    DATA:
           gd_dref          TYPE REF TO data,
           gd_dref1          TYPE REF TO data.
    FIELD-SYMBOLS:  <fs1>   TYPE any,
                               <fs_wa> TYPE any,
                                <field>    TYPE any,                  
                                <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
    *Copy data from p_src to p_dest*
    PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                             p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
    *DATA : lt_csks LIKE p_dest WITH HEADER LINE.
    START-OF-SELECTION.
      CREATE DATA gd_dref TYPE (p_src).
      CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
       ASSIGN gd_dref->* TO <fs_wa>.
       ASSIGN gd_dref1->* TO <fs_wa1>.
       SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
    *Write out data from FIELD SYMBOLS TO Table.
       loop at <fs_wa1> into <fs_wa>.
         do.
           assign component  sy-index
              of structure <fs_wa> to <field>.
           if sy-subrc <> 0.
           exit.
           endif.
           if sy-index = 1.
             write:/ <field>.
           else.
           write: / <field>.
           endif.
         enddo.
       endloop.
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    *p_dest is a table having a similar structure to table p_src .
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    EXIT.
    Thanks in Advance.

    try this...
    I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
    Cheers...
    report  ztest.
    data:
      gd_dref type ref to data,
      gd_dref1 type ref to data,
      gd_dref_str type ref to data,
      gd_dref_tab type ref to data.
    field-symbols:
      <fs1> type any,
      <fs_wa> type any,
      <fs1_dest_str> type any,
      <fs_dest_tab> type any table,
      <field> type any,
      <fs_wa1> type any table.
    * contains data from p_src
    *Copy data from p_src to p_dest*
    parameters: p_src like dd02l-tabname default 'vbak',
    * name of dynamic internal table *
                p_dest like dd02l-tabname default 'vbap'.
    * name of dynamic internal table*
    *data : lt_csks like p_dest with header line.
    start-of-selection.
      create data gd_dref type (p_src).
      create data gd_dref1 type table of (p_src).
      assign gd_dref->* to <fs_wa>.
      assign gd_dref1->* to <fs_wa1>.
      select * from (p_src) into corresponding fields of table <fs_wa1>
      up to 3 rows
      where vbeln ne space.
      create data gd_dref_str type (p_dest).
      create data gd_dref_tab type standard table of (p_dest).
      assign gd_dref_str->* to <fs1_dest_str>.
      assign gd_dref_tab->* to <fs_dest_tab>.
    *write out data from field symbols to table.
      loop at <fs_wa1> into <fs_wa>.
        " break-point here - can see vbeln/waers/create date/ etc move over to new structure
        " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
        " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
        break-point.
        move-corresponding <fs_wa> to <fs1_dest_str>.
        insert <fs1_dest_str> into table <fs_dest_tab>.
    **    do.
    **      assign component  sy-index
    **         of structure <fs_wa> to <field>.
    **      if sy-subrc <> 0.
    **        exit.
    **      endif.
    **      if sy-index = 1.
    **        write:/ <field>.
    **      else.
    **        write: / <field>.
    **      endif.
    **    enddo.
      endloop.
      " write out some dest data from the dest table build from previous loop
      loop at <fs_dest_tab> assigning <fs1_dest_str>.
        do.
          assign component sy-index of structure <fs_wa> to <field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <field>.
          else.
            write: / <field>.
          endif.
        enddo.
      endloop.

  • Copy contents of one internal table to another

    Hi,
    I have one internal table IT1 which has following fields HKONT, DMBTR and DESC. Here DESC row is empty and rest of the fields are filled.
    Now there is another IT2 which has DESC field and this is filled.
    I have to copy the IT2-DESC into IT1-desc.
    How to do that?

    Hi Anurodh,
    if u want to collate data from 2 tables, there should be atleast one common field.
    As from ur query i can see that the field in ques id Description of some other field, say F1.
    If i am right, then fetch F1 field in both the tables and then using Loop and Read statements you can add DESC to IT1 table.
    Hope it helps.
    Reward points if useful.
    Regards,
    Preeti

  • Copy data from 4 internal tables

    Hi Experts,
    I need to split a database field into 2 separate fields on the frontend and display it in an alv report.
    For this i used 4 internal tables. first one for regular fields and rest 3 of them for the split fields.
    Now the problem is, if i use 1 loop and insert workarea in it, the second record overwrites the first and if i use 3 internal tables, the looping is improper and it gives me duplicate entries in the report.
    delete adjacent duplicate is also not working.
    i am pasting the code. kindly help.
    thx
    *& Report  YVENDRALVRPTFINAL
    REPORT  YVENDRALVRPTFINAL.
      TYPE-POOLS: SLIS.
        DATA: program LIKE sy-repid.
        DATA: fcat TYPE slis_fieldcat_alv.
        DATA: fieldcat TYPE TABLE OF slis_fieldcat_alv.
        DATA: layout TYPE slis_layout_alv.
        Tables: LFA1,
                LFB1,
                T002T.
    DATA: Begin of itab1 occurs 0,
               LIFNR LIKE LFA1-LIFNR,
               BUKRS LIKE LFB1-BUKRS,
               KTOKK LIKE LFA1-KTOKK,
               ANRED LIKE LFA1-ANRED,
               NAME1 LIKE LFA1-NAME1,
               SORTL LIKE LFA1-SORTL,
             STRAS LIKE LFA1-STRAS, " HOUSE and STREET NUMBER
             STRAS1 LIKE LFA1-STRAS," STREET NUMBER
               PSTLZ LIKE LFA1-PSTLZ,
               ORT01 LIKE LFA1-ORT01,
               REGIO LIKE LFA1-REGIO,
               LAND1 LIKE LFA1-LAND1,
               SPTXT LIKE T002T-SPTXT,
             TELF1 LIKE LFA1-TELF1,
             TELF2 LIKE LFA1-TELF2,
             TELFX LIKE LFA1-TELFX,
             TELTX LIKE LFA1-TELTX,
               SMTP_SRCH LIKE ADR6-SMTP_SRCH,
               STCEG LIKE LFA1-STCEG,
               BRSCH LIKE LFA1-BRSCH,
          END OF itab1.
    DATA: wrkarea1 LIKE LINE OF itab1.
          DATA: Begin of itab2 occurs 0,
               LIFNR LIKE LFA1-LIFNR,
               BUKRS LIKE LFB1-BUKRS,
               KTOKK LIKE LFA1-KTOKK,
               ANRED LIKE LFA1-ANRED,
               NAME1 LIKE LFA1-NAME1,
               SORTL LIKE LFA1-SORTL,
             STRAS LIKE LFA1-STRAS, " HOUSE and STREET NUMBER
             STRAS1 LIKE LFA1-STRAS," STREET NUMBER
               STR LIKE LFA1-STRAS,
               HOU LIKE LFA1-STRAS,
               PSTLZ LIKE LFA1-PSTLZ,
               ORT01 LIKE LFA1-ORT01,
               REGIO LIKE LFA1-REGIO,
               LAND1 LIKE LFA1-LAND1,
               SPTXT LIKE T002T-SPTXT,
              *TELF1 LIKE LFA1-TELF1,
             PHONE  LIKE LFA1-TELF1,
               PHONE_EXT  LIKE LFA1-TELF1,
              *TELFX LIKE LFA1-TELFX,
               FAX LIKE LFA1-TELFX,
               FAX_EXT LIKE LFA1-TELFX,
             * TELTX LIKE LFA1-TELTX,
               SMTP_SRCH LIKE ADR6-SMTP_SRCH,
               STCEG LIKE LFA1-STCEG,
               BRSCH LIKE LFA1-BRSCH,
          END OF itab2.
          DATA: wrkarea2 LIKE LINE OF itab2.
         DATA:    STREET1 TYPE STRING,
                  HOUSE1 TYPE STRING,
                  PHONE1 TYPE STRING,
                  PHONE_EXT1 TYPE STRING,
                  FAX1 TYPE STRING,
                  FAX_EXT1 TYPE STRING.
         DATA:  BEGIN OF ADRDTL,
                HOU TYPE LFA1-STRAS,
                STR TYPE LFA1-STRAS,
                PHONE TYPE LFA1-TELF1,
    *PHONE_EXT  TYPE LFA1-TELF1,
    *FAX TYPE LFA1-TELFX,
    *FAX_EXT  TYPE LFA1-TELFX,
    *END OF ADRDTL.
           DATA: BEGIN OF itabhs occurs 0,
                 HSESTREET LIKE LFA1-STRAS,
                 END OF itabhs.
           DATA: wahs LIKE LINE OF itabhs.
            DATA:  BEGIN OF itabph occurs 0,
                   PHONENPHEXT TYPE LFA1-TELF1,
                   END OF itabph.
            DATA: waph LIKE LINE OF itabhs.
            DATA:  BEGIN OF itabfx occurs 0,
                   FAXNFAXEXT TYPE LFA1-TELFX,
                   END OF itabfx.
            DATA: wafx LIKE LINE OF itabhs.
          DATA: THREE LIKE LINE OF itab2,
                 FOUR LIKE LINE OF itab2.
              DATA:  THREE TYPE  LFA1-STRAS,
              FOUR  TYPE  LFA1-STRAS.
    SELECT-OPTIONS vendor FOR LFA1-LIFNR.
    *parameter vendor type LFA1-LIFNR.
      DATA:  wa LIKE LFA1-STRAS,
             wa1 LIKE LFA1-STRAS,
             wa2 LIKE LFA1-STRAS.
      DATA: BEGIN OF itabhsnew occurs 0,
                 STR LIKE LFA1-STRAS,
                 HOU LIKE LFA1-STRAS,
           END OF itabhsnew.
      DATA: wahsnew LIKE LINE OF itabhsnew.
      DATA: BEGIN OF itabphnew occurs 0,
                 PHONE LIKE LFA1-TELF1,
                 PHONE_EXT LIKE LFA1-TELF1,
           END OF itabphnew.
      DATA: waphnew LIKE LINE OF itabphnew.
      DATA: BEGIN OF itabfxnew occurs 0,
                 FAX LIKE LFA1-TELFX,
                 FAX_EXT LIKE LFA1-TELFX,
           END OF itabfxnew.
      DATA: wafxnew LIKE LINE OF itabfxnew.
    START-OF-SELECTION.
    SELECT LFA1STRAS FROM LFA1 INTO TABLE itabhs where LFA1LIFNR IN vendor.
    LOOP at itabhs into wahs.
    SPLIT wahs AT SPACE INTO STREET1 HOUSE1 .
    MOVE STREET1 TO wahsnew-STR.
    MOVE HOUSE1 TO wahsnew-HOU.
    INSERT wahsnew INTO TABLE itabhsnew.
    ENDLOOP.
    SELECT LFA1TELF1 FROM LFA1 INTO TABLE itabph where LFA1LIFNR IN vendor.
    LOOP at itabph into waph.
    SPLIT waph AT '-' INTO PHONE1 PHONE_EXT1.
    MOVE PHONE1 TO waphnew-PHONE.
    MOVE PHONE_EXT1 TO waphnew-PHONE_EXT.
    INSERT waphnew INTO TABLE itabphnew.
    ENDLOOP.
    SELECT LFA1TELFX FROM LFA1 INTO TABLE itabfx where LFA1LIFNR IN vendor.
    LOOP at itabfx into wafx.
    SPLIT wafx AT '-' INTO FAX1 FAX_EXT1.
    MOVE FAX1 TO wafxnew-FAX.
    MOVE FAX_EXT1 TO wafxnew-FAX_EXT.
    INSERT wafxnew INTO TABLE itabfxnew.
    ENDLOOP.
    *MOVE STREET1 TO ADRDTL-STR.
    *MOVE HOUSE1 TO ADRDTL-HOU.
    *MOVE PHONE1 TO ADRDTL-PHONE.
    *MOVE PHONE_EXT1 TO ADRDTL-PHONE_EXT.
    *MOVE FAX1 TO ADRDTL-FAX.
    *MOVE FAX_EXT1 TO ADRDTL-FAX_EXT.
    SELECT LFA1LIFNR  LFB1BUKRS LFA1KTOKK LFA1ANRED LFA1~NAME1
    LFA1SORTL LFA1PSTLZ LFA1ORT01 LFA1REGIO
    LFA1~LAND1
    T002T~SPTXT
    LFA1TELF1 LFA1TELF2 LFA1TELFX LFA1TELTX
    ADR6~SMTP_SRCH
    LFA1STCEG LFA1BRSCH
    FROM LFA1
    INNER JOIN T002T ON LFA1SPRAS = T002TSPRSL AND T002T~SPRAS = 2
    INNER JOIN LFB1 ON LFA1LIFNR = LFB1LIFNR
    INNER JOIN ADR6 ON LFA1ADRNR = ADR6ADDRNUMBER
    INTO TABLE itab1 WHERE LFB1~LIFNR IN vendor.
    LOOP AT itab1 INTO wrkarea1.
    MOVE-CORRESPONDING wrkarea1 TO wrkarea2.
    *MOVE STREET1 TO wrkarea2-STR.
    *MOVE HOUSE1 TO wrkarea2-HOU.
    *MOVE PHONE1 TO wrkarea2-PHONE.
    *MOVE PHONE_EXT1 TO wrkarea2-PHONE_EXT.
    *MOVE FAX1 TO wrkarea2-FAX.
    *MOVE FAX_EXT1 TO wrkarea2-FAX_EXT.
    *MOVE ADRDTL-STR TO wrkarea2-STR.
    *MOVE ADRDTL-HOU TO wrkarea2-HOU.
    *MOVE ADRDTL-PHONE TO wrkarea2-PHONE.
    *MOVE ADRDTL-PHONE_EXT TO wrkarea2-PHONE_EXT.
    *MOVE ADRDTL-FAX TO wrkarea2-FAX.
    *MOVE ADRDTL-FAX_EXT TO wrkarea2-FAX_EXT.
    *MOVE-CORRESPONDING wahs TO wrkarea2.
    *MOVE-CORRESPONDING waph TO wrkarea2.
    *MOVE-CORRESPONDING wafx TO wrkarea2.
    *MOVE-CORRESPONDING wahsnew TO wrkarea2.
    *MOVE-CORRESPONDING waphnew TO wrkarea2.
    *MOVE-CORRESPONDING wafxnew TO wrkarea2.
    *MOVE itabhsnew TO itab2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    LOOP AT itabhsnew INTO wahsnew.
    MOVE-CORRESPONDING wahsnew TO wrkarea2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    LOOP AT itabphnew into waphnew.
    MOVE-CORRESPONDING waphnew TO wrkarea2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    LOOP AT itabfxnew into wafxnew.
    MOVE-CORRESPONDING wafxnew TO wrkarea2.
    INSERT wrkarea2 INTO TABLE itab2.
    ENDLOOP.
    *loop at itabhsnew.
    *itab2-HOU = itabhsnew-HOU.
    *itab2-str = itabhsnew-str.
    *append itab2.
    *endloop.
    *LOOP AT itabhsnew.
    *itab2-HOU = itabhsnew-HOU.
    *itab2-str = itabhsnew-str.
    *append itab2.
    *ENDLOOP.
    *delete adjacent duplicates FROM itab2 COMPARING HOU STR PHONE PHONE_EXT FAX FAX_EXT.
    *LOOP AT itab2.
    *INSERT wrkarea2 INTO TABLE itab2.
    *endloop.
    *WRITE: THREE.
    *new-line.
    *WRITE: four.
    *new-line.
    *WRITE: five.
    program = SY-REPID.
    *PERFORM SELECT.
    *loop at itab2.
    *write:/    itab2-LIFNR,
              itab2-BUKRS,
              itab2-KTOKK,
              itab2-ANRED,
              itab2-NAME1,
              itab2-SORTL,
              itab2-HOU,
              itab2-STR,
              itab2-PSTLZ,
              itab2-ORT01,
              itab2-REGIO,
              itab2-LAND1,
              itab2-SPTXT,
              itab2-TELF1,
    *itab2-PHONE,
    *itab2-PHONE_EXT,
              itab2-TELF2,
              itab2-TELFX,
    *itab2-FAX,
    *itab2-FAX_EXT,
              itab2-TELTX,
              itab2-SMTP_SRCH,
              itab2-STCEG,
              itab2-BRSCH.
    *endloop.
    PERFORM CATALOG.
    PERFORM LAYOUTMAIN.
    PERFORM DISPLAY.
    LFA1STRAS LFA1STRAS
    *FORM SELECT.
    SELECT LFA1LIFNR  LFB1BUKRS LFA1KTOKK LFA1ANRED LFA1~NAME1
    *LFA1SORTL LFA1PSTLZ LFA1ORT01 LFA1REGIO
    *LFA1LAND1 T002TSPTXT LFA1TELF1 LFA1TELF2 LFA1TELFX LFA1TELTX
    *ADR6SMTP_SRCH LFA1STCEG LFA1~BRSCH
    *FROM LFA1
    *INNER JOIN T002T ON LFA1SPRAS = T002TSPRSL AND T002T~SPRAS = 2
    *INNER JOIN LFB1 ON LFA1LIFNR = LFB1LIFNR
    INNER JOIN ADR6 ON LFA1ADRNR = ADR6ADDRNUMBER
    *INTO TABLE itab1 WHERE LFA1~LIFNR IN vendor.
    *LOOP AT itab2.
    *MOVE itab1 TO itab2.
    *APPEND itab2.
    *MOVE-CORRESPONDING ADRDTL TO itab2.
    *APPEND itab2.
    *MOVE-CORRESPONDING ADRDTL TO itab2.
    *APPEND itab2.
    *ENDLOOP.
    *LOOP AT itab1 INTO wrkarea1.
    *MOVE-CORRESPONDING wrkarea1 TO wrkarea2.
    *ENDLOOP.
    *MOVE-CORRESPONDING adrdtl TO wrkarea2.
    *LOOP AT itab2.
    *INSERT wrkarea2 INTO TABLE itab2.
    *ENDLOOP.
    *ENDFORM.
    FORM CATALOG.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='LIFNR'.
    fcat-seltext_m = 'Vendor Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFB1'.
    fcat-fieldname ='BUKRS'.
    fcat-seltext_m = 'Company Code'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='KTOKK'.
    fcat-seltext_m = 'Account Group'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='ANRED'.
    fcat-seltext_m = 'Title'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='NAME1'.
    fcat-seltext_m = 'Name'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='SORTL'.
    fcat-seltext_m = 'Search Term'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='HOU'.
    fcat-seltext_m = 'Street'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='STR'.
    fcat-seltext_m = 'House Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='PSTLZ'.
    fcat-seltext_m = 'Postal Code'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='ORT01'.
    fcat-seltext_m = 'City'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='REGIO'.
    fcat-seltext_m = 'Region or State'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='LAND1'.
    fcat-seltext_m = 'Country'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='SPTXT'.
    fcat-seltext_m = 'Language'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='PHONE'.
    fcat-seltext_m = 'Telephone'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='PHONE_EXT'.
    fcat-seltext_m = 'Extension'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='FAX'.
    fcat-seltext_m = 'Fax Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='FAX_EXT'.
    fcat-seltext_m = 'Extension'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'ADR6'.
    fcat-fieldname ='SMTP_SRCH'.
    fcat-seltext_m = 'E-Mail'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='STCEG'.
    fcat-seltext_m = 'VAT Registration Number'.
    APPEND fcat TO fieldcat.
    fcat-tabname = 'LFA1'.
    fcat-fieldname ='BRSCH'.
    fcat-seltext_m = 'Industry Type'.
    APPEND fcat TO fieldcat.
    ENDFORM.
    FORM LAYOUTMAIN.
    layout-zebra = 'X'.
    *layout-edit= 'X'.
    *layout-zebra = 'X'.
    *layout-zebra = 'X'.
    ENDFORM.
    FORM DISPLAY.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
        I_CALLBACK_PROGRAM                = 'program'
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
        I_GRID_TITLE                      = 'VENDOR DETAILS'
      I_GRID_SETTINGS                   =
        IS_LAYOUT                         = layout
        IT_FIELDCAT                       = fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
       I_DEFAULT                          = 'X'
       I_SAVE                             = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = itab2.
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.

    HI,
    " By taking two internal table
    LOOP AT ITAB.
      IT_FINAL-FIELD1 = ITAB-FIELD(10).
      IT_FINAL-FIELD2 = ITAB-FIELD+10(10).
      APPEND IT_FINAL.
      CLEAR IT_FINAL.
    ENDLOOP.
    " By taking one internal table
    LOOP AT ITAB.
      ITAB-FIELD2 = ITAB-FIELD1(10).
      ITAB-FIELD3 = ITAB-FIELD1+10(10).
      MODIFY ITAB INDEX SY_TABIX.
    ENDLOOP.

  • How  to copy data from one internal table to another

    i am using some function module to get some data for my function module
    and the retrieved data is not getting populated in mu fumctional module
    i am sucessful in getting the data to an internal table in my function module but dont know how to pass it to my table parameter
    thanks in advance

    Hi Naval,
    Declare an internal table of type table parameter structure and pass it the table parameters of the Function module.
    Check the code for this function module.
    DATA IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
    SELECT * FROM MARA UP TO 10 ROWS INTO TABLE IT_MARA.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = 'C:\TEST.TXT'.      FILETYPE                = 'ASC'
          WRITE_FIELD_SEPARATOR   = 'X'
    <b>    TABLES
          DATA_TAB                = IT_MARA</b>
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          OTHERS                  = 22.
      IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Thanks,
    Vinay

  • Copy and Modify from one internal table to another.Please help.

    Hi,
    I have an internal table having a structure like below.
    Account Entity Category period1value pd2value
    10 A C 100 200.
    where account corresponds to 10
    entity A
    category C
    period1 value = 100
    period2 value = 200.
    Now I need to populate it into another table having structure like
    Account Entity Category period Value
    10 A C 1 100
    10 A C 2 200.
    If u see this carefully a new column, period is added in the database table and thus for each row there will be only 1value.
    Instead of period1 value and period2 value being in the same row they will come in different rows.One row will be like the value for period1 and next for value like period2.
    Pleadse help
    Ankit

    Hi,
    u can do as follows,
    LOOP AT itab1 into wa_itab1.
    wa_itab2-account = wa_itab1-account.
    wa_itab2-entity = wa_itab1-entity.
    wa_itab2-category = wa_itab1-category.
    if not wa_itab1-period1 is initial.
    wa_itab2-period = wa_itab1-period1.
    endif.
    if not wa_itab1-period2 is intial.
    wa_itab2-period = wa_itab1-period2.
    endif.
    wa_itab2-value = wa_itab1-value.
    append wa_tab2 to itab2.
    clear:wa_itab1-period1 ,
           wa_itab2-period .
    endloop.

Maybe you are looking for

  • Planning DataExport

    I have created a business rule to export data planning. The data is exporting to the path specified. Content of the rule for export is as below: FIX DATAEXPORT "File" ";" "W:\export.txt" "0"; ENDFIX Our situation is such that many users will be expor

  • Upgrading Entourage from Home to Standard

    I have the Home version of Entourage and got the Standard version (want the Automator routines) and I was wondering how you go about installing the Standard version when the Home version is sitting on your system.

  • Can't install Photoshop CS4 on Macbook Pro 10.8.3

    When I try to install from my original disc, it freezes and stops the install about halfway through.  Any fixes?

  • Components disappeared after adding the image in.....

    Hello everyone, I add a image in my home page that is in swing .As soon as I add that image the components in another page disappeared.(Componenets like textField ,Label).But when I click on that page, those pages appears. I want to appear all those

  • My i bad under name of my friend haw i can chang under my name

    i want to change the name of old honer of my i pad its under name of friend haw i change that name to me