2006 Oct 03 9:27 PM
Hi.. I need a little help on creating a background job.
My requirement is like this. I have a program to read a file from a specified folder on application server. The incoming file will have a variable name.. say something like XYZ_DATE_TIME.txt. The key here is the time stamp attached to the file. I want to schedule a background job to read the file into my ABAP. Can you tell me how do I make this happen ? I know the basic steps to create background jobs.
Hi.. I need a little help on creating a background job.
My requirement is like this. I have a program to read a file from a specified folder on application server. The incoming file will have a variable name.. say something like XYZ_DATE_TIME.txt. The key here is the time stamp attached to the file. I want to schedule a background job to read the file into my ABAP. Can you tell me how do I make this happen ? I know the basic steps to create background jobs.
2006 Oct 03 10:09 PM
Hi,
I'm not sure, if I understand your question right.
You can create background jobs with the transaction SM36. Your can do it for each program and variant and for a special time and period.
Was this the question?
NL
2006 Oct 03 10:14 PM
The question is like this.
I need to schedule a background job to pick up a file from a folder on the application server nightly.
There would be a new file put into the folder everyday though some other interface. The name of the file will be tagged to a date and time stamp. Example: FILENAME_DATE_TIME.txt. When i try to save a variant it I would have to provide a constant name of the file but this name keeps chaing in the scenario i mentioned. My question here is my program should be able to pick up file name which keeps changing.
Hope this is clear.
2006 Oct 03 10:27 PM
Use this function module whihc gives you the list of file in the directory into the table i_dir_list.
In the selections declare parameters p-mask.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = '/usr/yourfolder/'
TABLES
dir_list = i_dir_list
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
IF sy-subrc <> 0.
IF sy-subrc = 1.
MESSAGE e000(zfi) WITH 'Invalid directory'.
ELSEIF sy-subrc = 2.
MESSAGE e000(zfi) WITH 'sapgparam failed'.
ELSEIF sy-subrc = 3.
MESSAGE e000(zfi) WITH 'build directory falied'.
ELSEIF sy-subrc = 4.
MESSAGE e000(zfi) WITH 'File error: no authorization'.
ELSEIF sy-subrc = 5.
MESSAGE e000(zfi) WITH 'Read Directory failed'.
ENDIF.
ENDIF.
LOOP AT i_dir_list WHERE name IN p_mask. gives you list of file in the directory.
2006 Oct 03 10:16 PM
Hi madhu
The logic for picking up the file based on the time stamp should be incorporated inside your program. i.e you can use file name masking. and then Create a job in SM36.
scheduling the job, depends on how often you want to execute the program.
Nataraju
2006 Oct 03 10:19 PM
Hi,
WHen you are giving the logical filename you can define parameters..
Check the transaction FILE..
Using the FM FILE_GET_NAME you can get the filename for the logical file..And the parameter PARAMETER_1 pass the date..When you getting the physical file name in the exporting parameter FILE_NAME, you will get it with the date..
Check the logical file name ARCHIVE_DATA_FILE in the transaction FILE..Which has the parameters..
Check this documentation..
http://help.sap.com/saphelp_46c/helpdata/EN/8d/3e4ec2462a11d189000000e8323d3a/frameset.htm
Thanks,
Naren
2006 Oct 04 12:53 AM
Hi,
You can do it alternatively like this also. Do not change the file name of current file keep it constanat. Just before writing the new file to directory append time stamp to the old file and save it in the same directory or a backup directory. So that you will not have to bother regarding the file name to be picked.
If you want to get the file name from application server you can use the function module <b>SUBST_GET_FILE_LIST</b> which will give the list of file in the directory. You can sort the files and get the latest file from the Internal table returned.
Hope this helps.
Message was edited by: Imtiaz Ahmed
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |