2014 Aug 12 1:10 PM
I have a custom program with a selection screen which has 1 parameter and this contains a filepath value to a file on AL11.
This program is scheduled daily, so everyday I go to se38, execute the program, enter the filename e.g. '/usr/sap/tmp/fileabc_20140812.csv' and save this as a variant.
Then I go to sm36 and create my job for this variant and execute immediately.
Tomorrow we go again to this program, this time enter filename '/usr/sap/tmp/fileabc_20140813.csv' and then save variant, etc. Everyday the filename changes to the new date i.e. the suffix changes.
Is there any way of automatting this, perhaps via TVARVC, apart from writing a separate abap program?
2014 Aug 12 1:47 PM
To update TVARVC you'll need a separate program. Can you not amend the program that you're running?
2014 Aug 12 1:47 PM
To update TVARVC you'll need a separate program. Can you not amend the program that you're running?
2014 Aug 12 1:58 PM
In the program you can check if your program is running foreground or background using sy-batch.
If the program is running in the background you can autopopulate the selection screen filepath name from the program .
Probably in the selection screen you can create radio buttons which would say if foreground or background. If backround is selected then greyout the selection screen file path field and this could be set as your variant for the background job.
2014 Aug 12 2:08 PM
Everyday the filename changes to the new date i.e. the suffix changes.
This is a valid use case for logical filepaths & filnames. (T-code: FILE). The filenames can be generated at runtime through some reserved keywords e.g., <SYSID>, <DATE>, <CLIENT> etc, using the FM "FILE_GET_NAME".
I always prefer using them instead of physical filenames.
BR,
Suhas
PS - For further info, read the documentation of the data elements - FILEEXTERN, PATHEXTERN.
2014 Aug 12 2:14 PM
Can you now an a code in INITIALIZATION section where you populate the file name.
concatenate '/usr/sap/tmp/fileabc_' ,sy-datum,'.csv', this will give the file name as you required. There is only one problem and that is you can run program only once in a DAY as otherwise it will rewrite the file.
Other option which you can explore and see if it helps you is in below link
Hope this helps
Regards
2014 Aug 13 7:18 AM
Thank you all for your advice. Greatly appreciated.
Unfortunately because the program is large and used by many persons and branches, they are loathe to changing the code.
The way I see it I can write a new program to create a variant for the original program (e.g. using fm 'RS_CREATE_VARIANT'), and then also in this new program submit this as a job using JOB_SUBMIT.
Or, I can write a new program to update TVARVC, say 1 hour before the original program is scheduled to run. This variable can then be assigned once in the variant of the original program and scheduled to run every day.
Not sure which way is best.
2014 Aug 13 8:03 AM
TVARVC-LOW field is only 45 char, my AL11 filepath and filename is slightly longer than this, so have to go with coding to create a variant.