‎2009 Nov 06 8:47 AM
Hi All,
I am opening a file using OPEN DATASET command and after that i am deleting that file using DELETE DATA SET.
In this case is it require to use CLOSE DATASET also?
Ex: OPEN DATASET file_name IN TEXT MODE.
if sy-subrc = 0.
do.
Read data set ...................
-
-
endo
DELETE DATASET file_name
endif.
In the above is it require to use CLOSE DATASET after / before DELETE DATASET command.
Thanks,
Vijay
‎2009 Nov 06 8:50 AM
‎2009 Nov 06 8:50 AM
‎2009 Nov 06 8:52 AM
Is it compulsary to use Close Data set when we are using Delete data set
‎2009 Nov 06 8:53 AM
Hello,
I agree with Gautham on this 99%
I would have agreed 100% if i did not read this SAP documentation :
An opened file that was not explicitly closed using CLOSE DATASET is automatically closed when the program is exited
But it is a good practice to CLOSE DATASET for every OPEN DATASET.
BR,
Suhas
‎2009 Nov 06 9:03 AM
@ Gautham and Suhas,
But does it make sense to use CLOSE DATASET after using DELETE DATASET? DELETE dataset will delete the file but then whats there to close after this?
Vikranth
‎2009 Nov 06 9:05 AM
Hello Vik,
Suppose you donot have the auth. to delete a file in the app. server.
So your DELETE DATASET will return SY-SUBRC NE 0. So your file is not deleted & still is OPEN !!
I hope you get the catch
BR,
Suhas
‎2009 Nov 06 9:11 AM
Hello Suhas,
Yes i agree with that. But for the scenario when the file is deleted successfully, and if i use a CLOSE dataset after that, it's still showing sy-subrc = 0. I was atleast expecting a sy-subrc other than 0 if not a dump. Not sure what the system is closing after the DELETE dataset
Vikranth
‎2009 Nov 06 9:12 AM
>
> But for the scenario when the file is deleted successfully, and if i use a CLOSE dataset after that, it's still showing sy-subrc = > 0. I was atleast expecting a sy-subrc other than 0 if not a dump. Not sure what the system is closing after the DELETE dataset.
Hello Vik,
That's standard SAP functionality.
See Nitwick's post. He has added further info on CLOSE DATASET for ready reference.
BR,
Suhas
‎2009 Nov 06 9:15 AM
‎2009 Nov 06 9:16 AM
Hi Suhas,
I second your views on this.
P.S. Not 'He' by the way. I'm a 'She'
‎2009 Nov 06 9:19 AM
Some more additional information for close dataset ( from SAP docu )
You only need to close a file if you want to delete its contents the next time you open it for write access. For further information and an example, refer to Opening a File for Write Access.
http://help.sap.com/saphelp_erp2004/helpdata/EN/fc/eb3d1b358411d1829f0000e829fbfe/frameset.htm
‎2009 Nov 06 9:20 AM
Thanks for all for ur reply..
One more ...How many files can be opened with out using Close data set..
I am using OPEN DATASET to read a input file but I am not using CLOSE DATASET command to close the file..
How many files can be opened successfully with out using CLOSE DATASET command....
I heard that after opening some files program will goto DUMP if we dont use CLOSE DATASET command...
Thanks,
Vijay
‎2009 Nov 06 9:25 AM
Hello Vijay,
Do not beleive in what you hear !!
If any doubts write a small piece of code, read SAP documentation, search forums.
A simple F1 on OPEN DATASET gives you this info:
You can open up to 100 files per internal session. The actual maximum number of simultaneously open files may be less, depending on the platformEnough spoonfeeding for today !!
Good luck,
Suhas
‎2009 Nov 06 9:28 AM
Hello Suhas,
Thanks for your advice, I know that...I am not forcing you to reply...
But you are not at all telling straightforward answer to my questions..
Thanks,
Vijay
‎2009 Nov 06 9:28 AM
Thanks Gautham i got it now.
@Nitwick- Even i mistook you for a HE
When i was new to the forums i thought Julius was a SHE from the name. But came to know i was wrong when i checked Julius's business card
Hope he doesnt check this post
‎2009 Nov 06 9:32 AM
Hi Vijay,
No offence meant by anybody here to your questions.
All of us have been reading through the F1 documentation to answer your question. You could probably check it out for yourself. That's the intention.
Happy working.
@Vikranth
Well, 'Nitwick' is just a display name. Dumbledore's favourite word
‎2009 Nov 06 9:35 AM
Hello Vik,
I am sure if Julius checks this he will hatch another "over-the-top-of-your-head" comment
BR,
Suhas
‎2009 Nov 06 9:50 AM
Now i get 10 points for considering Julius as a SHE before. I think even Vijay was expecting Julius to be a SHE
‎2009 Nov 06 9:57 AM
>
> Now i get 10 points for considering Julius as a SHE before. I think even Vijay was expecting Julius to be a SHE
But how does that solve his problem ?
‎2009 Nov 06 10:10 AM
LOL am not exactly sure of the intention of the OP to assign p0ints to me Would be nice if he can clarify.
‎2009 Nov 06 8:58 AM
Hi,
Adding on to Suhas, (courtesy: SAP docu)
If the file is already closed or does not exist, the statement is ignored and the return value sy-subrc is set to 0.
‎2009 Nov 06 9:10 AM
Hi Vijay,
It is not required to use CLOSE DATASET with DELETE DATASET. But logically speaking if you want to delete, it is better to first open the file using OPEN DATASET and then proceed with you delete operation using DELETE DATASET then close the file using CLOSE DATSET.
Edited by: Harini Gopinath on Nov 6, 2009 2:49 PM