Combination of three internal tables

Hi there,
Is it possible to join three internal tables into one final table?

Hi,
  No its not possible.
u have to loop . & based on the key u have to make one internal table  by combining the data of each line item .
into one workarea.
create a structure which include all the structure of the 3 tables and make a table of it.
read 3 tables and append in the the final table
sort the tables and use binary search to improve the performance.
eg.
type : begin of table4.
         include table1.      " table structure
         include table2.
         include table3.
       end of table4.
data : table4_tab type table of table4,
       wa_tab4    type table4.
sort : table2 by abc,
        table3 by xyz.
  loop at table1.
      read table table2 with key abc = table1-abc
      binary search.
      if sy-subrc =0.
        wa_tab4-table2 = table2.
      endif.
      read table table3 with key abc = table1-abc
      binary search.
      if sy-subrc =0.
        wa_tab4-table3 = table3.
      endif.
        wa_tab4-table1 = table1.
     append wa_tab4 into table4_tab.
     claer wa_tab4.
endloop.
Use this to optimise code & performance
Reagrds
Manoj B Gupta
Message was edited by: Manoj Gupta

Similar Messages

  • How to populate an internal table from three different tables

    My requirement is to populate an itab by retrieving data from three diff db tables,
    ekko,ekpo and Ekbe.
    below is the code for data retrieval .
    SELECT EBELN INTO TABLE IT_EKKO FROM EKKO WHERE EBELN IN S_EBELN.
      IF NOT IT_EKKO[] IS INITIAL.
        SELECT  EBELP TXZ01 NETWR BUKRS INTO CORRESPONDING FIELDS OF TABLE IT_EKPO FROM EKPO FOR ALL ENTRIES IN IT_EKKO
          WHERE EBELN EQ IT_EKKO-EBELN.
    IF NOT IT_EKPO[] IS INITIAL.
          SELECT  EMATN WAERS WERKS GJAHR BEWTP INTO CORRESPONDING FIELDS OF TABLE IT_EKBE FROM EKBE FOR ALL ENTRIES IN IT_EKPO
            WHERE EBELN EQ IT_EKPO-EBELN
             AND  EBELP EQ IT_EKPO-EBELP
             AND  BEWTP EQ 'E' OR BEWTP EQ 'Q'.
            ENDIF.
            ENDIF.
    please tell me how to populate data from it_ekko,it_ekpo and it_ekbe into an internal table ITAB.

    Hi Mayana,
    You take one final structure & final internal table, & within that structure take all the fields which is required to be displayed as a final output.
    for data fetching from different table, you take three different structures & three internal table for that, because into corresponding fields of table is not good for performance wise. Use into table syntax.
    follow the below example:(similarly)
    sort it_klah by key fields.
    LOOP AT IT_KSSK INTO WA_KSSK.
        READ TABLE IT_KLAH INTO WA_KLAH WITH KEY CLINT = WA_KSSK-CLINT
                                                 KLART = WA_KSSK-KLART.
        IF SY-SUBRC EQ 0.
          MOVE:  WA_KLAH-OBJEK to WA_final-OBJEK.
    Read another table........(2nd one)
    IF SY-SUBRC EQ 0.
          MOVE:  ....................................
          APPEND WA_final TO IT_final.
        ENDIF.
    clear wa_final.
      ENDLOOP.
    finally display it_final records.
    Hope this can solve your problems.
    Regards,
    Tutun

  • Three select statement data in to One Internal table

    HI All,
          By using 3 select statement, data is displying by using work area (classical report). Now i want define three internal table for three select statements, and finally get the data in one final itab, and pass this to function module (ALV Report).
    looking for response

    hi,
    just go through this simple example. no need of declaring 3 itabs.
    data: begin of st1,
            a1 type c,
            a11 type i,
          end of st1.
    data: begin of st2,
            a2 type i,
            a22 type c,
          end of st2.
    data: begin of st3,
            a3 type i,
            a33 type i,
          end of st3.
    data: begin of fin_struct.
              include structure st1.
              include structure st2.
              include structure st3.
    data: end of fin_struct.
    data: fin_itab like table of fin_struct with header line.
    *1st structure  values
    move 'a' to fin_itab-a1.
    move 1 to fin_itab-a11.
    *2nd structure values
    move 11 to fin_itab-a2.
    move 'b' to fin_itab-a22.
    *3rd structure values
    move 15 to fin_itab-a3.
    move 12 to fin_itab-a33.
    *appending 1st record.
    append fin_itab.
    *1st strcuct values
    move 'b' to fin_itab-a1.
    move 3 to fin_itab-a11.
    *2nd structure values
    move 22 to fin_itab-a2.
    move 'c' to fin_itab-a22.
    *3rd structure values
    move 20 to fin_itab-a3.
    move 30 to fin_itab-a33.
    *appending 2nd record.
    append fin_itab.
    loop at fin_itab.
    write:/ fin_itab-a1, fin_itab-a11, fin_itab-a2, fin_itab-a22, fin_itab-a3, fin_itab-a33.
    endloop.
    here structre1,2,3...
    i used move statement.
    here u write select statement.. into struct1,2,3....
    using move u move all the values ...
    finally append it to final itab...
    rest of and all common for ALV...
    Regards,
    Shankar.

  • Internal Table statement

    INSERT, SORT, APPEND, MODIFY, COLLECT, READ, DELETE
    Which of the above statements are allowed to work with:
    Standard Internal Table?
    Sorted Internal Table?
    Hashed Internal Table?
    Thank You.

    Hi,
    <b>Append</b> is used to Fill <b>Standard Internal Tables</b>.
    <b>Insert</b> is used to Fill <b>Sorted Internal Tables & Hashed Internal Tables</b>.
    <b>Read</b>,<b>Delete</b>,<b>Modify</b>,<b>Collect</b>  will work in those <b>Three Internal Tables</b>.
    <b>Sort</b> is used to Sort <b>Standard & Hashed Interanl Table</b>.
    Regards,
    Padmam.

  • Join two internal tables

    hi all
        please give a query for joining of three internal tables and store into another table,and we should retrive data from that third table
    please take those fields as material number,plant,storage location,stock,units

    Hello Raja,
    SELECT EKKNEBELN EKKNEBELP EKKNKOSTL EKKNPS_PSP_PNR EKKN~SAKTO
          EKETWEMNG EKETETENR EKETBEDAT EKPOKNTTP EKPOLOEKZ EKPOMATNR
          EKPOWERKS EKPOMATKL  EKPOMENGE EKPOMEINS EKPONETPR EKPOPEINH
          EKPONETWR EKPOMTART EKPOEFFWR EKKOBUKRS EKKOBSART EKKOERNAM
          EKKOLIFNR EKKOEKORG EKKOEKGRP EKKOWAERS EKKO~BEDAT
          EKKO~MEMORY INTO TABLE G_T_OUTTAB
       FROM ( EKKN
               INNER JOIN EKET
               ON EKETEBELN = EKKNEBELN
               AND EKETEBELP = EKKNEBELP
               INNER JOIN EKPO
               ON EKPOEBELN = EKETEBELN
               AND EKPOEBELP = EKETEBELP
               INNER JOIN EKKO
               ON EKKOEBELN = EKPOEBELN )
             WHERE EKKN~EBELN IN S_EBELN
               AND EKKN~EBELP IN S_EBELP
               AND EKKN~KOSTL IN S_KOSTL
               AND EKKN~PS_PSP_PNR IN S_WBS
               AND EKKN~SAKTO IN S_SAKTO
               AND EKPO~KNTTP IN S_KNTTP
               AND EKPO~LOEKZ IN S_LOEKZ
               AND EKPO~MATKL IN S_MATKL
               AND EKPO~MATNR IN S_MATNR
               AND EKPO~WERKS IN S_WERKS
               AND EKKO~BEDAT IN S_BEDAT
               AND EKKO~BSART IN S_BSART
               AND EKKO~BUKRS IN S_BUKRS
               AND EKKO~EKGRP IN S_EKGRP
               AND EKKO~EKORG IN S_EKORG
               AND EKKO~ERNAM IN S_ERNAM
               AND EKKO~LIFNR IN S_LIFNR
               AND EKPO~MTART IN S_MTART
               AND EKKO~MEMORY IN S_MEMORY
               AND EKET~BEDAT IN S_DAT_ET.
    Try with this code.
    If useful reward.
    Vasanth

  • Records need to be passed between Internal tables

    Hi Experts,
    I'm working in BADI and have three internal tables say IT1, IT2 and IT3 where BELNR is the key field for all the tables. Now I have a field RECEIPT from IT1.
    My requirement is, I want to fetch only those records where IT1-RECEIPTS = X  and then need to pass only these records to IT2 and IT3.
    Is there any possibility to pass the records between internal tables. Please clarify me as how can I achieve it.
    BR,
    RAM.

    Hello,
    DATA: wa_tab LIKE LINE OF it1.
    LOOP AT it1 INTO wa_tab WHERE RECEIPTS EQ 'X'.
          APPEND wa_tab to it2.
          APPEND wa_tab to it3.
    ENDLOOP.

  • Appending All the fields of one internal table to other

    Hi,
    while running a FM I get three internal tables, my requirement is that I am running this FM at item level if it is possible to append all the tables datas get as a result of this FM to other internal table having same structure.
    I know it is possible while using loop, I need a solution with out using the loop
    Regards
    Nausal

    Move Itab1[] to itab2[].
    data: begin of itab occurs 0,
          Maktx LIKE MAKT-MAKTX,
      end of itab.
    data: begin of itab1 occurs 0,
          Maktx LIKE MAKT-MAKTX,
      end of itab1.
    select maktx from makt into table itab where maktx like 'M1%'.
    move itab[] to itab1[].
    loop at itab1.
      write:/ itab1-maktx.
    endloop.

  • Need logic in Internal table processing

    Hi all,
    I have requirement like this.
    i cretaed  three internal tables
    1) first Internal table can store total uploaded data from flat file..means line by line( Here each line is one record)
    2) Second internal can store all fields which are fetched based on table which is given on selction screen.
    3)now i cretaed one internal table with one variable
    4) i used spilt statement on first internal table ( which store all flat file recrds) into third internal table.
    so , my third internal table has first records values of first internal table in one column.
    Now my probelm...i need to populate bapi structre tables with values of third internal table based on field names of second internal table. i am not able to do logic.
    Is there any pointers to know soultion
    Note:we know which fields values from flat values  needs to populate Bapi structure table..
    Thanks in advance,
    regards,
    JBR

    check this program may be u will get the logic
    *& Report  ZBAPI_MATERIAL_SAVEDATA
    *& PURPOSE : THIS REPORT USES BAPI MATERIAL SAVE DATA TO UPDATE AND CREATE
    *&           THE MATERIAL
    REPORT  ZBAPI_MATERIAL_SAVEDATA NO STANDARD PAGE HEADING MESSAGE-ID (ZHNC).
    TYPES:BEGIN OF TY_MAT,
           MATERIAL(4),
           IND_SECTOR(1),
           MATL_TYPE(4),
           MATL_GROUP(9),
           BASE_UOM(3),
           BASE_UOM_ISO(3),
           PLANT(4),
           DEL_FLAG(1),
           PUR_GROUP(3),
           BASE_QTY(13),
           STGE_LOC(4),
           MRP_IND(1),
           SALES_ORG(4),
           DISTR_CHAN(2),
           DEL_FLAG1(1),
           MIN_ORDER(13),
           LANGU(2),
          MATL_DESC(40),
       END OF TY_MAT.
    DATA: IT_DATA TYPE TABLE OF TY_MAT,
          WA_DATA LIKE LINE  OF IT_DATA.
    *decalraing flag
    data: v_flag value ''.
    *DECLARING WORK AREAs  TO BE PASSED TO THE FUNCTION MODULE.
    DATA: BAPI_HEAD LIKE BAPIMATHEAD,
          BAPI_CLIENTDATA LIKE BAPI_MARA,
          BAPI_CLIENTDATAX LIKE BAPI_MARAX,
          BAPI_PLANTDATA LIKE BAPI_MARC,
          BAPI_PLANTDATAX LIKE  BAPI_MARCX,
          BAPI_STORAGELOCATIONDATA LIKE BAPI_MARD,
          BAPI_STORAGELOCATIONDATAX LIKE BAPI_MARDX,
          BAPI_SALESDATA LIKE BAPI_MVKE,
          BAPI_SALESDATAX LIKE BAPI_MVKEX,
          BAPI_MAKT LIKE BAPI_MAKT,
          BAPI_RETURN LIKE BAPIRET2.
    *INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION
    DATA: BEGIN OF IT_MAKT OCCURS 0.
    INCLUDE STRUCTURE BAPI_MAKT.
    DATA END OF IT_MAKT.
    DATA:BEGIN OF IT_RET OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA END OF IT_RET.
    *INTERNAL TABLE TO HOLD HEADER DATA
    DATA: IT_EXCEL TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *SELECTION-SCREEN ELEMENTS
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER: FNAME TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT 'C:\Documents and Settings\Administrator\Desktop\MATMAS.XLS' .
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
                P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
                P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
                P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK B1.
    *DECLARATION OF EXCELAL TABLE
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
    PERFORM F_GET_FILE USING FNAME.
    START-OF-SELECTION.
    PERFORM F_XLS_ITAB USING FNAME
                       CHANGING IT_EXCEL.
    PERFORM F_MOVE_DATA.
    perform F_GET_DATA.
    *&      Form  F_GET_FILE
          text
         -->P_FNAME  text
         <--P_SY_SUBRC  text
    FORM F_GET_FILE  USING    P_FNAME LIKE FNAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
       PROGRAM_NAME        = SYST-REPID
       DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      CHANGING
        FILE_NAME           = P_FNAME
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    IF SY-SUBRC <> 0.
    MESSAGE E006(ZHNC).
    ENDIF.
    ENDFORM.                    " F_GET_FILE
    *&      Form  F_XLS_ITAB
          text
         -->P_FNAME  text
         <--P_IT_EXCEL  text
    FORM F_XLS_ITAB  USING    P_FNAME
                     CHANGING P_IT_EXCEL.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                      = FNAME
        I_BEGIN_COL                   = P_BEGCOL
        I_BEGIN_ROW                   = P_BEGROW
        I_END_COL                     = P_ENDCOL
        I_END_ROW                     = P_ENDROW
      TABLES
        INTERN                        = IT_EXCEL
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    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.                    " F_XLS_ITAB
    *&      Form  F_MOVE_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM F_MOVE_DATA .
    DATA : LV_INDEX TYPE I.
    FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
    SORT IT_EXCEL BY ROW COL.
    CLEAR IT_EXCEL.
    LOOP AT IT_EXCEL.
    MOVE IT_EXCEL-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
    ASSIGN COMPONENT LV_INDEX OF STRUCTURE WA_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
    MOVE IT_EXCEL-VALUE TO <FS>.
    AT END OF ROW.
    APPEND WA_DATA TO IT_DATA.
    CLEAR WA_DATA.
    ENDAT.
    ENDLOOP.
    ENDFORM.                    " F_MOVE_DATA
    *&      Form  F_GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM F_GET_DATA .
    LOOP AT IT_DATA INTO WA_DATA.
    MOVE-CORRESPONDING WA_DATA  TO  BAPI_HEAD.
    BAPI_HEAD-BASIC_VIEW ='X'.
    BAPI_HEAD-SALES_VIEW ='X'.
    BAPI_HEAD-PURCHASE_VIEW ='X'.
    BAPI_HEAD-STORAGE_VIEW ='X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_CLIENTDATA.
    BAPI_CLIENTDATAX-MATL_GROUP = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM_ISO = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_PLANTDATA.
    BAPI_PLANTDATAX-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_PLANTDATAX-DEL_FLAG = 'X'.
    BAPI_PLANTDATAX-PUR_GROUP = 'X'.
    BAPI_PLANTDATAX-BASE_QTY = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_STORAGELOCATIONDATA.
    BAPI_STORAGELOCATIONDATA-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-PLANT = BAPI_STORAGELOCATIONDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-STGE_LOC = BAPI_STORAGELOCATIONDATA-STGE_LOC.
    BAPI_STORAGELOCATIONDATAX-MRP_IND = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_SALESDATA.
    BAPI_SALESDATAX-SALES_ORG = BAPI_SALESDATA-SALES_ORG.
    BAPI_SALESDATAX-DISTR_CHAN = BAPI_SALESDATA-DISTR_CHAN.
    BAPI_SALESDATAX-DEL_FLAG = BAPI_SALESDATA-DEL_FLAG.
    BAPI_SALESDATAX-MIN_ORDER = 'X'.
    REFRESH IT_MAKT.
    IT_MAKT-LANGU = WA_DATA-LANGU.
    IT_MAKT-MATL_DESC = WA_DATA-MATL_DESC.
    APPEND IT_MAKT.
    CLEAR IT_RET.
    REFRESH IT_RET.
    PERFORM F_CALL_BAPI.
    READ TABLE IT_RET WITH KEY TYPE = 'S'.
    IF SY-SUBRC EQ 0.
    PERFORM F_BAPI_COMMIT.
    WRITE:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',WA_DATA-MATERIAL.
    ELSE.
    MESSAGE E000(ZHNC) WITH 'ERROR IN CREATING THE MATERIAL'.
    *WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.
    *PERFORM F_DOWNLOAD.
    ENDIF.
    *ENDIF.
    ENDLOOP.
    ENDFORM.                    " F_GET_DATA
    *&      Form  F_CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    FORM F_CALL_BAPI .
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        HEADDATA                   = BAPI_HEAD
       CLIENTDATA                 =  BAPI_CLIENTDATA
       CLIENTDATAX                =  BAPI_CLIENTDATAX
       PLANTDATA                  =  BAPI_PLANTDATA
       PLANTDATAX                 =  BAPI_PLANTDATAX
       STORAGELOCATIONDATA        =  BAPI_STORAGELOCATIONDATA
       STORAGELOCATIONDATAX       =  BAPI_STORAGELOCATIONDATAX
       SALESDATA                  =  BAPI_SALESDATA
       SALESDATAX                 =  BAPI_SALESDATAX
    IMPORTING
       RETURN                     =  IT_RET
    TABLES
       MATERIALDESCRIPTION        = IT_MAKT
      UNITSOFMEASURE             =
      UNITSOFMEASUREX            =
      INTERNATIONALARTNOS        =
      MATERIALLONGTEXT           =
      TAXCLASSIFICATIONS         =
      RETURNMESSAGES             =
      PRTDATA                    =
      PRTDATAX                   =
      EXTENSIONIN                =
      EXTENSIONINX               =
    APPEND IT_RET.
    ENDFORM.                    " F_CALL_BAPI
    *&      Form  F_BAPI_COMMIT
          text
    -->  p1        text
    <--  p2        text
    FORM F_BAPI_COMMIT .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT         =
    IMPORTING
      RETURN        =
    ENDFORM.                    " F_BAPI_COMMIT

  • Internal table logic

    Hi,
    I have a scenario that I am trying to work on:
    I have three internal tables itab1 itab2 and itab3, all three internal tables have same fields in them but might be different values:
    All the internal tables have three rows of data and in each row there are five fields VAL1 VAL2 VAL3 VAL4 VAL5.The requirement is I need to compare all these three tables as below:
    Compare all the fields of itab1 with itab2, if they are same then skip and if not then compare each field of itab1 to itab3, if they are same then skip and if not replace the value of itab1 field (which is different with the one on itab3)with the itab3 field value.
    can you please help me with this?
    Moderator message : Requirements dumping not allowed, show the work you have already done.  Thread locked.
    Edited by: Vinod Kumar on Mar 9, 2012 7:37 PM

    Hi Vijay,
    I started writing the code as below:
    loop at itab1 into wa_itab1.
      READ TABLE itab2 INDEX sy-index into waA_itab2.
      READ TABLE itab3 INDEX sy-index into wa_itab3.
    if wa_itab1-val1 = wa_itab2-val1.
    skip.
    else.
    if_wa_tab1-val1 = wa_itab3-val1.
    skip.
    else.
    wa_tab1-val1 = wa_itab3-val1.
    endif.
    endif.
    if wa_itab2-val1 = wa_itab2-val2.
    skip.
    else.
    if_wa_tab2-val1 = wa_itab3-val2.
    skip.
    else.
    wa_tab1-val2 = wa_itab3-val2.
    endif.
    endif.
    if wa_itab1-val3 = wa_itab2-val3.
    skip.
    else.
    if_wa_tab1-val3 = wa_itab3-val3.
    skip.
    else.
    wa_tab1-val3 = wa_itab3-val3.
    endif.
    endif.
    if wa_itab1-val4 = wa_itab2-val4.
    skip.
    else.
    if_wa_tab1-va4l = wa_itab3-val4.
    skip.
    else.
    wa_tab1-val4 = wa_itab3-val4.
    endif.
    endif.
    ENDLOOP.
    but I am not sure if whatever I have written is correct.

  • Processing two internal tables

    hi
    i have two internal tables
    itab1  with feilds  partner, vbeln. cmgst ( SO status)
    itab2  - vbeln, posnr(item no ), kwmeng(qunatity) , cmpre ( credit price )
    now i need to get the sum of  (cmpre * kwmeng) for each partner and SO status combination into another internal table itab3.
    so itab3 will have partner, cmgst (so status ) , total amount
    is it possible to achieve this with out using loop inside a loop.
    thanks

    Hi Sudhakar,
    Check below code sample. Change it according to ur need.
    DATA: BEGIN OF itab1 OCCURS 0,
          partner TYPE string,
          vbeln TYPE vbeln,
          cmgst TYPE cmgst,
          END OF itab1,
          wa1 LIKE itab1.
    DATA: BEGIN OF itab2 OCCURS 0,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          kwmeng TYPE kwmeng,
          cmpre TYPE cmpre,
          END OF itab2,
          wa2 LIKE itab2.
    DATA: BEGIN OF itab3 OCCURS 0,
          partner TYPE string,
          cmgst TYPE cmgst,
          amt TYPE p DECIMALS 2,
          END OF itab3,
          wa3 LIKE itab3.
    wa1-partner = 'Test1'. wa1-vbeln   = '0000000001'. wa1-cmgst   = 'X'.
    APPEND wa1 TO itab1. CLEAR wa1.
    wa1-partner = 'Test2'. wa1-vbeln   = '0000000002'. wa1-cmgst   = 'X'.
    APPEND wa1 TO itab1. CLEAR wa1.
    wa2-vbeln  = '0000000001'. wa2-posnr  = '000001'. wa2-kwmeng = 10. wa2-cmpre  = 100.
    APPEND wa2 TO itab2. CLEAR wa2.
    wa2-vbeln  = '0000000002'. wa2-posnr  = '000002'. wa2-kwmeng = 20. wa2-cmpre  = 200.
    APPEND wa2 TO itab2. CLEAR wa2.
    LOOP AT itab1 INTO wa1.
      READ TABLE itab2 INTO wa2 WITH KEY vbeln = wa1-vbeln.
      IF sy-subrc = 0.
        wa3-partner = wa1-partner.
        wa3-cmgst   = wa1-cmgst.
        wa3-amt     = wa2-kwmeng * wa2-cmpre.
        APPEND wa3 TO itab3.
        CLEAR wa3.
      ENDIF.
    ENDLOOP.
    Thanks,

  • Filtering data from internal tables

    Hi,
    I have some common data in three internal tables. The fields in the 3 internal tables are same. It contains some common data and also some different data. Now i need to filter out the commom data among these three tables.
    Based on one internal table data need to filter the common data from the remaining tables and disply them in the output list.
    Let me know how we can do this.
    Regards,
    Ram.

    Hi,
    I have below internal tables.
    <b>Advance_list1</b>
    and the fields are:
    Installation_Number
    Installation_name
    Lloyds_number
    Country_of_operation
    Superior_fun_location
    Project_name
    Responsible_unit
    Status
    and <b>Advance_list2</b> and <b>Advance_list3</b> with the same above fields. But the data will be different in all the three tables and contains some common data. Need to filter based on <b>Advance_list1</b> internal table.If there is no common data then should not disply anything in the output list.
    Pls give me some input on this.
    Regards,
    Ram

  • Merge 2 internal table

    hi,
    1st internal table contains 5 field from ekko - po header table
    2nd internal table contains corresponding value from ekpo - po line item table.
    now i want to merge this table into 3rd table.
    please give me best suggestions with minimum loop logic.
    thanks,
    raj

    hi,
    plz refer the code below. in this way you can solve your query.
    TYPES: begin of itype,
    lifnr TYPE rbkp-lifnr,
    belnr TYPE rbkp-belnr,
    xblnr TYPE rbkp-xblnr,
    END OF itype.
    TYPES:BEGIN OF itype1,
    name1 TYPE lfa1-name1,
    END OF itype1.
    TYPES: BEGIN OF itype2,
    ebeln TYPE ekbe-ebeln,
    belnr type ekbe-belnr,
    END OF itype2.
    DATA: itab TYPE TABLE OF itype, "internal table
    wtab TYPE itype. "work area
    DATA: itab1 TYPE TABLE OF itype1, "internal table
    wtab1 TYPE itype1. "work area
    DATA: itab2 TYPE TABLE OF itype2, "internal table
    wtab2 TYPE itype2. "work area
    select ebeln belnr from ekbe into table itab2 where ebeln in s_ebeln.
    SELECT lifnr belnr xblnr FROM rbkp INTO TABLE itab FOR ALL ENTRIES IN
    itab2 WHERE
    belnr = itab2-belnr.
    SELECT name1 FROM lfa1 INTO TABLE itab1 FOR ALL ENTRIES IN itab WHERE
    lifnr = itab-lifnr.
    Loop at itab2 into wtab2.
    iheader-ebeln = wtab2-ebeln.
    read table itab into wtab
    with key belnr = wtab2-belnr.
    iheader-lifnr = wtab-lifnr.
    iheader-belnr = wtab-belnr.
    iheader-xblnr = wtab-xblnr.
    read table itab1 into wtab1
    with key lifnr = iheader-lifnr.
    iheader-name1 = wtab1-name1.
    end loop.
    here data of three internal table itab, itab1, itab2 is going in one internal tbale iheader.
    regards,
    Ruchika
    Reward if useful.......

  • Combine 2 internal tables into a single internal table

    Hi
    I need to replace the following join statement by splitting it into 2 select statements and then combine them into a single internal table
    SELECT  vbak~waerk
    vbapvbeln vbapposnr vbapnetwr vbapbrgew
    vbap~erdat                         "IM152805
    INTO CORRESPONDING FIELDS OF TABLE l_t_orders
    FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln
    FOR ALL entries IN t_mchb
    WHERE vbap~vbeln = t_mchb-vbeln
    AND vbap~posnr = t_mchb-posnr.
    Need to replace the above with separate select statements and then combine the result into a single internal table...
    could anyone please help me...
    thanks in advance

    Hi,
    Check the code below,
    select vbeln waerk
    from vbak into table it_vbak for all entries in t_mchb  where vbeln = t_mchb-vbeln.
    select posnr
         netwr
         brgew
         erdat "IM152805
    INTO TABLE it_vbap
    for all entries in t_mchb
    where vbeln = t_mchb-vbeln
    and posnr = t_mchb-posnr.
    loop at it_vbap into wa_vbap.
    read table it_vbak into wa_vbak where vbeln = wa_vbap-vbeln.
    if sy-subrc = 0.
    l_t_orders-waerk = wa_vbak-waerk.
    l_t_orders-vbeln = wa_vbap-vbeln.
    l_t_orders-posnr = wa_vbap-posnr
    l_t_orders-netwr   = wa_vbap-netwr.
    l_t_orders-brgew   = wa_vbap-brgew.
    l_t_orders-erdat   = wa_vbap-erdat.
    append l_t_orders.
    endif.
    endloop.
    Reward if it is helpful.
    Regards,
    Bhanu

  • How to join THREE different tables into internal table using one select statement .

    How to join THREE different tables into internal table using one select statement .
    Hi experts,
    I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
    Scenario:
    Database tables:
    SPFLI
    SFLIGHT
    SBOOK.
    Table Fields:
    SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
    SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
    SEATSOCC_C SEATSMAX_F SEATSOCC_F
    SBOOK - CARRID CONNID CLASS
    MY INTERNAL TABLE IS IT_XX.
    Your help much appreciated.
    Thanks in advance.
    Pawan.

    Hi Pawan,
    please check below codes. hope it can help you.
    TYPES: BEGIN OF ty_xx,
            carrid     TYPE spfli-carrid   ,
            connid     TYPE spfli-connid   ,
            countryfr  TYPE spfli-countryfr,
            cityfrom   TYPE spfli-cityfrom  ,
            countryto  TYPE spfli-countryto,
            cityto     TYPE spfli-cityto   ,
            fldate     TYPE sflight-fldate ,
            seatsmax   TYPE sflight-seatsmax ,
            seatsocc   TYPE sflight-seatsocc ,
            seatsmax_b TYPE sflight-seatsmax_b,
            seatsocc_b TYPE sflight-seatsocc_b,
            seatsmax_f TYPE sflight-seatsmax_f,
            seatsocc_f TYPE sflight-seatsocc_f,
            class      TYPE sbook-class,
          END OF ty_xx,
          t_xx TYPE STANDARD TABLE OF ty_xx.
    DATA: it_xx TYPE t_xx.
    SELECT spfli~carrid
           spfli~connid
           spfli~countryfr
           spfli~cityfrom
           spfli~countryto
           spfli~cityto
           sflight~fldate
           sflight~seatsmax
           sflight~seatsocc
           sflight~seatsmax_b
           sflight~seatsocc_b
           sflight~seatsmax_f
           sflight~seatsocc_f
           sbook~class
      INTO TABLE it_xx
      FROM spfli INNER JOIN sflight
      ON spfli~carrid = sflight~carrid
      AND spfli~connid = sflight~connid
      INNER JOIN sbook
      ON spfli~carrid = sbook~carrid
      AND spfli~connid = sbook~connid.
    Thanks,
    Yawa

  • Combining Two Internal Tables??

    How do you combine two internal tables(not by append statement)...if any one knws please let me know..thanks in advance..

    Sort itab_vbap by vbeln posnr.
    sort itab_vbkd by vbeln posnr.
    Loop at itab_vbap into wa_vbap.
    read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.
    if sy-subrc = 0.
    move corresponding wa_vbap to wa_final.
    move corresponding wa_vbkd to wa_final.
    append wa_final to itab_final.
    endif.
    endloop.
    For move corresponding statement the name of the fields should match in both the work areas.
    I hope it helps.

Maybe you are looking for