Open File Functionality
I have a file is located on local disk, what is the FM that I can use to upload it into the SAP system, I want a Pop Up window so that i can browse through to upload the file and store the name of the file in a variable in the SAP Code.
Code Snippet Would Help Me.
raj desai replied
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_rfname LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_rfname.
PERFORM upload_file_from_desktop CHANGING g_error.
DATA : v_file LIKE rlgrap-filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = 'P_RFNAME'
file_name = v_file
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i368(00) WITH 'Enter Correct File'.
MOVE : v_file TO p_rfname.
ENDFORM. " get_desktop_file_help
FORM upload_file_from_desktop CHANGING p_error.
IF NOT sy-batch IS INITIAL.
MESSAGE e368(00) WITH 'Files can only be uploaded'
CALL FUNCTION 'WS_UPLOAD'
filename = p_rfname
filetype = 'DAT'
data_tab = it_data
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc NE 0.
MESSAGE i368(00) WITH 'Error while reading data from file'.
MOVE : 'X' TO p_error.