How to get the logical file path name dynamically by reading physical path and upload file on application server in abap
In some cases when we upload a file on application server we need to get the logical file path name dynamically since we deal with different systems i.e. Development, Quality and production system and the server path is different in all the systems. So to get the file path dynamically we need to obtain the logical file path name by reading the physical path name which is nothing but directory parameter.
So to achieve this I have documented the code below that will help in understanding how to upload the file on application server by getting the file path dynamically reading the physical path.
Steps to create abap program to upload the file on application sever:-
So here in this example we are reading the data from an existing Z-table and writing it to the application server using the physical path name.
Go to SE38:- Give a name to the program such as Z_FILE_UPLOAD and click on “create” button.
A following pop up comes, provide all the details as per the requirement.
So the first part is data declaration and selection screen to read the specific data from the Z-table.
Then we will be reading the data from the Z-table into a internal table using the select statement in start-of-selection.
Now declaring 2 sub-routines:
1. To define the file path – PERFORM define_path
2. To upload the file – PERFORM upload_file
Lets see the definition of both the routines.
So below the logical name of the physical path DIR_SAPUSERS is read. So dynamically we can get the file path name for any systems by just reading the physical path.
Below is the file that upload to the application server.