Two internal tables in to one internal table

Hi , 
           I have two internal tables ITAB1 and ITAB2, i would like to put fields from  two internal tables in to one internal table(ITAB3) with out using inner joint. any one of you can give the sample code for this
Thanks
Raja.

Hi,
Kamesh wrote :
      Read itab2 into wa_itab2 with key f2 = itab1-f1 <USe your where conditions here>.
Read statement does not have WHERE conditions.
Please be careful while posting. Your thread will be reffered by many people. Please dont mislead.
Regards,
Swapna.

Similar Messages

  • Two Dimension Hierarchys based on one Logical Table

    Is it possible to have two dimesion hierarchys based on one logical table? Suppose we have the following case:
    Accounts Table
    Code
    Name
    Category
    Subcategory
    Level 1
    Level 2
    Level 3
    I would like to have one dimension Total > Category >Subcategory > Code and one Total > Level 1 > Level 2 > Level 3 > Code, so I can drill down on both paths. Is this possible?
    Thanx

    Yes, the trick is to have the same key on the lowest level in your hierarchy.
    regards
    John
    http://obiee101.blogspot.com/

  • Download the KTOPL  field data and GLT0 table data into one Internal table

    Hi,
    I have downloaded GLT0 table fields  data to PC file . But i need to download KTOPL(Chart Of Accounts) data also. in GLT0 table there is no KTOPL field.
    But in SKA1 table have KTOPL field. Then what is the issue is GLT0 data & KTOPL field data needs to download into one Internal Table.
    anybody could you please solve this problem. immediately need to solve this.
    Below is the code.
    REPORT ZFXXEABL_1 NO STANDARD PAGE HEADING
                    LINE-SIZE 200.
    Tables Declaration
    TABLES : GLT0.
    Data Declaration
    DATA :   FP(8)           TYPE C,
             YEAR           LIKE GLT0-RYEAR,
             PERIOD(3)       TYPE C,
             DBALANCE         LIKE VBAP-NETWR VALUE 0 ,
             CBALANCE         LIKE VBAP-NETWR VALUE 0.
    *Internal table for for final data..
    DATA : BEGIN OF REC1 OCCURS 0,
           BAL             LIKE GLT0-TSLVT value 0,
           COAREA          LIKE GLT0-RBUSA,
          CA(4)           TYPE C,
           KTOPL           LIKE ska1-ktopl, 
           CCODE           LIKE GLT0-BUKRS,
           CREDIT          LIKE  VBAP-NETWR,
           CURRENCY        LIKE GLT0-RTCUR,
           CURTYPE(2)      TYPE N,
           DEBIT           LIKE VBAP-NETWR,
           YEAR(8)         TYPE C,
           FY(2)           TYPE C,
           ACCOUNT         LIKE GLT0-RACCT,
           VER             LIKE GLT0-RVERS,
           VTYPE(2)        TYPE N,
           CLNT            LIKE SY-MANDT,
           S_SYS(3)        TYPE C,
           INDICATOR      LIKE GLT0-DRCRK,
           END OF REC1.
    DATA : C(2) TYPE N,
           D(2) TYPE N.
    DATA REC1_H LIKE REC1.
    Variable declarations
    DATA :
           W_FILES(4) TYPE N,
           W_DEBIT LIKE GLT0-TSLVT,
           W_CREDIT LIKE GLT0-TSLVT,
           W_PCFILE LIKE RLGRAP-FILENAME ,
           W_UNIXFILE LIKE RLGRAP-FILENAME,
           W_PCFILE1 LIKE RLGRAP-FILENAME,
           W_UNIXFIL1 LIKE RLGRAP-FILENAME,
           W_EXT(3) TYPE C,
           W_UEXT(3) TYPE C,
           W_PATH LIKE RLGRAP-FILENAME,
           W_UPATH LIKE RLGRAP-FILENAME,
           W_FIRST(1) TYPE C VALUE 'Y',
           W_CFIRST(1) TYPE C VALUE 'Y',
           W_PCFIL LIKE RLGRAP-FILENAME.
    DATA: "REC LIKE GLT0 OCCURS 0 WITH HEADER LINE,
          T_TEMP LIKE GLT0 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF REC3 OCCURS 0.
          INCLUDE STRUCTURE GLT0.
    DATA: KTOPL LIKE SKA1-KTOPL,
          END OF REC3.
    DATA: BEGIN OF T_KTOPL OCCURS 0,
          KTOPL LIKE SKA1-KTOPL,
          SAKNR LIKE SKA1-SAKNR,
          END OF T_KTOPL.
    Download data.
    DATA: BEGIN OF I_REC2 OCCURS 0,
           BAL(17),        "             like GLT0-TSLVT value 0,
           COAREA(4),      "          like glt0-rbusa,
           CA(4),          "  chart of accounts
           CCODE(4),       "           like glt0-bukrs,
           CREDIT(17),     "          like  vbap-netwr,
           CURRENCY(5),    "       like glt0-rtcur,
           CURTYPE(2),     "      type n,
           DEBIT(17),      "           like vbap-netwr,
           YEAR(8),        "  type c,
           FY(2),          " type c, fiscal yr variant
           ACCOUNT(10),    " like glt0-racct,
           VER(3),         "    like glt0-rvers,
           VTYPE(3),       " type n,
           CLNT(3),        "like sy-mandt,
           S_SYS(3),       "like sy-sysid,
           INDICATOR(1),   "   like glt0-drcrk,
          END OF I_REC2.
    Selection screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK BL1  WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS : COMPCODE FOR GLT0-BUKRS,
                      GLACC FOR GLT0-RACCT,
                      FISYEAR   FOR GLT0-RYEAR,
                    no intervals no-extension,      "- BG6661-070212
                       FISCPER FOR GLT0-RPMAX,
                     busarea   for glt0-rbusa,
                      CURRENCY  FOR GLT0-RTCUR.
    SELECTION-SCREEN END   OF BLOCK BL1.
    SELECTION-SCREEN BEGIN OF BLOCK BL2  WITH FRAME TITLE TEXT-BL2.
    PARAMETERS:
      P_UNIX AS CHECKBOX,                  "Check box for Unix Option
      P_UNFIL LIKE RLGRAP-FILENAME,        " Unix file Dnload file name
       default '/var/opt/arch/extract/GLT0.ASC',  "- BG6661-070212
      P_PCFILE AS CHECKBOX,                "Check box for Local PC download.
      P_PCFIL LIKE RLGRAP-FILENAME         " PC file Dnload file name
                 default 'C:\GLT0.ASC'.           "- BG6661-070212
          DEFAULT 'C:\glt0_gl_balance_all.asc'.     "+ BG6661-070212
    SELECTION-SCREEN END   OF BLOCK BL2.
    *eject
    Initialization.                                                     *
    INITIALIZATION.
    Try to default download filename
    p_pcfil = c_pcfile.
    p_unfil = c_unixfile.
    if sy-sysid eq c_n01.
       p_unfil =   c_unixfile.
    endif.
    if sy-sysid eq c_g21.
       p_unfil =   c_g21_unixfile.
    endif.
    if sy-sysid eq c_g9d.
       p_unfil =   c_g9d_unixfile.
    endif.
    Default for download filename
    *{ Begin of BG6661-070212
      CONCATENATE C_UNIXFILE
                  SY-SYSID C_FSLASH C_CHRON C_FILENAME INTO P_UNFIL.
    *} End of BG6661-070212
    AT SELECTION-SCREEN OUTPUT.
    loop at screen.
       if screen-name = 'P_PCFIL'.        "PC FILE
         screen-input = '0'.
         modify screen.
       endif.
       if screen-name = 'P_UNFIL'.        "UN FILE
         screen-input = '0'.
         modify screen.
       endif.
    endloop.
      if w_first = 'Y'.
        perform path_file.
        w_first = 'N'.
      endif.
    if w_cfirst = 'Y'.
       perform cpath_file.
       w_cfirst = 'N'.
    endif.
    Start-of-Selection.                                                 *
    START-OF-SELECTION.
    *COLLECT DATA
      PERFORM COLLECT_DATA.
    *BUILD FILENAMES
      PERFORM BUILD_FILES.
    *LOCAL
      IF P_PCFILE = C_YES.
       PERFORM LOCAL_DOWNLOAD.
      ENDIF.
    *UNIX
      IF P_UNIX = C_YES.
        PERFORM UNIX_DOWNLOAD.
      ENDIF.
      IF P_PCFILE IS INITIAL AND P_UNIX IS INITIAL.
        MESSAGE I000(ZL) WITH 'Down load flags both are unchecked'.
      ENDIF.
    END-OF-SELECTION.
    IF P_PCFILE = C_YES.
    WRITE :/ 'PC File'  , C_UNDER, P_PCFIL.
    ENDIF.
    *&      Form  DOWNLOAD
          Download                                                       *
    FORM DOWNLOAD.
      P_PCFIL =  W_PATH.
      DATA LIN TYPE I.
      DESCRIBE TABLE I_REC2 LINES LIN.
      WRITE:/ 'No of Records downloaded = ',LIN.
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
               FILENAME            =  P_PCFIL
               FILETYPE            =  C_ASC   "c_dat   "dat
           TABLES
                DATA_TAB            = I_REC2  " t_str
               fieldnames          = t_strhd
           EXCEPTIONS
                FILE_OPEN_ERROR     = 1
                FILE_WRITE_ERROR    = 2
                INVALID_FILESIZE    = 3
                INVALID_TABLE_WIDTH = 4
                INVALID_TYPE        = 5
                NO_BATCH            = 6
                UNKNOWN_ERROR       = 7
                OTHERS              = 8.
      IF SY-SUBRC EQ 0.
      ENDIF.
    ENDFORM.
    *&      Form  WRITE_TO_SERVER
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM WRITE_TO_SERVER.
      DATA : L_MSG(100) TYPE C,
             L_LINE(5000) TYPE C.
      P_UNFIL =  W_UPATH.
      DATA LIN TYPE I.                           
      DESCRIBE TABLE I_REC2 LINES LIN.           
      WRITE:/ 'No of Records downloaded = ',LIN. 
      OPEN DATASET P_UNFIL FOR OUTPUT IN TEXT MODE.        " message l_msg.
      IF SY-SUBRC <> 0.
        WRITE: / L_MSG.
      ENDIF.
    perform header_text1.
      LOOP AT I_REC2.
        TRANSFER I_REC2 TO P_UNFIL.
      ENDLOOP.
      CLOSE DATASET P_UNFIL.
      WRITE : / C_TEXT , W_UPATH.
      SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
      CLEAR W_UPATH.
      IF NOT W_UEXT IS INITIAL.
        CONCATENATE W_UNIXFIL1  C_DOT W_UEXT INTO W_UPATH.
      ELSE.
        W_UEXT = C_ASC. " c_csv.
        CONCATENATE W_UNIXFIL1 C_DOT W_UEXT INTO W_UPATH.
      ENDIF.
    ENDFORM.                               " WRITE_TO_SERVER
    *&      Form  BUILD_FILES
    FORM BUILD_FILES.
      IF P_PCFILE = C_YES.
        W_PCFILE = P_PCFIL.
    ***Split path at dot**
        SPLIT W_PCFILE AT C_DOT INTO W_PCFILE1 W_EXT.
        IF NOT W_EXT IS INITIAL.
          CONCATENATE W_PCFILE1 C_DOT W_EXT INTO W_PATH.
        ELSE.
          W_PATH = W_PCFILE1.
        ENDIF.
      ENDIF.
      IF P_UNIX = C_YES.
        W_UNIXFILE = P_UNFIL.
        SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
        IF NOT W_UEXT IS INITIAL.
          CONCATENATE W_UNIXFIL1  C_DOT W_UEXT INTO W_UPATH.
        ELSE.
          W_UPATH = W_UNIXFIL1.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM CPATH_FILE.
    CLEAR P_PCFIL.
       CONCATENATE C_PCFILE
                   C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
                   C_DOT C_ASC INTO  P_PCFIL.
    ENDFORM.                    " CPATH_FILE
    FORM PATH_FILE.
    CLEAR P_UNFIL.
      if sy-sysid eq c_n01.
       CONCATENATE C_UNIXFILE
                   C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
                    C_DOT C_ASC INTO  P_UNFIL.
      endif.
      if sy-sysid eq c_g21.
      concatenate c_g21_unixfile
                  c_comfile sy-sysid c_under sy-datum sy-uzeit
                   c_dot c_asc into  p_unfil.
      endif.
      if sy-sysid eq c_g9d.
      concatenate c_g9d_unixfile
                  c_comfile sy-sysid c_under sy-datum sy-uzeit
                   c_dot c_asc into  p_unfil.
      endif.
    ENDFORM.                    " PATH_FILE
    Local_Download                                                       *
          Local                                                          *
    FORM LOCAL_DOWNLOAD.
    perform header_text.
    LOOP AT REC1.
    REC1-CLNT = SY-MANDT.
    REC1-S_SYS = SY-SYSID.
    MOVE:  REC1-BAL TO I_REC2-BAL,
            REC1-COAREA TO I_REC2-COAREA,
           REC1-CA TO I_REC2-CA,         
            REC1-KTOPL TO I_REC2-CA,       
            REC1-CCODE TO I_REC2-CCODE,
            REC1-CREDIT TO I_REC2-CREDIT,
            REC1-CURRENCY TO I_REC2-CURRENCY,
            REC1-CURTYPE TO I_REC2-CURTYPE,
            REC1-DEBIT TO I_REC2-DEBIT,
            REC1-YEAR TO I_REC2-YEAR,
            REC1-FY TO I_REC2-FY,
            REC1-ACCOUNT TO I_REC2-ACCOUNT,
            REC1-VER TO I_REC2-VER,
            REC1-VTYPE TO I_REC2-VTYPE,
            REC1-CLNT TO I_REC2-CLNT,
            REC1-S_SYS TO I_REC2-S_SYS,
            REC1-INDICATOR TO I_REC2-INDICATOR.
    APPEND I_REC2.
    CLEAR  I_REC2.
    ENDLOOP.
      IF NOT I_REC2[] IS INITIAL.
        PERFORM DOWNLOAD .
        CLEAR I_REC2.
        REFRESH I_REC2.
       ELSE.
       WRITE : / ' no record exist due to unavailability of data'.
      ENDIF.
    ENDFORM.                               " LOCAL_DOWNLOAD
    *&      Form  UNIX_DOWNLOAD
    FORM UNIX_DOWNLOAD.
    LOOP AT REC1.
    REC1-CLNT = SY-MANDT.
    REC1-S_SYS = SY-SYSID.
    MOVE:  REC1-BAL TO I_REC2-BAL,
            REC1-COAREA TO I_REC2-COAREA,
          REC1-CA TO I_REC2-CA,         
            REC1-KTOPL TO I_REC2-CA,       
            REC1-CCODE TO I_REC2-CCODE,
            REC1-CREDIT TO I_REC2-CREDIT,
            REC1-CURRENCY TO I_REC2-CURRENCY,
            REC1-CURTYPE TO I_REC2-CURTYPE,
            REC1-DEBIT TO I_REC2-DEBIT,
            REC1-YEAR TO I_REC2-YEAR,
            REC1-FY TO I_REC2-FY,
            REC1-ACCOUNT TO I_REC2-ACCOUNT,
            REC1-VER TO I_REC2-VER,
            REC1-VTYPE TO I_REC2-VTYPE,
            SY-MANDT TO I_REC2-CLNT,
            SY-SYSID TO I_REC2-S_SYS,
            REC1-INDICATOR TO I_REC2-INDICATOR.
    APPEND I_REC2.
    CLEAR  I_REC2.
    ENDLOOP.
      IF NOT I_REC2[] IS INITIAL.
        PERFORM WRITE_TO_SERVER.
        CLEAR I_REC2.
        REFRESH I_REC2.
      ELSE.
       WRITE : / ' no record exist due to unavailability of data'.
      ENDIF.
    ENDFORM.                               " UNIX_DOWNLOAD
    *&      Form  HEADER_TEXT
          text                                                           *
    -->  p1        text
    <--  p2        text
    *form header_text.
      concatenate c_bal c_ba c_ca c_cc  c_credit c_currency c_curtype
         c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
               into t_strhd
               separated by c_comma.
      append t_strhd.
    *endform.                               " HEADER_TEXT
    *&      Form  HEADER_TEXT1
          text                                                           *
    *form header_text1.
      concatenate c_bal c_ba c_ca c_cc  c_credit c_currency c_curtype
        c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
               into t_strhd1
               separated by c_comma.
      append t_strhd1.
      transfer t_strhd1 to p_unfil.
    *endform.                    " HEADER_TEXT1
    *&      Form  COLLECT_DATA
          Collect Data                                                   *
    FORM COLLECT_DATA.
    SELECT * FROM GLT0 INTO  TABLE REC3
                        WHERE   BUKRS IN COMPCODE
                        AND     RYEAR IN FISYEAR
                        AND     RPMAX IN FISCPER
                        AND     RACCT IN GLACC
                        AND     RTCUR IN  CURRENCY.
    SELECT KTOPL FROM SKA1
                 INTO TABLE T_KTOPL
                 FOR ALL ENTRIES IN REC3
                 WHERE SAKNR = REC3-RACCT.
    LOOP AT REC3 .
       select *
       from glt0
       into table t_temp
       where rldnr = rec-rldnr
         and rrcty  = rec-rrcty
          and rvers  = rec-rvers
         and bukrs = rec-bukrs
         and ryear = rec-ryear
          and racct  = rec-racct
           and rbusa  = rec-rbusa
           and rtcur <> 'ZAR'
         and rpmax  = rec-rpmax.
    if sy-subrc = 0.
            rec1-bal = '0.00'.
    else.
      rec1-bal = rec-hslvt.
      endif.
    *READ TABLE T_KTOPL WITH KEY SAKNR = REC-RACCT BINARY SEARCH.
    MOVE T_KTOPL-KTOPL TO REC3-KTOPL.
    CLEAR:  CBALANCE, DBALANCE.
    REC1-BAL = REC3-HSLVT.
    IF REC3-DRCRK = 'S'.
    IF REC3-HSLVT NE C_ZERO.
           YEAR   = REC-RYEAR.
           PERIOD = '000'.
           CONCATENATE PERIOD C_DOT YEAR INTO FP.
           REC1-INDICATOR = REC-DRCRK.
           REC1-DEBIT = C_ZERO.
           REC1-CREDIT = C_ZERO.
           REC1-CCODE = REC-BUKRS.
           REC1-YEAR  = FP.
           REC1-CURRENCY = REC-RTCUR.
           REC1-ACCOUNT  = REC-RACCT.
           rec1-bal      = rec-hslvt.
           dbalance = rec1-bal.
           REC1-CURTYPE = C_CTYPE.
           REC1-FY      = C_FY.
           REC1-COAREA   = REC-RBUSA.
           REC1-VER     = REC-RVERS.
           REC1-VTYPE   = C_CTYPE.
           REC1-CA      = C_CHART.
           APPEND REC1.
            C = 0.
          PERFORM D.
    ENDIF.
    IF REC3-HSL01 NE C_ZERO.
            YEAR   = REC3-RYEAR.
            PERIOD = '001'.
            CONCATENATE PERIOD C_DOT YEAR INTO FP.
            REC1-INDICATOR = REC3-DRCRK.
            REC1-DEBIT = REC3-HSL01 .
            REC1-CCODE = REC3-BUKRS.
            REC1-YEAR  = FP.
            REC1-CURRENCY = REC3-RTCUR.
            REC1-ACCOUNT  = REC3-RACCT.
           rec1-bal      = REC3-hsl01 + dbalance.
           dbalance = rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART. 
            REC1-KTOPL = REC3-KTOPL. 
            APPEND REC1.
            C = 1.
         PERFORM D.
    ENDIF.
    IF  REC3-HSL02 NE C_ZERO.
          REC1-DEBIT = REC3-HSL02.
       YEAR   = REC3-RYEAR.
       PERIOD = '002'.
      CONCATENATE PERIOD C_DOT YEAR INTO FP.
         REC1-INDICATOR = REC3-DRCRK.
       REC1-DEBIT = REC3-HSL02.
       REC1-CCODE = REC3-BUKRS.
       REC1-YEAR  = FP.
       REC1-CURRENCY = REC3-RTCUR.
       REC1-ACCOUNT  = REC3-RACCT.
      rec1-bal      = REC3-hsl02 + dbalance.
      dbalance = rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART. "-BF7957-070503
            REC1-KTOPL = REC3-KTOPL.  "+BF7957-070503
       APPEND REC1.
       C = 2.
    PERFORM D.
    ENDIF.
    IF  REC3-HSL03 NE C_ZERO.
            YEAR   = REC3-RYEAR.
            PERIOD = '003'.
            CONCATENATE PERIOD C_DOT YEAR INTO FP.
               REC1-INDICATOR = REC3-DRCRK.
            REC1-DEBIT = REC3-HSL03.
            REC1-CCODE = REC3-BUKRS.
            REC1-YEAR  = FP.
            REC1-CURRENCY = REC3-RTCUR.
            REC1-ACCOUNT  = REC3-RACCT.
           rec1-bal      = REC3-hsl03 + dbalance .
           dbalance =  rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
           REC1-CA      = C_CHART. "-BF7957-070503
             REC1-KTOPL = REC3-KTOPL. "+BF7957-070503
            APPEND REC1.
          C = 3.
    PERFORM D.
    ENDIF.
    IF  REC3-HSL04 NE C_ZERO.
           REC1-DEBIT = REC3-HSL04.
              YEAR   = REC3-RYEAR.
              PERIOD = '004'.
             CONCATENATE PERIOD C_DOT YEAR INTO FP.
                REC1-INDICATOR = REC3-DRCRK.
             REC1-DEBIT = REC3-HSL04.
              REC1-CCODE = REC3-BUKRS.
              REC1-YEAR  = FP.
              REC1-CURRENCY = REC3-RTCUR.
              REC1-ACCOUNT  = REC3-RACCT.
             rec1-bal      = REC3-hsl04 + dbalance .
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART.  "-BF7957-070503
            REC1-KTOPL = REC3-KTOPL.  "+BF7957-070503
            APPEND REC1.
             dbalance = rec1-bal.
              C = 4.
              PERFORM D.
    ENDIF.
    Thanks and Regards,
    Ram

    use logical database SDF, nodes ska1 and  skc1c
    A.

  • ADF:two dependent navigation lists on one database table

    Hello,
    I´ve got one table with adress informations and I like to define two navigation lists (drop down lists) on which the first one shows the streets and the second one shows the names. When I select the street in the first one I like to see the names in the second list only of the selected street.
    How can I realize this? In my datacontrol I´ve got one dataview with the several attributes and I can create the two lists but they don´t depent on each other.
    Many Thanks!

    Hi!
    Thank you for your reply, Frank.
    But the examples you mean, are based on two or more tables and worked with Master/Detail tables. I only have one table and I like to define two select choices for two columns of that one table. For example, one selectchoicelist for name and the other one for street. So the results are the rows which are matching the two selected criteria.
    Regards
    Sven

  • Join multiple tables to create one new table with data from all the other

    CREATE TABLE NAME2012 (STOCKNAME2012 VARCHAR(255), VAL2012 FLOAT)
    INSERT INTO NAME2012 VALUES (‘Stock3’, 50)
    INSERT INTO NAME2012 VALUES (‘Stock2’, 55)
    INSERT INTO NAME2012 VALUES (‘Stock4’, 45)
    CREATE TABLE NAME2011 (STOCKNAME2011 VARCHAR(255), VAL2011 FLOAT)
    INSERT INTO NAME2011 VALUES (‘Stock1’, 56)
    INSERT INTO NAME2011 VALUES (‘Stock2’, 48)
    INSERT INTO NAME2010 VALUES (‘Stock3’, 59)
    CREATE TABLE NAME2010 (STOCKNAME2010 VARCHAR(255), VAL2010 FLOAT )
    INSERT INTO NAME2010 VALUES (‘Stock1’, 47)
    INSERT INTO NAME2010 VALUES (‘Stock2’, 46)
    I would like a new Table STOCKS populated with names of stocks from the other tables as well as values. So I get a new table STOCKS, with data as below.
    CREATE TABLE STOCKS (NAME VARCHAR(255), VALUE2012 FLOAT , VALUE2011 FLOAT, VALUE2010 FLOAT)
    End result in table STOCKS should be like:
    NAME               VALUE2010              VALUE2011             
    VALUE2012
    Stock1                 47                          
    56                            NULL
    Stock2                 46                          
    48                             50
    Stock3                NULL                         59                          
     55
    Stock4                NULL                       NULL                         
    45
    How can I write a T-SQL expression that could do this?

    Hi
    There must be StockMaster
    Try this
    CREATE TABLE NAME2012 (
    STOCKNAME2012 VARCHAR(255)
    ,VAL2012 FLOAT
    INSERT INTO NAME2012
    VALUES (
    'Stock3'
    ,50
    INSERT INTO NAME2012
    VALUES (
    'Stock2'
    ,55
    INSERT INTO NAME2012
    VALUES (
    'Stock4'
    ,45
    CREATE TABLE NAME2011 (
    STOCKNAME2011 VARCHAR(255)
    ,VAL2011 FLOAT
    INSERT INTO NAME2011
    VALUES (
    'Stock1'
    ,56
    INSERT INTO NAME2011
    VALUES (
    'Stock2'
    ,48
    CREATE TABLE NAME2010 (
    STOCKNAME2010 VARCHAR(255)
    ,VAL2010 FLOAT
    INSERT INTO NAME2010
    VALUES (
    'Stock1'
    ,47
    INSERT INTO NAME2010
    VALUES (
    'Stock2'
    ,46
    INSERT INTO NAME2010
    VALUES (
    'Stock3'
    ,59
    Create table stockMaster(STOCKNAME VARCHAR(255))
    go
    Insert into stockMaster values('Stock1')
    Insert into stockMaster values('Stock2')
    Insert into stockMaster values('Stock3')
    Insert into stockMaster values('Stock4')
    Select Distinct S.STOCKNAME , A.VAL2010 ,B.VAL2011,C.VAL2012 from  stockMaster S
    left join NAME2012  C on S.STOCKNAME = C.STOCKNAME2012
    left join NAME2011 B on s.STOCKNAME = B.STOCKNAME2011
    left join NAME2010 A on s.STOCKNAME = A.STOCKNAME2010
    go
    Drop table NAME2010
    Drop table NAME2011
    Drop table NAME2012
    Drop table stockMaster 
    Mark as Ans if you find it useful
    Shridhar J Joshi Thanks a lot

  • How to pass data from one internal session to another

    Hi SAP Experts,
    How to pass data from one internal session to another and from One external session to another external session. I used import and export parmeter and SPA/GPA parameters. What is the other way to pass data?
    Please tel me urgently
    Thank you
    Basu

    Memory Structures of an ABAP Program
    In the Overview of the R/3 Basis System you have seen that each user can open up to six R/3 windows in a single SAPgui session. Each of these windows corresponds to a session on the application server with its own area of shared memory.
    The first application program that you start in a session opens an internal session within the main session. The internal session has a memory area that contains the ABAP program and its associated data. When the program calls external routines (methods, subroutines or function modules) their main program and working data are also loaded into the memory area of the internal session.
    Only one internal session is ever active. If the active application program calls a further application program, the system opens another internal session. Here, there are two possible cases: If the second program does not return control to the calling program when it has finished running, the called program replaces the calling program in the internal session. The contents of the memory of the calling program are deleted. If the second program does return control to the calling program when it has finished running, the session of the called program is not deleted. Instead, it becomes inactive, and its memory contents are placed on a stack.
    The memory area of each session contains an area called ABAP memory. ABAP memory is available to all internal sessions. ABAP programs can use the EXPORT and IMPORT statements to access it. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.
    All ABAP programs can also access the SAP memory. This is a memory area to which all sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters are often used to preassign values to input fields. You can set them individually for users, or globally according to the flow of an application program. SAP memory is the only connection between the different sessions within a SAPgui.
    The following diagram shows how an application program accesses the different areas within shared memory:
    In the diagram, an ABAP program is active in the second internal session of the first main session. It can access the memory of its own internal session, ABAP memory and SAP memory. The program in the first internal session has called the program which is currently active, and its own data is currently inactive on the stack. If the program currently active calls another program but will itself carry on once that program has finished running, the new program will be activated in a third internal session.
    Data Clusters in ABAP Memory
    You can store data clusters in ABAP memory. ABAP memory is a memory area within the internal session (roll area) of an ABAP program and any other program called from it using CALL TRANSACTION or SUBMIT.
    ABAP memory is independent of the ABAP program or program module from which it was generated. In other words, an object saved in ABAP memory can be read from any other ABAP program in the same call chain. ABAP memory is not the same as the cross-transaction global SAP memory. For further information, refer to Passing Data Between Programs.
    This allows you to pass data from one module to another over several levels of the program hierarchy. For example, you can pass data
    From an executable program (report) to another executable program called using SUBMIT.
    From a transaction to an executable program (report).
    Between dialog modules.
    From a program to a function module.
    and so on.
    The contents of the memory are released when you leave the transaction.
    To save data objects in ABAP memory, use the statement EXPORT TO MEMORY.
    Saving Data Objects in Memory
    To read data objects from memory, use the statement IMPORT FROM MEMORY.
    Reading Data Objects from Memory
    To delete data clusters from memory, use the statement FREE MEMORY.
    Deleting Data Clusters from Memory
    please read this which provide more idea about memory
    Message was edited by:
            sunil kumar

  • KO01 Internal order number range Pru00E4fix+internal number

    Dear all,
    we have one worldwide controlling area.
    We would like to set up as less as possible internal order types. As you know you can assign behind each internal oder type the number range.
    We would like to have a number range with the company-code prefix + an internal number:
    Example:
    Using one internal order type:
    expected numbers:
    DE10000001 (DE10 = company code)
    DE10000002 (DE10 = company code)
    CZ10000001 (CZ10 = company code)
    CZ10000002 (CZ10 = company code)
    The prefix should be selected from the company code which we enter manually in TA KO01. The number should be generated internal!
    Have you maybe already implemented a similar solution?
    One option could be a user exit + using Transaction SNUM???
    Thanks for a feedback!
    xmchx

    We did a similar thing for SD Invoices with enhancement for SNRO restricting for sales order types.  We had the number ranges stored in an external table (Z table) and picked up from there.  But our co. codes had numerical ids.  But is certainly possible to do similarly for your requirement also.  But in that case, number ranges will be handled by your enhancement routine and not by SAP.
    Ravi.

  • How to join two internal table rows in alternative manner into one internal table?

    How to join two internal table rows in alternative manner into one internal table?
    two internal tables are suppose itab1 &  itab2 & its data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    d
    e
    f
    g
    h
    i
    Header 1
    Header 2
    Header 3
    1
    2
    3
    4
    5
    6
    7
    8
    9
    INTO itab3 data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    1
    2
    3
    d
    e
    f
    4
    5
    6
    g
    h
    i
    7
    8
    9

    Hi Soubhik,
    I have added two additional columns for each internal table.
    Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
    Row_Count  - It represents the Row Count Number, increase the row count value 1 by one..
    ITAB1:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    a
    b
    c
    1
    1
    d
    e
    f
    1
    2
    g
    h
    i
    1
    3
    ITAB2:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    1
    2
    3
    2
    1
    4
    5
    6
    2
    2
    7
    8
    9
    2
    3
    Create the Final Internal table as same as the ITAB1/ITAB2 structure.
    "Data Declarations
    DATA: IT_FINAL LIKE TABLE OF ITAB1.          "Final Internal Table
    FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1,     "TAB1
                                   <FS_TAB2> TYPE TY_TAB2.     "TAB2
    "Assign the values for the additional two column for ITAB1
    LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
         <FS_TAB1>-TABLE_COUNT = 1.             "Table value same for all row
         <FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
    ENDLOOP.
    "Assign the values for the additional two column for ITAB2
    LOOP AT ITAB2 ASSIGNING <FS_TAB2>.    
         <FS_TAB2>-TABLE_COUNT = 2.                  "Table value same for all row
         <FS_TAB2>-ROW_COUNT = SY-TABIX.      "Index value
    ENDLOOP.
    "Copy the First Internal Table 'ITAB1' to Final Table
    IT_FINAL[] = ITAB1[].
    "Copy the Second Internal Table 'ITAB2' to Final Table
    APPEND IT
    LOOP AT ITAB2 INTO WA_TAB2.
    APPEND WA_TAB2 TO IT_FINAL.
    ENDLOOP.
    "Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
    SORT IT_FINAL BY  ROW_COUNT TABLE_COUNT.
    After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
    Regards
    Rajkumar Narasimman

  • How can i add two table into one internal table

    I WANT TO ADD THIS TWO DIFFERENT TABLE INTO ONE INTERNAL TABLE PLEASE HELP.
    TABLES: J_1IEXCHDR, J_1IEXCDTL.
    SELECT * FROM J_1IEXCHDR WHERE STATUS = 'P'.
    WRITE: / J_1IEXCHDR-LIFNR,
              J_1IEXCHDR-DOCNO,
              J_1IEXCHDR-EXYEAR,
              J_1IEXCHDR-BUDAT.
    SELECT * FROM J_1IEXCDTL WHERE TRNTYP = J_1IEXCHDR-TRNTYP
                              AND DOCYR  = J_1IEXCHDR-DOCYR
                              AND DOCNO  = J_1IEXCHDR-DOCNO.
       WRITE: / J_1IEXCDTL-EXBAS,
                J_1IEXCDTL-EXBED,
                J_1IEXCDTL-RDOC1,
                J_1IEXCDTL-ECS.
    ENDSELECT.
    ENDSELECT.
    THANKS IN ADVANCED.

    U have to link these 2 tables like this
    <b>SELECT
    J_1IEXCHDR~DOCNO
    FROM J_1IEXCHDR inner join J_1IEXCDTL
    on J_1IEXCHDRDOCYR  = J_1IEXCDTLDOCYR
    WHERE STATUS = 'P'.</b>
    this is sample code only, and u have to check the F.key relationship.
    Regards
    Prabhu

  • Data package's data coolection in one internal table of Update rule in bw

    Hello Gurus,
    I have a requirement in bw which demands to create update routine, in which I need to find the vendor for the material, which doesn't have vendor by some business rule but, here in this case data is divided into different datapackages so here in this case material data is splited over different datapackages.
    One material can have n no of records with differnt plants.
    My only question is like can we collect all datapackage data in one internal table.
    Ex: if there are total 5 datapckages, so in update rule can we collect all these datapackages records?
    Please suggest your opinion.
    Thanks in advance,
    Snehal.
    Moderator message: please have a look in the BW forums.
    Edited by: Thomas Zloch on Jan 11, 2011 1:49 PM

    hi,
    i think your problem is need of a work area...
    Using "FOR ALL ENTRIES IN lt_zhrp"  You must use " check lt_zhrp is not initial "
    DATA: lt_zhrp TYPE STANDARD TABLE OF zhrp,
          lt_zhrt TYPE STANDARD TABLE OF zhrt.
    *new
    data: wa_zhrp type lt_zhrp.
    SELECT tabnr
    FROM zhrp
    INTO CORRESPONDING FIELDS OF TABLE lt_zhrp
    WHERE objid = lv_posid.
    LOOP AT lt_zhrp INTO wa_zhrp.
      SELECT low
      FROM zhrt
      INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
      WHERE tabnr =  wa_zhrp-tabnr  " lt_zhrp-tabnr
      AND attrib = 'NET_VALUE'.
    ENDLOOP.
    Edited by: Miguel Antunes on Apr 28, 2010 4:22 PM

  • Moving data from one internal table to another

    Hi,
    I have one internal table populated with a list of material codes and another with all the material numbers.
    ITAB1: MCODE KSCHL KNUMH MATNR
    ITAB2:  MCODE MATNR
    The matnr field in itab1 is blank initially. It needs to be populated with all the material numbers from itab2. How can I achieve this?
    Thanks,
    ap

    Hi
    Lets say that there is only one record in itab1 and for that there is correspondingly 10 records in itab2.
    that means that the one record in itab1 should be changed to the first material number in itab2 and there should be nine more records created in itab1 according to the values in itab2.
    Hope this is what you mean.
    If this is the logic then the following code should work
    then lets have a third internal table the same type as itab1
    Loop at itab1 into wa_itab1
    *readt table itab2 into wa_itab2 with key mcode = wa_itab1-mcode.
    *IF sy-subrc eq 0.
    loop at itab2 into wa_itab2 where mcode = wa_itab1-mcode.
    wa_itab1-matnr = wa_itab2-matnr
    append wa_itab1 to itab3.
    endloop.
    *ENDIF.
    *modify itab1 from wa_itab1.
    endloop.
    itab3 will contain all the values that you require

  • How to populate one internal table from another using field symbols

    Hi Gurus,
      I have a problem. I have to populate one internal table (sructure t_otput) from another internal table (sructure t_from) using field symbol.
    Structure for from table.
    types: begin of t_from,
             year(4) type c,
             ww(2) type c,
             site type marc-werks,
             demand type i,
           end of t_from.
    Structure for output table.
    types: begin of t_display,
             title(30),
             WW1(10),
             WW2(10),
             WW3(10),
           end of t_display.
    The from table looks like this:
    Year | WW | Site | Demand
    2005 | 1  | OR1  | 12.00
    2005 | 2  | OR1  | 13.00
    2005 | 3  | OR1  | 14.00
    The display table which has to be populated should look like this:
    Title  | WW1   | WW2   | WW3
    OR1    |       |       |
    Demand | 12.00 | 13.00 | 14.00
    How to populate display table using field symbol?
    Please give code snippets
    Thanks,
    Gopal

    Gopal,
    Here is the code, however I am not vary clear about the ORG1 and Demand display that you have shown in the display. I am sure with this code it should not be a big deal to tweak in whatever manner you want.
    TABLES : marc.
    TYPES: BEGIN OF type_display,
    title(30),
    ww1(10),
    ww2(10),
    ww3(10),
    END OF type_display.
    TYPES: BEGIN OF type_from,
    year(4) TYPE c,
    ww(2) TYPE c,
    site TYPE marc-werks,
    demand TYPE i,
    END OF type_from.
    data : t_from type table of type_from,
           t_display type table of type_display.
    field-symbols : <fs_from> type type_from,
                    <fs_display> type type_display.
    data : wa_from type type_From,
           wa_display type type_display.
    wa_from-year = '2005'.
    wa_from-ww   = '1'.
    wa_from-site = 'OR1'.
    wa_from-demand = '12.00'.
    insert wa_from  into table t_from.
    wa_from-year = '2005'.
    wa_from-ww   = '2'.
    wa_from-site = 'OR1'.
    wa_from-demand = '13.00'.
    insert wa_from  into table t_from.
    wa_from-year = '2005'.
    wa_from-ww   = '3'.
    wa_from-site = 'OR1'.
    wa_from-demand = '14.00'.
    insert wa_from  into table t_from.
    data : variable(3) type c.
    field-symbols : <fs_any> type any.
    break-point.
    Loop at t_from assigning <fs_from>.
    variable = 'WW'.
    wa_display-title = <fs_from>-site.
    concatenate variable <fs_from>-ww into variable.
    assign component variable of structure wa_display to <fs_any>.
    <fs_any> = <fs_from>-demand.
    endloop.
    append wa_display to t_display.
    clear wa_display.
    loop at t_display assigning <Fs_display>.
      write :/ <fs_display>.
    endloop.
    Note : Please award points if this helps you.
    Regards,
    Ravi

  • How to scan data from one internal table to another

    Hi All,
    let me know how to scan all from one internal table to another internal table. Pls provide me the syntax and code.
    i am very thankful to you all in advance.
    Thanks & Regards,
    Nagarjuna.

    if u want to copy data from itab1 to itab2  then use
    itab2[] = itab1[].
    if u want to compare whether both itab1 and itab2 are same or not,use
    if itab1[] = itab2[].
    *--same
    else.
    *--not same
    endif.
    if u want to compare itabs based on primary key....
    loop at itab1.
    read table itab2 with key f1 = itab1-f1.
    if sy-subrc <> 0.
    *--not same....
    endif.
    endloop.
    if u want to copy only few lines(say from 1 to 3) of itab1 to itab2 then use...
    append lines of itab1 from 1 to 3 to itab2.
    if internal tables don't have same structure,
    say only fields f1 and f2 are common,then
    loop at itab1.
    itab2-f1 = itab1-f1.
    itab2-f2 = itab1-f2.
    append itab2.
    clear itab2.
    endloop.
    if there are many common fields then...
    loop at itab1.
    move-corresponding itab1 to itab2.
    append itab2.
    clear itab2.
    endloop.
    Please don't forget to reward points....!!!
    Regards
    vasu

  • Problem in Summing the value in one internal table. Its very urgent.

    Hi Experts,
    I have 10 fields in one internal table and based on the 8th field changing, I have to sum the 3rd field.
    I am unable to use AT END OF <FIELD8>, because any of the fields from 1 to 7 are changing, then this control break statement triggering.
    Could any body tell me, how I have to do this.
    Thanks,
    bsv.

    Hi,
    I think it could be as simple as below.
    DATA: l_field8 TYPE bla bla.
    READ TABLE itab
         INTO wa_itab
         INDEX 1.
    l_field8 = wa_itab-field8.
    LOOP AT itab INTO wa_itab.
         IF l_field8 NE wa_itab-field8.
              "Do the sum here
         ENDIF.
    ENDLOOP.
    Regards,
    Teddy
    Edited by: Teddy Kurniawan on Jan 25, 2008 8:38 AM

  • How to insert select columns from one internal table to another

    Hi,
    How to insert select columns from one internal table to another based on condition as we do from a standart table to internal table.
    regards,
    Sriram

    Hi,
    If your question is for copying data from 1 int table to other ;
    we can use
    APPEND LINES OF it_1 TO it_2.
    or if they have different columns then:
    loop at it_1 into wa_it1.
    move wa_it1-data to wa_it2-d1.
    apped wa_it2 to it_2.
    clear wa_it2.
    endloop.
    thnxz

Maybe you are looking for