‎2008 Nov 13 7:20 PM
Hi,
Using above function module for uploading excel in sap .But data is not bieng populated .
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
tables
i_tab_converted_data = it_datatab[] "ACTUAL DATA
exceptions
conversion_failed = 1
others = 2.
g_t_intab[] = it_datatab[].
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_data
loop at g_t_intab into g_t_record.
Regards
Ivneet
‎2008 Nov 14 5:11 AM
‎2008 Nov 14 5:17 AM
Hi ivneeth,
Try this code.
DATA:ta_file TYPE STANDARD TABLE OF alsmex_tabline,
wa_file TYPE alsmex_tabline.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pa_f
i_begin_col = '1'
i_begin_row = '3'
i_end_col = '13'
i_end_row = '5000'
TABLES
intern = ta_file
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc EQ 0.
LOOP AT ta_file INTO wa_file.
AT NEW row.
Clear the work area
CLEAR wa_file.
ENDAT.
For Column One
IF wa_file-col = '1'.
MOVE wa_file-value TO wa_tab-num.
ENDIF.
IF wa_file-col = '2'.
MOVE wa_file-value TO wa_tab-sno.
ENDIF.
For Column TWO
IF wa_file-col = '3'.
MOVE wa_file-value TO wa_tab-panel.
ENDIF.
*For Column 3
IF wa_file-col = '4'.
MOVE wa_file-value TO wa_tab-speck.
ENDIF.
*For Column 4
IF wa_file-col = '5'.
MOVE wa_file-value TO wa_tab-make.
ENDIF.
*For Column 5
IF wa_file-col = '6'.
MOVE wa_file-value TO wa_tab-quantity.
ENDIF.
*For Column 6
IF wa_file-col = '7'.
MOVE wa_file-value TO wa_tab-rate.
ENDIF.
*For Column 7
IF wa_file-col = '8'.
MOVE wa_file-value TO wa_tab-curr.
ENDIF.
AT END OF row.
The Data Transfer from work area to Internal table
APPEND wa_tab TO ta_tab.
CLEAR wa_tab.
ENDAT.
ENDLOOP.
ENDIF.
‎2008 Nov 14 5:26 AM
Hi
Use this code
TYPE-POOLS: truxs. "type-pools for upload excel file
DATA : p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab, " structure defination
(mention your fields)
END OF t_datatab.
DATA: it_datatab TYPE STANDARD TABLE OF t_datatab, "internal table
wa_datatab TYPE t_datatab. "work area
DATA: it_raw TYPE truxs_t_text_data. "work table internal table
CLEAR : p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
CLEAR :it_datatab .
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[]
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.
* endif.Ranga
‎2008 Nov 14 6:45 AM
‎2008 Nov 15 7:51 AM
Hi Ivneet,
For uploading data from excel file into SAP, you can follow these steps:-
First enter all the records in your excel file and save this file as TEXT (TAB DELIMITED).
This will result in a Text file with your records in separate lines and fields separated by a tab.
Now you can use this file to upload data into SAP.
************************************************************************************************************************
REPORT ZTG_VENDRP.
TYPES : BEGIN OF VENDOR,
LIFNR LIKE RF02K-LIFNR,
BUKRS LIKE RF02K-BUKRS,
EKORG LIKE RF02K-EKORG,
KTOKK LIKE RF02K-KTOKK,
ANRED LIKE LFA1-ANRED,
NAME1 LIKE LFA1-NAME1,
SORTL LIKE LFA1-SORTL,
LAND1 LIKE LFA1-LAND1,
SPRAS LIKE LFA1-SPRAS,
WAERS LIKE LFM1-WAERS,
END OF VENDOR.
DATA : VENDOR_TAB TYPE STANDARD TABLE OF VENDOR INITIAL SIZE 10 WITH HEADER LINE.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'c:\vendors.txt'
FILETYPE = 'DAT'
TABLES
DATA_TAB = VENDOR_TAB
************************************************************************************************************************
This will populate all your text file (excel) records into the internal table.
Now, you can use this table as per your requirements.
Hope this solves your problem.
Thanks & Regards.
Tarun Gambhir.