2005 May 04 5:06 AM
Hi all,
Can i use GUI_UPLOAD for uploading data from an excel sheet from the prsentation server into SAP.
Is there any thing important that I should take care of.
Thanks in Advance.
Regards
Satish.
2005 May 04 5:21 AM
Hi ,
Have a look into this sample program
Retrieve data file from presentation server(Upload from PC)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = i_file
filetype = 'ASC'
TABLES
data_tab = it_datatab "ITBL_IN_RECORD[]
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
<b>OR</b>
*Dynamic manipulation of report programs
*......................................................................
*: Report ZDYNAMICCODE :
*:.....................................................................
*: Execute ABAP from a PC file(.txt) :
*: Therefor allowing any abap code to be executed on any client :
*: which contains this program :
*: :
*.....................................................................:
REPORT zdynamiccode .
TABLES rlgrap.
*selection screen creation
PARAMETER: p_file(200) TYPE c,
p_temp(30) TYPE c DEFAULT 'Z123TEMP_REPORT_FOR_CODE'.
*data declaration
DATA: it_tab TYPE filetable,
gd_subrc TYPE i,
answer TYPE c.
TYPES: BEGIN OF t_abapcode,
row(72) TYPE c,
END OF t_abapcode.
DATA: it_abapcode TYPE STANDARD TABLE OF t_abapcode INITIAL SIZE 0,
it_store TYPE STANDARD TABLE OF t_abapcode INITIAL SIZE 0.
DATA: filename TYPE string.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*Selecting a File, plus inserting default file extension
REFRESH: it_tab.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select File'
default_filename = '*.txt'
multiselection = ' '
CHANGING
file_table = it_tab
rc = gd_subrc.
LOOP AT it_tab INTO p_file.
ENDLOOP.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
*move file name into a field with type compatable with FM
filename = p_file.
*upload file from PC
<b> CALL FUNCTION 'GUI_UPLOAD'</b>
EXPORTING
filename = filename
TABLES
data_tab = it_abapcode
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 EQ 0.
Check if report name being used fro temorary code already exists as
any code will be over written and lost
READ REPORT p_temp INTO it_store.
IF sy-subrc NE 0.
Please note any existing code in the program will be lost!!!!
INSERT REPORT p_temp FROM it_abapcode.
SUBMIT (p_temp) AND RETURN.
DELETE REPORT p_temp.
ELSE.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
text_question = 'Report used to store temporary code already
exists!!! Do you want to overwrite it?'
IMPORTING
answer = answer.
IF sy-subrc EQ 0.
IF answer EQ '1'. "yes
Please note any existing code in the program will be lost!!!!
INSERT REPORT p_temp FROM it_abapcode.
SUBMIT (p_temp) AND RETURN.
DELETE REPORT p_temp.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Have a look into this link http://www.sapdevelopment.co.uk/file/file_updown.htm
Thanks & Regards,
Judith.
2005 May 04 8:16 AM
Hi Satish,
You can make use of the function module
"ALSM_EXCEL_TO_INTERNAL_TABLE".
Ramesh