DATA UPLOAD into 5 Different Internal Tables !!!

Hi ABAPers,
I have data in 5 different TABS of an Excel Sheet.
I have to UPLOAD this data in these different TABS to 5 different Internal tables.
Can any one give me a solution to this ???

take data from all internal tabels into final internal table.....and proceed in below way......
fill ur inetnal table and call call the below form DOWNLOAD_TO_EXCEL, This Form is displaying an internal table it_outtab
Move data from it_outtab to it_excel
it_excel will contain all the charecter fields
DATA : BEGIN OF IT_EXCEL OCCURS 0,
FLD1(32),
FLD2(32),
FLD3(32),
FLD4(32),
FLD5(32),
FLD6(32),
FLD7(32),
FLD8(32),
FLD9(32),
FLD10(32),
FLD11(32),
FLD12(32),
FLD13(32),
FLD14(32),
FLD15(32),
FLD16(32),
FLD17(32),
FLD18(32),
FLD19(32),
FLD20(32),
FLD21(32),
END OF IT_EXCEL.
FORM DOWNLOAD_TO_EXCEL.
PERFORM GET_FILE_NAME .
CLEAR IT_EXCEL.
REFRESH IT_EXCEL.
IF NOT FNAME IS INITIAL .
PERFORM POPULATE_HEADER_DETAIL.
LOOP AT IT_OUTTAB.
IT_EXCEL-FLD1 = IT_OUTTAB-BANFN.
IT_EXCEL-FLD2 = IT_OUTTAB-BNFPO.
IT_EXCEL-FLD3 = IT_OUTTAB-EBELN.
IT_EXCEL-FLD4 = IT_OUTTAB-EBELP.
IT_EXCEL-FLD5 = IT_OUTTAB-STYLE.
IT_EXCEL-FLD6 = IT_OUTTAB-SKU.
IT_EXCEL-FLD7 = IT_OUTTAB-LP_COLOR.
IT_EXCEL-FLD8 = IT_OUTTAB-MAKTX.
IT_EXCEL-FLD9 = IT_OUTTAB-CURR_PRICE.
IF NOT IT_OUTTAB-VALID_FROM IS INITIAL.
CONCATENATE IT_OUTTAB-VALID_FROM+4(2) '/'
IT_OUTTAB-VALID_FROM+6(2) '/'
IT_OUTTAB-VALID_FROM(4) INTO IT_EXCEL-FLD10.
ENDIF.
IF NOT IT_OUTTAB-VALID_TO IS INITIAL.
CONCATENATE IT_OUTTAB-VALID_TO+4(2) '/'
IT_OUTTAB-VALID_TO+6(2) '/'
IT_OUTTAB-VALID_TO(4) INTO IT_EXCEL-FLD11.
ENDIF.
IT_EXCEL-FLD12 = IT_OUTTAB-FUT_PRICE.
IT_EXCEL-FLD13 = IT_OUTTAB-FAC_PRICE.
IF NOT IT_OUTTAB-FAC_VALID_FROM IS INITIAL.
CONCATENATE IT_OUTTAB-FAC_VALID_FROM+4(2) '/'
IT_OUTTAB-FAC_VALID_FROM+6(2) '/'
IT_OUTTAB-FAC_VALID_FROM(4) INTO IT_EXCEL-FLD14.
ENDIF.
IF NOT IT_OUTTAB-FAC_VALID_TO IS INITIAL.
CONCATENATE IT_OUTTAB-FAC_VALID_TO+4(2) '/'
IT_OUTTAB-FAC_VALID_TO+6(2) '/'
IT_OUTTAB-FAC_VALID_TO(4) INTO IT_EXCEL-FLD15.
ENDIF.
IT_EXCEL-FLD16 = IT_OUTTAB-JPN_PRICE.
IT_EXCEL-FLD17 = IT_OUTTAB-EAN11_1.
IT_EXCEL-FLD18 = IT_OUTTAB-EAN11_2.
IT_EXCEL-FLD19 = IT_OUTTAB-HANG_TAG_STAT.
IT_EXCEL-FLD20 = IT_OUTTAB-LABEL_STAT.
IT_EXCEL-FLD21 = IT_OUTTAB-CJI_STAT.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
ENDLOOP.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
CHECK_VERSION = ' '
DATA_NAME = FNAME
DATA_PATH_FLAG = ''
DATA_TYPE = 'DAT'
DATA_BIN_FILE_SIZE =
MACRO_NAME = ' '
MACRO_PATH_FLAG = 'E'
FORCE_START = ' '
WAIT = ''
IMPORTING
WINID =
TABLES
DATA_TAB = IT_EXCEL
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
WRONG_VERSION = 3
INTERNAL_ERROR = 4
INVALID_TYPE = 5
CANCELLED = 6
DOWNLOAD_ERROR = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF .
ENDFORM. " DOWNLOAD_TO_EXCEL
FORM GET_FILE_NAME.
DATA: TMP_FILENAME LIKE RLGRAP-FILENAME,
GLOBAL_FILEMASK_ALL(80),
GLOBAL_FILEMASK_MASK(20), GLOBAL_FILEMASK_TEXT(20),
GLOBAL_DOWNLOAD_PATH LIKE RLGRAP-FILENAME,
DEF_PATH LIKE RLGRAP-FILENAME,
FIELDLN TYPE I,
MODE TYPE C,
TMP_MASK LIKE GLOBAL_FILEMASK_ALL.
FIELD-SYMBOLS: .
IF GLOBAL_FILEMASK_MASK IS INITIAL.
TMP_MASK = ',.,..'.
ELSE.
TMP_MASK = ','.
WRITE GLOBAL_FILEMASK_TEXT TO TMP_MASK+1.
WRITE ',' TO TMP_MASK+21.
WRITE GLOBAL_FILEMASK_MASK TO TMP_MASK+22.
WRITE '.' TO TMP_MASK+42.
CONDENSE TMP_MASK NO-GAPS.
ENDIF.
IF NOT GLOBAL_FILEMASK_ALL IS INITIAL.
TMP_MASK = GLOBAL_FILEMASK_ALL.
ENDIF.
FIELDLN = STRLEN( DEF_PATH ) - 1.
ASSIGN DEF_PATH+FIELDLN(1) TO .
ENDIF.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = FNAME "rlgrap-filename
DEF_PATH = DEF_PATH
MASK = TMP_MASK
MODE = MODE
TITLE = ' '
IMPORTING
FILENAME = FNAME
RC =
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04.
IF SY-SUBRC = 0.
FNAME = TMP_FILENAME.
ELSE.
ENDIF.
ENDFORM. " GET_FILE_NAME
FORM POPULATE_HEADER_DETAIL.
IT_EXCEL-FLD8 = 'S U D H E E R'.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
IT_EXCEL-FLD1 = 'Price Validation Report'.
IT_EXCEL-FLD14 = 'Page'.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
IT_EXCEL-FLD1 = 'Vendor Number/Name'.
IT_EXCEL-FLD3 = 'Plan Month'.
IT_EXCEL-FLD4 = 'Effective In-store-Date'.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
IT_EXCEL-FLD1 = VENDOR_NAME.
IT_EXCEL-FLD3 = P_BEDNR.
IT_EXCEL-FLD4 = P_EFF_DT.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
sudheer start
APPEND IT_EXCEL.
IT_EXCEL-FLD1 = 'PR'.
IT_EXCEL-FLD2 = 'Line'.
IT_EXCEL-FLD3 = 'PO'.
IT_EXCEL-FLD4 = 'PO Line'.
IT_EXCEL-FLD5 = 'Style'.
IT_EXCEL-FLD6 = 'SKU'.
IT_EXCEL-FLD7 = 'Long Color'.
IT_EXCEL-FLD8 = 'Material Description'.
IT_EXCEL-FLD9 = 'Current Price'.
IT_EXCEL-FLD10 = 'validity'.
IT_EXCEL-FLD11 = 'Period'.
IT_EXCEL-FLD12 = 'Future Price'.
IT_EXCEL-FLD13 = 'Factory Price'.
IT_EXCEL-FLD14 = 'Validity'.
IT_EXCEL-FLD15 = 'Period'.
IT_EXCEL-FLD16 = 'Japan Price'.
IT_EXCEL-FLD17 = 'First UPC'.
IT_EXCEL-FLD18 = 'Factory UPC'.
IT_EXCEL-FLD19 = 'Hang Tag Status'.
IT_EXCEL-FLD20 = 'Label Status'.
IT_EXCEL-FLD21 = 'CJI Label Status'.
*sudheer end
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
ENDFORM. " POPULATE_HEADER_DETAIL
Check these links for sample code :
http://www.sapdevelopment.co.uk/ms/ms_excel.htm
please check this example:
FORM download.
DATA: lh_file1 TYPE rlgrap-filename,
lh_file2 TYPE rlgrap-filename,
lh_file3 TYPE rlgrap-filename,
lh_datda(1).
CLEAR: lh_file1, lh_file2, lh_file3.
Download neue Daten
CONCATENATE xh_pfad 'Datafile materialmaster new ' sy-datum(4)
sy-datum4(2) sy-datum6(2) sy-uzeit '.xls' INTO lh_file1.
working area
DATA: index TYPE i,
lh_col TYPE i.
FIELD-SYMBOLS: .
SORT xt_bmm00 BY matnr.
SORT xt_bmmh1 BY matnr.
SORT xt_bmmh4 BY matnr.
SORT xt_bmmh7 BY matnr.
IF NOT xt_bmm00[] IS INITIAL.
MOVE 'X' TO lh_datda.
DO 4 TIMES.
CASE sy-index.
WHEN 1.
CREATE OBJECT lh_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF lh_excel 'Visible' = 1 .
GET PROPERTY OF lh_excel 'Workbooks' = lh_workbooks .
GET PROPERTY OF lh_workbooks 'Application' = lh_application .
SET PROPERTY OF lh_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF lh_workbooks 'Add' = lh_workbook .
CALL METHOD OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = sy-index .
SET PROPERTY OF lh_sheet 'NAME' = 'BMMH7'.
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S005'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmmh7.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmmh7 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 2.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMMH4'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMMH4'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S004'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmmh4.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmmh4 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 3.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMMH1'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMMH1'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S003'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
Die folgende Abfrage ist notwendig, weil der Namensraum ZZ...
in der Struktur nicht erlaubt ist, aber im Excel-Sheet als
Überschrift gebraucht wird.
IF xt_ftab-fieldname = 'SPIRIDON'.
MOVE 'ZZSSN' TO xt_ftab-fieldname.
ENDIF.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmmh1.
index = sy-tabix + 1.
DO 72 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmmh1 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 4.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMM00'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMM00'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S002'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmm00.
index = sy-tabix + 1.
DO 21 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmm00 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
ENDCASE.
ENDDO.
CALL METHOD OF lh_workbook 'SAVEAS'
EXPORTING #1 = lh_file1.
CALL METHOD OF lh_excel 'QUIT'.
FREE OBJECT: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
ENDIF.
Download geänderter Materialstammdaten
CONCATENATE xh_pfad 'Datafile materialmaster change ' sy-datum(4)
sy-datum4(2) sy-datum6(2) sy-uzeit '.xls' INTO lh_file2.
IF NOT xt_emmh1[] IS INITIAL.
MOVE 'X' TO lh_datda.
DO 2 TIMES.
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = sy-index .
CASE sy-index.
WHEN 1.
CREATE OBJECT lh_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF lh_excel 'Visible' = 1 .
GET PROPERTY OF lh_excel 'Workbooks' = lh_workbooks .
GET PROPERTY OF lh_workbooks 'Application' = lh_application .
SET PROPERTY OF lh_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF lh_workbooks 'Add' = lh_workbook .
CALL METHOD OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = sy-index .
SET PROPERTY OF lh_sheet 'NAME' = 'BMMH7'.
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S005'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_emmh7.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_emmh7 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 2.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMMH1'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMMH1'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S003'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
Die folgende Abfrage ist notwendig, weil der Namensraum ZZ...
in der Struktur nicht erlaubt ist, aber im Excel-Sheet als
Überschrift gebraucht wird.
IF xt_ftab-fieldname = 'SPIRIDON'.
MOVE 'ZZSSN' TO xt_ftab-fieldname.
ENDIF.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_emmh1.
index = sy-tabix + 1.
DO 72 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_emmh1 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
ENDCASE.
ENDDO.
CALL METHOD OF lh_workbook 'SAVEAS'
EXPORTING #1 = lh_file2.
CALL METHOD OF lh_excel 'QUIT'.
FREE OBJECT: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
ENDIF.
Download geänderter Texte
CONCATENATE xh_pfad 'Datafile materialmaster change PO ' sy-datum(4)
sy-datum4(2) sy-datum6(2) sy-uzeit '.xls' INTO lh_file3.
IF NOT xt_tmmh7[] IS INITIAL.
CLEAR: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
MOVE 'X' TO lh_datda.
CREATE OBJECT lh_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF lh_excel 'Visible' = 1 .
GET PROPERTY OF lh_excel 'Workbooks' = lh_workbooks .
GET PROPERTY OF lh_workbooks 'Application' = lh_application .
SET PROPERTY OF lh_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF lh_workbooks 'Add' = lh_workbook .
CALL METHOD OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = 1 .
SET PROPERTY OF lh_sheet 'NAME' = 'BMMH7'.
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S005'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_tmmh7.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_tmmh7 TO  lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
CALL METHOD OF lh_workbook 'SAVEAS'
EXPORTING #1 = lh_file3.
CALL METHOD OF lh_excel 'QUIT'.
FREE OBJECT: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
ENDIF.
IF lh_datda NE 'X'.
MESSAGE i016.
ENDIF.
ENDFORM. " download
FORM fill_cell USING p_i
value
p_customer_cell1
h_excel
h_cells.
CALL METHOD OF h_excel 'Cells' = h_cells EXPORTING #1 = p_i #2 = value.
SET PROPERTY OF lh_cells 'Numberformat' = '@'.
SET PROPERTY OF h_cells 'Value' = p_customer_cell1.
ENDFORM. " fill_cell

Similar Messages

  • Excel data transfer into SAP internal table with GUI_UPLOAD

    hi all,
      i m using SRM4 system and i wanted to develop one report which will upload data from excel and convert it into IT.
    i know that many threads are posted on this topic.
    but my requirement is slight different. in the system only one function module is available that is "GUI_UPLOAD" and we want that user shd not save file as tab delimited before calling this fm. instead, program shd take care of all these things...
    please suggest something asap..
    helpful ans will be rewarded..
    thanks,
    jigs.

    Dear Jigs,
    Please go though the following lines of code:
    D A T A D E C L A R A T I O N *
    TABLES: ANEP,
    BKPF.
    TYPES: BEGIN OF TY_TABDATA,
    MANDT LIKE SY-MANDT, " Client
    ZSLNUM LIKE ZSHIFTDEPN-ZSLNUM, " Serial Number
    ZASSET LIKE ZSHIFTDEPN-ZASSET, " Original asset that was transferred
    ZYEAR LIKE ZSHIFTDEPN-ZYEAR, " Fiscal Year
    ZPERIOD LIKE ZSHIFTDEPN-ZPERIOD, " Fiscal Period
    ZSHIFT1 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 1
    ZSHIFT2 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 2
    ZSHIFT3 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 3
    END OF TY_TABDATA.
    Declaration of the Internal Table with Header Line comprising of the uploaded data.
    DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.
    INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
    DATA: END OF IT_FILE_UPLOAD.
    S E L E C T I O N - S C R E E N *
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,
    BEGIN OF BLOCK B2 WITH FRAME.
    PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK B2,
    END OF BLOCK B1.
    E V E N T : AT S E L E C T I O N - S C R E E N *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    PROGRAM_NAME = SYST-REPID
    DYNPRO_NUMBER = SYST-DYNNR
    FIELD_NAME = ' '
    STATIC = 'X'
    MASK = '.'
    CHANGING
    FILE_NAME = P_FNAME
    EXCEPTIONS
    MASK_TOO_LONG = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    E V E N T : S T A R T - O F - S E L E C T I O N *
    START-OF-SELECTION.
    Upload Excel file into Internal Table.
    PERFORM UPLOAD_EXCEL_FILE.
    Organize the uploaded data into another Internal Table.
    PERFORM ORGANIZE_UPLOADED_DATA.
    E V E N T : E N D - O F - S E L E C T I O N *
    END-OF-SELECTION.
    *& Form UPLOAD_EXCEL_FILE
    text
    --> p1 text
    <-- p2 text
    FORM UPLOAD_EXCEL_FILE .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = P_FNAME
    I_BEGIN_COL = 1
    I_BEGIN_ROW = 3
    I_END_COL = 7
    I_END_ROW = 32000
    TABLES
    INTERN = IT_FILE_UPLOAD
    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. " UPLOAD_EXCEL_FILE
    *& Form ORGANIZE_UPLOADED_DATA
    text
    --> p1 text
    <-- p2 text
    FORM ORGANIZE_UPLOADED_DATA .
    SORT IT_FILE_UPLOAD BY ROW
    COL.
    LOOP AT IT_FILE_UPLOAD.
    CASE IT_FILE_UPLOAD-COL.
    WHEN 1.
    WA_TABDATA-ZSLNUM = IT_FILE_UPLOAD-VALUE.
    WHEN 2.
    WA_TABDATA-ZASSET = IT_FILE_UPLOAD-VALUE.
    WHEN 3.
    WA_TABDATA-ZYEAR = IT_FILE_UPLOAD-VALUE.
    WHEN 4.
    WA_TABDATA-ZPERIOD = IT_FILE_UPLOAD-VALUE.
    WHEN 5.
    WA_TABDATA-ZSHIFT1 = IT_FILE_UPLOAD-VALUE.
    WHEN 6.
    WA_TABDATA-ZSHIFT2 = IT_FILE_UPLOAD-VALUE.
    WHEN 7.
    WA_TABDATA-ZSHIFT3 = IT_FILE_UPLOAD-VALUE.
    ENDCASE.
    AT END OF ROW.
    WA_TABDATA-MANDT = SY-MANDT.
    APPEND WA_TABDATA TO IT_TABDATA.
    CLEAR: WA_TABDATA.
    ENDAT.
    ENDLOOP.
    ENDFORM. " ORGANIZE_UPLOADED_DATA
    In the subroutine --> ORGANIZE_UPLOADED_DATA, data are organized as per the structure declared above.
    Regards,
    Abir
    Don't forget to award points *

  • How to bring data from 3 different internal table to one

    hii all,
              i have 3 internal table ls_mat,which has around 20 fields,it_stpo,which has 3 fields,and it_mast,i need to bring all these 3 table data in one tabel...how do i do...plzz help...

    Hi ,
    Does this internal table have any fields in common in all the three.
    If yes , then loop ls_mat
    Declare a type will all the fields and create a structure and internal table with that type (for ex lx_final and lt_final respectively)
    Loop at ls_mat into lx_mat.
    1.copy all the fields of lx_mat to respective lx_final.
    2.read table it_stpo into lx_stpo with key field = lx_mat-field.
    3.Copy all fields of lx_stpo to respective lx_final.
    4. read table it_mast into lx_mast with key field = lx_mat-field.
    5. copy all fields of lx_mast to respective lx_final.
    6. now append lx_final to lt_final.
    Endloop.
    now you can get all values inside lt_final.
    Regards,
    sivaganesh

  • Error during uploading into an internal table

    Hi all,
    I am uploading flat files of either type excel and text. i have used the appropriate function modules(Gui_upload and Text_raw_excel to sap) but while testing it i found the following two things:
    1. In excel file if it has 3 records , only 2 get updated. if there are 2 only 1 gets updated.
    2. IN text file if it has more than 1 record only the first one gets updated and for the others it gives bad file format.
    Please help me out
    Regards,
    Varun

    Hi,
        Refer
    https://forums.sdn.sap.com/click.jspa?searchID=8909280&messageID=4126977
    Regards
    Kiran Sure

  • How can i add two table data into third internal table see below

    hi i insert diffferent table data into different internal table i did try to insert two different internal table data into third internal table by using move
    but only single data is coming please help me
    i want this two internal table data inot third internal table.
    sELECT  * FROM J_1IEXCHDR INTO CORRESPONDING FIELDS OF ITAB1 WHERE STATUS = 'P'.
    SELECT * FROM J_1IEXCDTL INTO CORRESPONDING FIELDS OF ITAB2  WHERE LIFNR = J_1IEXCHDR-LIFNR.
                             AND DOCYR  = J_1IEXCHDR-DOCYR,
                             AND DOCNO  = J_1IEXCHDR-DOCNO.
    WRITE: /  ITAB1-LIFNR,
              ITAB1-DOCNO,
              ITAB1-EXYEAR,
              ITAB1-BUDAT,
              ITAB2-EXBED,
              ITAB2-RDOC,
              ITAB2-ECS.
    ENDSELECT.
    ENDSELECT.
    thank you .

    hi
      Two add two internal tables data.  first we need to create third internal table with all the fields of first two internal tables.
    later u move the two internal tables data to third internal table
    by looping the internal table which have more records or depending on the requirement and move the corresponding fields of first internal table to the third internal table and use the read statement with condition based on primary key of first itab and get the corresponding data of 2table into 3table.
    i am sending the sample code to u.
    check it out. i think u will understand how to move.
    select vbeln waerk netwr erdat audat kunnr
       into table it_vbeln
       from vbak
       where vbeln in s_vbeln
         and erdat in s_erdat.
      if not it_vbeln[] is initial.
      select kunnr name1
       into table it_kunnr
       from  kna1
       for all entries in it_vbeln
         where kunnr = it_vbeln-kunnr.
      endif.
      loop at it_vbeln.
      clear it_final.
       it_final-vbeln = it_vbeln-vbeln.
       it_final-waerk = it_vbeln-waerk.
       it_final-netwr = it_vbeln-netwr.
       it_final-erdat = it_vbeln-erdat.
       it_final-audat = it_vbeln-audat.
      read table it_kunnr with key kunnr = it_vbeln-kunnr.
       it_final-name1 = it_kunnr-name1.
      append it_final.
      endloop.

  • How to fetch the data from query to internal table ?

    Dear all ,
             I would like to fetch the query data(sq01) into my internal table ? is it possible to do that ?
    Best Regards,
    Carlos

    Hi
    Try this <b>RRW3_GET_QUERY_VIEW_DATA</b>
    Also, you can have a look at this...
    <a href="/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-ii Query results into Internal table</a>
    Regards
    Raj

  • How to insert  data from different internal  table  into a data base table

    hi all,
             I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
    in short i want to do something like the foll:
    INSERT  INTO ZMIS_CODES-CODE VALUE '1'.
    *INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)

    REPORT  ZINSERT.
    tables kna1.
    data: itab LIKE KNA1.
    data lv_kUNAG LIKE KNA1-KUNNR.
    lv_kuNAG =  '0000010223'.
    ITAB-kuNNR = lv_kuNAG.
    ITAB-name1 = 'XYZ'.
    INSERT INTO KNA1 VALUES ITAB.
    IF SY-SUBRC = 0.
    WRITE:/ 'SUCCESS'.
    ELSE.
    WRITE:/ 'FAILED'.
    ENDIF.
    Here lv_kunag is ref to kna1 kunnr passed in different name
    In internal table .
    Try and let me know if this logic dint work.

  • Passing data to different internal tables with different columns from a comma delimited file

    Hi,
    I have a program wherein we upload a comma delimited file and based on the region( we have drop down in the selection screen to pick the region).  Based on the region, the data from the file is passed to internal table. For region A, we have 10 columns and for region B we have 9 columns.
    There is a split statement (split at comma) used to break the data into different columns.
    I need to add hard error messages if the no. of columns in the uploaded file are incorrect. For example, if the uploaded file is of type region A, then the uploaded file should be split into 10 columns. If the file contains lesser or more columns thenan error message should be added. Similar is the case with region B.
    I do not want to remove the existing split statement(existing code). Is there a way I can exactly pass the data into the internal table accurately? I have gone through some posts where in they have made use of the method cl_alv_table_create=>create_dynamic_table by passing the field catalog. But I cannot use this as I have two different internal tables to be populated based on the region. Appreciate help on this.
    Thanks,
    Pavan

    Hi Abhishek,
    I have no issues with the rows. I have a file with format like a1,b1,c1,d1,e1, the file should be uploaded and split at comma. So far its fine. After this, if the file is related to region A say Asia, then it should have 5 fields( as an example). So, all the 5 values a1,b1..e1 will be passed to 5 fields of itab1.
    I also have region B( say Europe)  whose file will have only 4 fields. So, file is of the form a2,b2,c2,d2. Again data is split at comma and passed to itab2.
    If some one loads file related to Asia and the file has only 4 fields  then the data would be incorrect. Similar is the case when someone tries to load Europe file with 5 fields related data. To avoid this, I want to validate the data uploaded. For this, I want to count the no. of fields (seperated by comma). If no. of fields is 5 then the file is related to Asia or if no. of fields is 4 then it is Europe file.
    Well, the no. of commas is nothing but no. of fields - 1. If the file is of the form a1,b1..e1 then I can say like if no. of commas = 4 then it is File Asia.But I am not sure how to write a code for this.Please advise.
    Thanks,
    Pavan

  • Upload data from Excel to Internal table

    Hi,
    I am facing a peculiar problem in uploading the data in excel sheet to internal table.
    The excel file contains material number and product hierarchy number. The product hierarchy number for some material is downloaded as 5.73101E17 for the value 573100910115782000. Though I expand the sheet the display is the same 5.73101E17. When i upload the sheet using the f'n module "ALSM_EXCEL_TO_INTERNAL_TABLE" the value is taken as it is (5.73101E+17) into the internal table which is wrong. I tried to change the data type to type n. Then the value is uploaded as 5731011700000000.
    Please propose a solution to this without having to change the format of the column from general to "number without decimals"
    Regards,
    Sam

    HI
    see this example code which EXCEL TO INTERNAL TABLE AND THEN TO APPLICATION
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 1
       OTHERS              = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    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.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • Upload data from Excel to internal table without using Screen

    Hi,
    My reqirment is to read the excel input data and then upload it to internal table for further proceeing but without using selection input screen. I mean can I mention the fixed file name and the path in the function module iself for the input file.

    1.First create one internal table as u have created ur EXCEL file.
    e.g: if ur EXCEL file contains 3 fields col1 col2 and col3.
           data: begin of wa,
                     col1(10),
                     col2(10),
                     col3(10),
                   end of wa,
                   itab like standard table of wa.
    data: filename type string 'C:\FOLDER\DATA.XLS'
    If u dont want to use the screen, then pass the file name directly to the GUI_UPLOAD FM.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = filename
       FILETYPE                      = '.XLS'
      tables
        data_tab                      = itab
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    This will serve ur puspose.
    loop at itab into wa.
    write: / wa-col1,wa-col2,wa-col3.
    endloop.
    Thanks & Regards
    Santhosh

  • How to read data in correct format from EXCEL file into an internal table??

    Hi Experts,
    My requirement is to upload data from an excel file on presentation server into an internal table on <b>SRM</b> server.
    I used 'GUI_UPLOAD' function module to achieve the same but all the the data is getting uploaded in # only.I had set in the 'HAS_FIELD_SEPARATOR' to 'X' to overcome this problem.
    But all the efforts are in vain. The function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' doesn't exist on SRM Server and I am not getting any other function module having similar functionality available on SRM server.
    I have written the following code:-
    TYPES: BEGIN OF ty_addr_loc,
             userid    TYPE xubname,      "User Id
             addr_code TYPE char4,        "3 Digit Site Location Code/4 Digit
                                                       "Alternate Address
             loc_id    TYPE bbp_location, "Indicator: Address is standard address
            END OF ty_addr_loc.
    *Retrieving file name
    parameters: p_file type rlgrap-filename.
      DATA:
        Local variable holding file name
          l_file TYPE string,
        Local Variable holding the file type,
          l_type TYPE filetype VALUE 'ASC',
        Local Variable holding the field separator
          l_sep  TYPE char01,
          i_tab type standard table of ty_addr_loc.
    Clearing local variables
      CLEAR:
            l_file,
            l_sep.
    Initializing the local variables
      MOVE p_file TO l_file.
      l_sep = 'X'.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = l_file
          filetype                      = l_type
          has_field_separator           = l_sep
       HEADER_LENGTH                 = 0
       READ_BY_LINE                  = 'X'
       DAT_MODE                      = ' '
       CODEPAGE                      = ' '
       IGNORE_CERR                   = ABAP_TRUE
       REPLACEMENT                   = '#'
       CHECK_BOM                     = ' '
       VIRUS_SCAN_PROFILE            =
       NO_AUTH_CHECK                 = ' '
    IMPORTING
       FILELENGTH                    =
       HEADER                        =
        TABLES
          data_tab                     = i_tab
       EXCEPTIONS
         file_open_error               = 1
         file_read_error               = 2
         no_batch                      = 3
         gui_refuse_filetransfer       = 4
         invalid_type                  = 5
         no_authority                  = 6
         unknown_error                 = 7
         bad_data_format               = 8
         header_not_allowed            = 9
         separator_not_allowed         = 10
         header_too_long               = 11
         unknown_dp_error              = 12
         access_denied                 = 13
         dp_out_of_memory              = 14
         disk_full                     = 15
         dp_timeout                    = 16
         OTHERS                        = 17
      IF sy-subrc <> 0.
      Throwing an information message
        MESSAGE i003. "Data Upload Failed
        LEAVE LIST-PROCESSING.
      ENDIF.
    Please tell me a way out. I have to make a delivery urgently.
    Thanks in advance,
    Swati Gupta

    Hi
    Try the FM <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b>
    Sample:
      call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
           exporting
                filename                = i_filename
                i_begin_col             = l_begin_col
                i_begin_row             = l_begin_row
                i_end_col               = l_end_col
                i_end_row               = l_end_row
           tables
                intern                  = xt_intern
           exceptions
                INCONSISTENT_PARAMETERS = 201
                UPLOAD_OLE              = 201.
      if sy-subrc <> 0.
        e_subrc = sy-subrc.
        exit.
      endif.
    <b>reward if Helpful.</b>

  • Upload an XML file into the Internal table

    Hi Guys,
    I want to know, how to upload an xml file into the Internal table through ABAP programming

    you just wanted to load the xml file into internal table (as a table of binary strings)or load the xml data mapped to itab row columns
    for the first one you can simply use gui_upload
    and for the second one you need to load the xml file using gui_upload and use XLST program to transform into an itab
    Regards
    Raja

  • Collect data from a dynamic XML file into multiple internal tables

    I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
    My XML file is of the following type.It is very complex and the dynamice.
    The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
    "I" and "L" are child tags of <C>
    <I>
           <J>10</J>
             <K>EN</K>
      </I>
    <L>
             <J>20</J>
              <N>BB</N>
      </L>
    Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
    I need to collect <D>, <E> in one internal table ITAB.
    I need to collect <G>, <H> in one internal table JTAB.
    I need to collect <J>, <K> in one internal table KTAB.
    I need to collect <J>, <N> in one internal table PTAB.
    Below is the complete XML file.
    ?xml version="1.0" encoding="iso-8859-1" ?>
    <A>
        <B/>
        <C>
           <D>RED</D>
           <E>999</E>
        <F>
           <G>TRACK</G>
           <H>PACK</H>
        </F>
        <I>
           <J>10</J>
           <K>EN</K>
        </I>
        <I>
           <J>20</J>
           <K>TN</K>
        </I>
        <I>
           <J>30</J>
           <K>KN</K>
        </I>
        <L>
           <J>10</J>
           <N>AA</N>
        </L>
        <L>
           <J>20</J>
           <N>BB</N>
        </L>
        <L>
           <J>30</J>
           <N>CC</N>
        </L>
        </C>
      </A>
    With the help of SDN I am able to gather the values of <D> <E> in one internal table.
    Now if I need to gather
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    I am unable to do. I am following  XSLT transformation method. If some one has some suggestions. Please help.
    Here is my ABAP program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ITAB,
             D(10) TYPE C,
             E(10) TYPE C,
           END OF ITAB.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_ITAB     TYPE STANDARD TABLE OF ts_ITAB,
          gs_ITAB     TYPE ts_ITAB.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab1
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        not_supported_by_gui    = 17
        error_no_gui            = 18
        OTHERS                  = 19.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IITAB".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'IITAB'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION zxslt
        SOURCE XML gt_itab1
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Now let's see what we got from the file
    LOOP AT gt_ITAB INTO gs_ITAB.
      WRITE: / 'D:', gs_ITAB-D.
      WRITE: / 'E :', gs_ITAB-E.
    ENDLOOP.
    Transformation
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IITAB>
              <xsl:apply-templates select="//C"/>
            </IITAB>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <item>
          <D>
            <xsl:value-of select="D"/>
          </D>
          <E>
            <xsl:value-of select="E"/>
          </E>
        </item>
      </xsl:template>
    </xsl:transform>
    Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
    Kindly help.
    Regards,
    VS

    Hi Rammohan,
    Thanks for the effort!
    But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
    Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields.  I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
    Moreover I have about 10 such work areas.  so the effort would be ten times the above effort! I want to avoid this! Please help!
    I would be very grateful if you could provide an alternative solution.
    Thanks once again,
    Best Regards,
    Vinod.V

  • 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

  • Upload a .CSV File into an Internal table

    Hi,
    What are the parameters to be filled into the Function Modules "GUI_UPLOAD" and "ALSM_EXCEL_TO_INTERNAL_TABLE" to Upload a .CSV File into an internal table.
    Please send a sample code to support this....
    Regards,
    Aadhi.

    Hi,
            Check the below code.
    TYPE-POOLS: truxs.
    TYPES:
      BEGIN OF ty_line,
        vbeln LIKE vbap-vbeln,
        posnr LIKE vbap-posnr,
      END OF ty_line.
    *data:  ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
    DATA: itab   TYPE STANDARD TABLE OF ty_line WITH DEFAULT KEY.
    DATA: itab1  TYPE truxs_t_text_data.
    SELECT
      vbeln
      posnr
      UP TO 10 ROWS
      FROM vbap
      INTO TABLE itab.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
      EXPORTING
        i_field_seperator    = ';'
      TABLES
        i_tab_sap_data       = itab
      CHANGING
        i_tab_converted_data = itab1
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = 'd:\TEMP\test1.txt'
      TABLES
        data_tab = itab1
      EXCEPTIONS
        OTHERS   = 1.
    IF sy-subrc eq 0.
      WRITE: 'Data downloaded successfully'.
    ENDIF.
    DATA: BEGIN OF IEXCEL OCCURS 0.
          INCLUDE STRUCTURE ALSMEX_TABLINE.
    DATA: END OF IEXCEL.
    PARAMETERS: FILENM   LIKE rlgrap-filename MEMORY ID M01,
                NOHEADER AS CHECKBOX.
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      = FILENM
        i_begin_col                   = 1
        i_begin_row                  = 1
        i_end_col                     = 100
        i_end_row                     = 30000
      tables
        intern                        = IEXCEL
      EXCEPTIONS
        INCONSISTENT_PARAMETERS       = 1
        UPLOAD_OLE                    = 2
        OTHERS                        = 3.
    if sy-subrc <> 0.
       WRITE: / 'EXCEL UPLOAD FAILED ', FILENM, SY-SUBRC.
    endif.

Maybe you are looking for