2008 Sep 02 5:14 AM
hi,
i need to create a program to upload excel file from application server(SAP UNIX server) into SAP for batch upload. can any one please advice how am i going to read the excel file and provide me the code?
thanks
hi,
i need to create a program to upload excel file from application server(SAP UNIX server) into SAP for batch upload. can any one please advice how am i going to read the excel file and provide me the code?
thanks
2008 Sep 02 5:21 AM
Hi ben,
You can use gui_upload Function module .
Here is the code to upload excel file:
DATA:
w_file TYPE string. " File name
DATA:
* Internal table to hold input file data
i_upload TYPE TABLE OF sflight.
*Uploading the file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'DAT'
has_field_separator = 'X'
TABLES
data_tab = i_upload
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 s001(zs) WITH space sy-subrc.
ENDIF. " IF sy-subrc ne 0And For Batch Upload you can use LSMW or BDC.
Thanks and regards
2008 Sep 04 8:28 AM
hi,
i try to use GUI_UPLOAD but i keep getting error message.
i try to use the below function to call, but it does not work for getting from application server. can you please advice.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = p_ex_r0
i_end_col = 13
i_end_row = p_ex_r1
TABLES
intern = it_ex_data[]
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.
2008 Sep 02 5:26 AM
Hi U can use GUI_UPLOAD with the FIELD SEPERATOR = 'X'
Hope It Helps ,,,
2008 Sep 02 5:30 AM
You can use CG3Z and CG3Y tcode to upload/download from application server.
2008 Sep 02 5:31 AM
2008 Sep 04 8:34 AM
Hi Ben,
Refer to following code:
data: gi_raw_data TYPE truxs_t_text_data,
parameter : gv_file type rlgrap-filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = sy-repid
dynpro_number = syst-dynnr
field_name = gv_file
CHANGING
file_name = gv_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID gv_msgid TYPE 'I' NUMBER 000.
ENDIF.
FIND '.xls' IN gv_file IGNORING CASE.
IF sy-subrc NE 0.
Concatenate gv_file '.XLS' into gv_file.
ENDIF.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = '1'
i_tab_raw_data = gi_raw_data
i_filename = gv_file
TABLES
i_tab_converted_data = gi_datatab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID gv_msgid TYPE 'I' NUMBER 001.
ENDIF.
I am assuming you know the BDC method to upload data. If not, I can provide the code for that as well.
Hope it helps
Regards
Natasha Garg
2008 Sep 04 8:42 AM
hi, can you explain how the code works? i still get error message for this.
2008 Sep 04 8:43 AM
hi ,
Check this Standard Program in SE38 : RC1TCG3Z
Thanks
Always Learner
2008 Sep 04 8:51 AM
Hi,
You can also use Open Dataset to read your files from application Server instead calling function GUI_UPLOAD
TYPES : begin of ty_filetab,
Declare fields of excel file for input
END OF ty_filetab.
TYPES: BEGIN OF ty_outtab ,
Declare your fields name for output .
END OF ty_outtab .
DATA:it_outtab TYPE STANDARD TABLE OF ty_outtab,
wa_outtab TYPE ty_outtab,
it_filetab type standard table of ty_filetab,
wa_filetab type ty_filetab.
DATA :cdata(500) type C.
open dataset p_file for output in legacy text mode.
Loop at it_outtab into wa_outtab.
move-corresponding wa_outtab to wa_filetab.
whatever you want to move you can move here and cancatenate into cdata
endloop.
close dataset p_file.
Hope it will work.
2008 Sep 10 3:44 AM
hi,
i still get error message by using "OPEN DATASET".
the file i upload will be EXCEL format. can any one please able to provide me the actual coding for this. togehter of how to pass the excel file into internal table. thanks
2008 Oct 06 4:41 AM
Hi Lee,
is your issue resolved? if so can you provide solution .
sastry.
2008 Oct 06 4:54 AM
hi,
just use function module: GUI_UPLOAD.
HOPE IT WILL HELP U
RAHUL
2008 Oct 06 6:48 AM
hi ,
need to upload XLS file is from application server not from presentation server.
suggestions?
sastry.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |