05-18-2012 7:10 PM
Hi frn's
How to Execute Batch file in Presentation server by passing 2 file names as argument. i have class cl_frontend_service method execute but not able to find the way to pass two or more file name as argument.
Thanks and Regards..
Priyank Dixit
05-18-2012 7:36 PM
Hello Priyank,
You will have to a small work around to achieve this.
1. Get a list of all the file names in an internal table (file names) typically read from some Directory ..
2. Loop on the internal table (file names) and Upload them to the corresponding internal tables (data).
Sample Code :
*Step 1. Read all the filenames by doing a Directory Listing
CALL METHOD cl_gui_frontend_services=>directory_list_filesEXPORTING
directory = dir
files_only = 'X'
CHANGING
file_table = it_pfiles
count = count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6.
* Step 2: Loop on the file names to upload each oneLOOP AT it_pfiles INTO wa_pfile.
WRITE wa_pfile.
ENDLOOP.
Regards,
Shyam
05-18-2012 7:54 PM
Hi Subrahmanya,
Thanks for your quick reply.
I have batch file. which is perfroming some task using 2 files .but these two files name are not static, i need to suplly those file name at run time form my sap program.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT =
APPLICATION = 'Batch file name'
PARAMETER =
DEFAULT_DIRECTORY =
MAXIMIZED =
MINIMIZED =
SYNCHRONOUS =
OPERATION = 'OPEN'
where should i pass the arugment .
Or if there is any other way to achieve the requirment then please let me know.
Thanks and Regards.
Priyank Dixit
05-18-2012 9:36 PM
Since the file names are dynamic, you can concat them into a string with a delimiter and pass it on to the batch file as an input parameter.
And you decipher the filenames in the batch file and continue with the processing.
Regards,
Shyam