2007 Aug 15 7:04 AM
hi exerts,
how to upload data from xlsheet to sap.
thanks in advance
radhakrishna.
9343479997.
2007 Aug 15 7:07 AM
Hi,
u can use the FM
gui_upload
or
alsm_excel_to_internal_table.
Both FM will upload the data from Presenatation server to Internal table.
Revert back if any issues.
Reward with points if helpful.
Regards,
Naveen
hi exerts,
how to upload data from xlsheet to sap.
thanks in advance
radhakrishna.
9343479997.
2007 Aug 15 7:07 AM
Hi,
u can use the FM
gui_upload
or
alsm_excel_to_internal_table.
Both FM will upload the data from Presenatation server to Internal table.
Revert back if any issues.
Reward with points if helpful.
Regards,
Naveen
2007 Aug 15 7:10 AM
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
I_LINE_HEADER =
I_TAB_RAW_DATA = i_temp
I_FILENAME = fl_file
TABLES
I_TAB_CONVERTED_DATA = i_articles
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.
ENDFORM. " UploadData
GUI_UPLOAD will convert your excel file to an internal file that can be interpreted by SAP. It then passes this internal file to TEXT_CONVERT_XLS_TO_SAP which in turn would convert the data into what you have defined in your internal table. No need to convert your excel file to a tab-delimited one.
2007 Aug 15 7:11 AM
Hi
Happy Independence Day To All Indians
use fm alsm_excel_to_internal_table. or check this code
use this code for how to upload file into internal table
data: L_FILETABLE TYPE FILETABLE,
L_FILETAB_H TYPE FILETABLE WITH HEADER LINE.
data: begin of itab_string occurs 0,
record type char255,
end of itab_string.
data: p_file1 type string.
selection screen .
PARAMETERS: P_FILE TYPE LOCALFILE.
at selection-screen on value-request for P_FILE.
IF THE USER SELECT EXTENTION BUTTON IT WILL OPEN THE LOCAL DIRECTORY FOR SELECTING THE FILE LOCATION.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION = 'CSV'
DEFAULT_FILENAME = 'C:\Documents and Settings\kiran\Desktop\STATUS.csv'
FILE_FILTER =
INITIAL_DIRECTORY = 'C:\Documents and Settings\kiran\Desktop\'
MULTISELECTION =
WITH_ENCODING =
CHANGING
FILE_TABLE = L_FILETABLE
RC = RC
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
IF SY-SUBRC <> 0.
ELSE.
LOOP AT l_filetable INTO L_FILETAB_H.
P_FILE = L_FILETAB_H-FILENAME.
move p_file to p_file1.
EXIT.
ENDLOOP.
ENDIF.
passing the selected file name to gui_upload for loading the data
into internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab_string
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 I000(Z00) WITH 'PLEASE PROVIDE CORRECT FILE NAME'.
ENDIF.
Reward points
kiran.M
please reward points for helpful ans's AND CLOSE THREAD
kiran.M
2007 Aug 15 8:26 AM
hi, try this code:
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION F4_FILENAME
EXPORTING
field_name = P_FILE
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION TEXT_CONVERT_XLS_TO_SAP
EXPORTING
I_FIELD_SEPERATOR =
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
***********************************************************************
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
reward points if it helps.
rgds