Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

TVARVC - can I use tvarvc table for my purpose below:

former_member201275
Active Contributor
0 Kudos
1,320

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?

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos
337

To update TVARVC you'll need a separate program. Can you not amend the program that you're running?

6 REPLIES 6

matt
Active Contributor
0 Kudos
338

To update TVARVC you'll need a separate program. Can you not amend the program that you're running?

ruhi_karim
Explorer
0 Kudos
337

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.

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
337

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.

Former Member
0 Kudos
337

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

former_member201275
Active Contributor
0 Kudos
337

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.

former_member201275
Active Contributor
0 Kudos
337

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.