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.

Similar Messages

  • How to select the data from a Maintainance View into an internal table

    Hi All,
    Can anybody tell me how to select the data from a Maintainance View into an internal table.
    Thanks,
    srinivas.

    HI,
    You can not retrieve data from A mentenance view.
    For detail check this link,
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
    Regards,
    Anirban

  • Selecting from multiple tables, into one internal table

    Hi,
    What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
    Thanks,
    John
    Points will be rewarded and all responses will be highly appreciated.

    I have simple example :
    First one - Join 5 tables
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 4 or 5 tables join.
    get run time field f2.
    f3 = f2 - f1 ( Total time).
    Second one - joins 3 table and use for all entries
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 3 tables join and use for all entries
    get run time field f2.
    f3 = f2 - f1. ( Total time )
    Finally you can have time diffrence between the both sql statement.

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

  • 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

  • Retrive data from two tables into one internal table.

    Hi SDN,
    I am downloading the Assets data from two tables ANLA,ANLZ.
    there is a common field ANL1in both tables and i have to retrive the data by using anl1 into the internal table.
    can you please send me the SELECT Syntax for this probl.....
    Thank you & Regards,
    Manoj

    Hi manoj,
    Please see the following sample code. But kindly don't use join as it may hamper ur performance. No trouble in using two select query.
    data: begin of itab occurs 0,
            BUKRS like anla-BUKRS,
            ANLN1 like anla-ANLN1,
           BDATU like anlz-BDATU,
            end of itab.
    select anlabukrs anlaANLN1 anlzBDATU  into corresponding fields of table itab from anla inner join anlz on anlaanl1 eq anlz~anl1 where (logexp).
    Please come back for any clarification.
    Thanks and Regards,
    saurabh

  • Problem with Fetching Million Records from Table COEP into an Internal Tabl

    Hi Everyone ! Hope things are going well.
           Table : COEP has 6 million records.
    I am trying to get records based on certain criteria, that is, there are atleast 5 conditions in the WHERE clause.
    I've noticed it takes about 15 minutes to populate the internal table. How can i improve the performance to less than a minute for a fetch of 500 records from a database set of 6 million?
    Regards,
    Owais...

    The first obvious sugession would be to use the proper indexes. I had a similar Issue with COVP which is a join of COEP and COBK. I got substanstial performance improvement by adding "where LEDNR EQ '00'" in the where clause.
    Here is my select:
              SELECT kokrs
                     belnr
                     buzei
                     ebeln
                     ebelp
                     wkgbtr
                     refbn
                     bukrs
                     gjahr
                FROM covp CLIENT SPECIFIED
                INTO TABLE i_coep
                 FOR ALL ENTRIES IN i_objnr
               WHERE mandt EQ sy-mandt
                 AND lednr EQ '00'
                 AND objnr = i_objnr-objnr
                 AND kokrs = c_conarea.

  • How to transfer Data of One internal table to another

    Dear Guru,
    I have an internal table
    DATA: BEGIN OF t_cust OCCURS 0,
                kschl  LIKE rv13a-kschl,
                werks LIKE komg-werks,
                matnr LIKE komg-matnr,
                kbetr  LIKE konp-kbetr,
                datab LIKE rv13a-datab,
                datbi  LIKE rv13a-datbi,
          END OF t_cust.
    I want to tranfer all the contents of internal table "t_cust" into another internal table "t_cust2" after converting kbetr, datab, datbi fields  into char type.
    How i will do it??
    pls hlp..

    Hi Saifur,
    if the structure is same then you can simply do
    itab1[] = itab2[].
    if you are changing the data type then.
    data: wa1 like itab1,
            wa2 like itab2.
    loop at itab1 into wa.
    wa2-field1 = wa1-field1.
    wa2-field2 = wa1-field2.
    Append wa2 to itab2.
    endloop.

  • How to do a SELECT from different tables into an internal table?

    How to do a SELECT from different tables into an internal table?
    I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
    REPORT  zinternal_table.
    TABLES:
      mara,
      marc,
      zperson.
    TYPES:
    BEGIN OF str_table1,
      v_name LIKE zperson-zname,
      v_matnr LIKE marc-matnr,
      v_emarc LIKE marc-emarc,
      v_werks_d LIKE marc-werks_d,
      v_dstat LIKE marc-dstat,
      END OF str_table,
      i_table1 TYPE STANDARD TABLE OF str_table1.
    DATA:
    BEGIN OF str_table2,
    v_mandt LIKE mara-mandt,
    v_ernam LIKE mara-ernam,
      v_laeda LIKE mara-laeda,
    END OF str_table2,
    itab_final LIKE STANDARD TABLE OF str_table2.

    first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
    u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
    then for all the entries in that internal table retrieve data from zperson into another internal table.
    then loop at one internal table
    read another internal table where key equals in both the tables.
    finally assign fileds if sy-subrc = 0.
    gs_finaltable-matnr = gs_table-matnr
    etc...
    and finally append gs_finaltable to gt_finaltable.
    there u go ur final table has all the data u want.
    regards
    Edited by: BrightSide on Apr 2, 2009 3:49 PM

  • Split a string into multiple internal tables

    Hi all,
    I need to split a string based internal table into multiple internal tables based on some sub strings in that string based internal table...
    High priority help me out...
    eg...
    a | jhkhjk | kljdskj |lkjdlj |
    b | kjhdkjh | kldjkj |
    c | jndojkok |
    d |
    this data which is in the application server file is brought into a internal table as a text. Now i need to send 'a' to one internal table, 'b' to one internal table, so on... help me
    <Priority downgraded>
    Edited by: Suhas Saha on Oct 12, 2011 12:24 PM

    Hi pradeep,
    eg...
    a | jhkhjk | kljdskj |lkjdlj |
    b | kjhdkjh | kldjkj |
    c | jndojkok |
    d |
    As per your statement "Now i need to send 'a' to one internal table, 'b' to one internal table"
    Do you want only a to one internal table and b to one internal table
    OR
    Do you want the whole row of the internal table i mean
    a | jhkhjk | kljdskj |lkjdlj | to 1 internal table
    Having the case of an internal table which is of type string,
    1) Loop through the internal table.    LOOP AT lt_tab INTO lwa_tab.
    2) Ge the work area contents and get the first char wa_tab-string+0(1)
    3)   FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
      w_tabname = p_table.
      CREATE DATA w_dref TYPE TABLE OF (w_tabname).
      ASSIGN w_dref->* TO <t_itab>.
    Follow the link
    http://www.sap-img.com/ab030.htm
    http://www.sapdev.co.uk/tips/dynamic-structure.htm
    and then based on the sy-tabix values you will get that many number of internal table
           <FS> = wa_tab-string+0(1)
          append  <FS>
    OR
    USE SPLIT statement at the relevant seperator
    revert for further clarification
    Thanks
    Sri
    Edited by: SRIKANTH P on Oct 12, 2011 12:36 PM

  • How to caputre report output into an internal table?

    Hi,
    Is there a way to capture report output into one internal table?
    Regards,
    Amruth

    Hi Amruth,
    Use SUBMIT.. EXPORTING LIST TO MEMORY.
    It saves  the output of a report into memory. Use the function modules LIST_FROM_MEMORY. WRITE_LIST & DISPLAY_LIST to retrieve the data.
    All these function modules belongs to function group 'SLST'.
    However the submit does not display hte output list of the called report, but saves it in ABAP memory & leaves the called report immediately. Since the calling program can read the list from memory & process it furthe, you need to use the addition ..AND RETURN.
    Regards,
    Chandru

  • Exporting An message Internal table to Standard program Internal Table

    Hi,
      In T-code VOFM, We have Goods issue routine 113, Now in Custmizing 913 is Configured. we are Checking the status of each handling unit of the Delivery. So I am getting the status Incomeplete Message for Multipe HU's. hence AM storing into One internal Table and Now I want To Export That Internal Table to Standard Program Internal Table 'WAT'.
    If I raise

    Elaborate your questions Please.

  • My MBA was stolen. I need to buy a replacement the next day bec I used it for work. I downloaded the Find iPhone apps and registered my stolen MBA. If I will erase MAC will it also erase the data of my new MBA?

    My MBA was stolen. I need to buy a replacement the next day bec I used it for work. I downloaded the Find iPhone apps and registered my stolen MBA. If I will erase MAC will it also erase the data of my new MBA?

    did you turn 'find my mac' ON your MBA BEFORE your it was stolen? if not, you will not be able to do anything to the stolen MBA
    if you did turn it on before it was stolen, yes it will erase everything on the MBA

  • How to read a table and transfer the data into an internal table?

    Hello,
    I try to read all the data from a table (all attribute values from a node) and to write these data into an internal table. Any idea how to do this?
    Thanks for any help.

    Hi,
    Check this code.
    Here i creates context one node i.e  flights and attributes are from SFLIGHT table.
    DATA: lo_nd_flights TYPE REF TO if_wd_context_node,
            lo_el_flights TYPE REF TO if_wd_context_element,
            ls_flights TYPE if_main=>element_flights,
            it_flights type if_main=>elements_flights.
    navigate from <CONTEXT> to <FLIGHTS> via lead selection
      lo_nd_flights = wd_context->get_child_node( 'FLIGHTS' ).
    CALL METHOD LO_ND_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE
      IMPORTING
        TABLE  = it_flights.
    now the table data will be in internal table it_flights.

Maybe you are looking for

  • Need Help Calculating Credit Card Payments

    Okay, let's say that I owe my credit card company $2000.00, and they're charging me 20% APR, based on my average daily balance. If I send them $30/week, then how many weeks will it take me to pay them off? It seems like there should be a Financial Fu

  • Any method has similar function as 'when_mouse_enter' trigger in 10g

    in 10g, we cannot use 'when_mouse_enter', 'when_mouse_leave' functions, is there any other functions have similar interactive functions in 10g?

  • Low market price using Material Ledger for FG

    Hi dear Experts, We are using Material ledger for valuating 1 FG material with out quantity structure and its goning well but in the opening of a new plant after the actual costing calculation with have to adjust the actual cost to the low market pri

  • Feature request: a smarter phonebook

    Hi, Today we struggle daily with numerous lists of data on devices: thousands of songs in an mp3 player, or countless emails, or just the files in your computer. And the tools for managing those lists are never good enough. When it comes to phonebook

  • Exporting data to Excel file

    I am curious what the "best practice" is for exporting data programmaticly from SQL Server to Excel.  Is it best to do it straight from SQL Server, or should I do it with in my C# code?  My program is going to pull the data, put in the excel file, th


HashFlare