In many occasion, data needs to be loaded to SAP BW through flat file.
But flat file load from local desktop is not possible through process chain(Process chain will failed to extract from Local desktop).
In order to resolve this issue, flat file needs to be uploaded to application server and then process chain can be triggered at its scheduled time.
Process chain will not fail if flat file is loaded from application server.
Program to load file to application server:
TYPE-POOLS : vrm.
DATA: param TYPE vrm_id,
values TYPE vrm_values,
value LIKE LINE OF values.
PARAMETERS: p_file TYPE localfile OBLIGATORY.
*File selection from local desktop
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
DATA: ifile TYPE filetable.
DATA: xfile LIKE LINE OF ifile.
DATA: rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
initial_directory = ‘C:\’
file_table = ifile
rc = rc.
READ TABLE ifile INTO xfile INDEX 1.
CHECK sy-subrc = 0.
p_file = xfile-filename.
*Local file upload to Application server
DATA: p_file_path LIKE sapb-sappfad.
p_file_path = p_file.
CALL FUNCTION ‘ARCHIVFILE_CLIENT_TO_SERVER’
path = p_file_path
targetpath = ‘abc.CSV’
* ERROR_FILE = 1
* OTHERS = 2
While executing the above program, selection screen displayed to choose the file from local desktop as shown below:
Click on F4 option to choose the file from desktop.
Click on Execute.
In order to check the file is successfully loaded, please goto T-code AL11.
Docubel click the directory “DIR_SAPUSERS”
Now, we can able to see the flat file that has been loaded to application server.
Now this file can be used to load through process chain.