‎2008 Apr 24 9:57 AM
Hi
I have requirement to delete Data from Dataset for some records , is it possible to do. ?
Scenerio, is I have text file on application server , according to that file , records are getting uploaded in my Ztables. some times due to some errors records are not getting updated in Ztable. since I am clearing the file before close dataset... Text (flat) file gets deleted from Application server.
requirement is , I want, if data has been updated in my ztables only those records should get deleted from my Text file of application server,remaining which are having errors or not updated in Ztable should remain in TEXT file..
How should , I right code for this. any idea ?
Thanks in advance
.
‎2008 Apr 24 10:41 AM
‎2008 Apr 24 11:20 AM
hi purnima,
compare the records with the primary key..if they match delete that record...
regds
‎2008 Apr 25 5:34 AM
Hi, sudheer
Thanks for reply.
But I wanted code (syntax) to delete the records from Flat file.
e.g.
I have written code in the beginning
ie.
OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
.
IF sy-subrc EQ 0.
DO.
READ DATASET v_file INTO wa_file.
IF sy-subrc EQ 0.
APPEND wa_file TO ifile.
ELSE.
EXIT.
ENDIF.
ENDDO.
At the end of my processing : given like this . Which is clearing the Flat file and closing it.
MODIFY Ztable FROM TABLE internal tab.
IF sy-subrc EQ 0.
CLEAR wa_file.
CLOSE DATASET v_file.
OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
TRANSFER wa_file TO v_file.
CLOSE DATASET v_file.
ENDIF.
Now , I don't want to Deleting the whole file.. but if records are not gone properly..should Keep those records in flat file.
what wud be the code for that. ?
Thanks in advance.
‎2008 Apr 25 5:40 AM
Hi,
There is no statement to delete records from an application file. Check the below logic to solve your problem.
(1) Assume FILE1 contains the actual data.
(2) Copy the contents of FILE1 to FILE2.
(3) Delete FILE1 from the application server ( optional)
(4) Read the records from FILE2 except those you want to delete
(5) Write these records into FILE1.
When the file is already opened, SAP triggers an exception of the type CX_SY_FILE_OPEN.
Best Regards,
Raj.
‎2008 Apr 28 10:38 AM
Thanks everyone,
I have got solution. Not as I wanted, but My purpose has got solved.
Regards
purnima