‎2010 Jun 24 6:39 AM
Hi Friends,
I have an issue where i have a job which has three different stepst for same program. If i run the job the program will create a file in the application server and append the other two steps in the same file without overwriting the file or creating a new file.
My problem is like its creating three different files in application server for that particular job since it has three steps . Its not appending into one particular file .
I am using the FM 'Z_INTERFACE_FILE_WRITE' where i have used the pi_append in the exportng parameter . ITs working when i specify the file in local system. It is appending correctly when i run the report normally to apppend into local system.
But when i schedule a job to append the file in application server its creating three different files.
Kindly help me if anyone is aware of this issue
Thanks in advance
Kishore
‎2010 Jun 24 7:28 AM
Hi,
Please use open dataset to write and append files.Please check the logic of Z FM which you are using .
To open and write into a file use
OPEN DATASET FNAME FOR OUTPUT.
To append data into existing file use
OPEN DATASET FNAME FOR APPENDING.
To write into file:
v_file = file path on application server
OPEN DATASET v_file FOR output.
IF sy-subrc NE 0.
write:/ 'error opening file'.
ELSE.
TRANSFER data TO v_file.
ENDIF.
CLOSE DATASET v_file.
For appending :
OPEN DATASET v_file fOR APPENDING.(file is opened for appending data position is set to the end of the file).
Thanks and Regards,
P.Bharadwaj
‎2010 Jun 24 7:56 AM
Hi Bharadwaj,
Thanks for the immediate reply. AS u have said the function module which i am using is having that OPEN DATASET FNAME FOR APPENDING when i checked on the logical file on selection screen.
And the TRANSFER FUNCTION ALSO i have used.
But at the end after the close dataset u have used that 'For appending ' OPEN dataset v_file for appending' . THis one i didn use it after the close dataset. Is that i have to use that to get that data appending into a single file..
Thanks
Kishore
‎2010 Jun 24 7:59 AM
Hi,
Exactly.
OPEN DATASET FNAME FOR APPENDING is used for appending into an existing file since you are not using that ,new file is getting created.
Thanks and Regards,
P.Bharadwaj
‎2010 Jun 24 8:35 AM
I am already using that OPEN DATASET FNAME FOR APPENDING which u have mentioned in the pevious mail.
If the logical file is checked i am using this open dataset. But before getting in to the open dataset i am using one FM FILE_GET_NAME where the new file is getting created in that application server. How to restrict that for appending into same file itself
Thanks for replying patiently
Thanks
Kishore
‎2010 Jun 24 8:41 AM
Hi,
You donnot have to create a new file because you are appending to an existing file , Use OPEN DATASET FNAME FOR OUTPUT if the file does not already exist, it is created automatically( no need for file creating FM).So please remove that FM .
THanks and Regards,
P.Bharadwaj
‎2010 Jun 24 10:59 AM
Actually Bharadwaj i cannot go ahead and change that FM Z_INTERFACE_FILE_WRITE since its the main interface custom FM which is used by many programs.More over if i comment that FM Z_GET_FILENAME i will not get the file itself created in the application server then whats the use of using OPEN DATASET And TRANSFER that file.
My problem is Z_GET_FILENAME is used inside this FM Z_INTERFACE_FILE_WRITE So every step it executes its getting inside that Z_INTERFACE fm AND CREATING A FILE in Z_GET_FILENAME.I want this file name to be crated only once and next step it should not create instead should append in to same file
Hope now i am clear
Thanks
Kishore
‎2010 Jun 24 11:36 AM
Since you have 3 steps in the job, check the file path and name which is passing for the 2nd & 3rd steps in the FM -->Z_GET_FILENAME and replace it with the 1st step file path and name. Hope this will work..
Regards,
Peetham
‎2010 Jun 25 11:39 AM
Hi ,
Its been a delay for me in getting things rite..I am still having problem and not able to find the solution for this issue.
As i said its creating three differnt files in the application server based on the timestamp.Now this timestamp is related to standard FM FILE_GET_NAME where i cannot do any change. As u suggested how to use the first file which is getting created with the timestamp using that FILE_GET_NAME for other two steps also. Kindly give it as an example which wil be really helpful for me.
Thanks
Kishore
‎2010 Jun 28 8:55 AM
Hi,
I assume it is not mandatory to use Z FM ,Remove Fm and use below logic .
Since you always create a file and then you append data into same one.
To open and write into a file use
OPEN DATASET FNAME FOR OUTPUT.(a file is created)
To append data into existing file use
OPEN DATASET FNAME FOR APPENDING.
To write into file:
v_file = file path on application server
OPEN DATASET v_file FOR output.
IF sy-subrc NE 0.
write:/ 'error opening file'.
ELSE.
TRANSFER data TO v_file.
ENDIF.
CLOSE DATASET v_file.
In above code at first run a file will be created and data will be filled in the same , for further operations on the same file use appending .
Thanks and Regards,
P.Bharadwaj
‎2010 Jun 29 1:15 PM
Hi Baradwaj,
First of all Thanks for your patient replies.Its not mandatory to use that Z_INTERFACE_FILE_WRITE as you said .But the client is not agreeing to remove that FM and change the logic since its been used to send it to another system. They dont want to take any risk.
I have a doubt is that possible to export the File to the MEMORY id and use it again when it executes the next step. I just came across this solution but not sure how to implement it.
Your suggesstion and example will be helpful for me
Thanks
Kishore
‎2010 Jun 30 12:06 PM
Hi,
I don't think that will be feasible solution.You can just remove FM from your code and use the logic which I mentioned above.
Please award points if my posts are helpful :).
Thanks and Regards,
P.Bharadwaj
‎2010 Jun 24 12:15 PM
Get someone to fix your custom function module (it's obviously not SAP standard with the Z_name) so that it will work for both APPS server and Desktop, which employ DIFFERENT programming methods/statements!
‎2010 Jun 24 12:52 PM
Yupp Changing the FM will do i know that. But this FM is being used in many programs and donno whether it will impact in any other programs. So i was asking is there any alternative to do something in the Program itself rather than changing in the FM.
Anyways i will just consult with my client and check whether i can go ahead with the changes for Custom FM.
Thanks for your effort .
Any other further doubts or issues will get back to u. Thanks bharadwaj for ur immediate response too
Thanks
Kishore
‎2010 Jul 16 1:26 PM
i solved it by using GET and SET parameters. Thanks for all your help