Application Development and Automation 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: 
Read only

File open problem

Former Member
0 Likes
712

Hi Expert,

I have a program scheduled in background mode for which it runs for several time in one batch job and creates multiple proposals. The problem i am facing is sometimes when it creates second proposal it overwrites first proposal. So i might think that this is due to first file is opened when it is processing for second file. File is created on application server. Can you please suggest me how i can handle this situation so that first file must be closed while it will go for second file creation. close_dataset is used in the program.

Thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
679

Yes Close first file using CLOSE DATASET and then open second file and process......

Thanks,

Chandra

Read only

Former Member
0 Likes
679

Sounds like the filename (dataset name) is not being changed between the two proposals.  This is how I would expect the overlay to occur....  the flow should be like:

{code}lv_filen = set your filename value here.

open dataset lv_filen for output in text mode encoding default...etc.

if sy-subrc eq 0.

  loop at....

  transfer...to lv_filen.

endloop.

close dataset lv_filen.

else.

* error routine.

endif.  {code}

then do it all again from the lv_filen = ....

Read only

0 Likes
679

Pls try to include timestamp...it will solve ....

Thanks,

Chandra

Read only

0 Likes
679

Hi,

Thanks for your reply. Actually file name is changed everytime it creates the file. We have ZTABLE associated with the program in which counter gets automatically incremented in that table and program takes this counter number appended to the file name. But sometimes it is not happening.

Suppose i have schduled batch job today and ZTABLE has counter 122 now. Batch job has two proposals to process then first proposal will have the name TEST122 and second will have TEST123. But in some cases both the proposals are appearing as TEST122.

Read only

0 Likes
679

Sorry, but from my viewpoint, this has to be an error in the program that is failing to update the counter, or there is some situation in which the filename is not being set correctly.