Application Development 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: 

How to delete the record in the file present in the application server?

Former Member
0 Kudos

Hi,

I have two questions.

i) How can I delete a record based on some condition in the recordx in the file that is present in the application server?

ii) How can I lock the users whiel one user is accessing the file on the application server?

Thanks in advance.

Suvan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try to study the material which i have given its mattter 30 minutes.I hope it will help you

9 REPLIES 9

Former Member
0 Kudos

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,

Vijay

0 Kudos

Hi,

If u want a frequent deletion this approach to delete a record from a file will havee unnecesary copy of records from one file to another and deletion of one file and renaming activities.

Instead what u can do is Add and field del_flag to ur record structure.

If u want to delete the record from a file just mark this del_flag as 'X'.

While processing u can have a loop like

loop at it_XXX where del_flag <> 'X'.

endloop.

This will logically delete the record.

When u r to finish the application at that time only perform this copying / deleting / and renaing activity

Hope this helps.

Cheers,

Nitin

0 Kudos

Hi Vijay,

Thanks for your suggestion. I have a solution of downloading the entire data into internal table and again writing the file with filtered data. But why I am asking is if the contents of the file is very big, then performance will be degraded. Any way thanks for your suggestion.

Do you have any idea of locking the file as in presentation server(if one user opens a file others cant modify the same).

Thanks,

Suvan

Former Member
0 Kudos

[Removed by the moderator.]

in this book he has explained clearly about your problem.i didn't remember. so sorry for not explaining to u .with in day 7 u will get the topic which u have stated above how to block the buffer etc....

Former Member
0 Kudos

try to study the material which i have given its mattter 30 minutes.I hope it will help you

Former Member
0 Kudos

Whay not convert the file to a table? Then you can load and manipulate any record you want. You can also use standard SAP locking functionality.

Rob

0 Kudos

Hi Rob,

I wanted to know that fecility of locking. Could you be more specific please. (Lock objects are not meant for this, if I am not wrong).

0 Kudos

If the file is conveted to a table, use the enqueue/dequeue functions; otherwise, I suppose you could create a dummy table and lock/unlock it when the file is being manipulated.

Rob

0 Kudos

Thank you Rob,

Suvan.