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

Delete documents

Former Member
0 Likes
1,449


Hello experts,

i am a beginner with abap development and try to write a report that deletes materials, documents and document structures.

I just wrote a method that should delete documents. My Problem is, that the function module always returns that the document cannot be deleted, because it is used in a document structure. But I am sure that it isn't. My import structure is BAPI_DOC_AUX , just like the function module needs it.

Do you have any ideas where that comes from?

Thanks a lot.

method DELETE_DOCUMENTS.

  DATA ls_success LIKE LINE OF it_success.

* deletes document from corresponding tables
  CALL FUNCTION 'BAPI_DOCUMENT_DELETE_DIRECT'
    EXPORTING
      documenttype          = is_doc-doctype
      documentnumber        = is_doc-docnumber
      documentpart          = is_doc-docpart
      documentversion       = is_doc-docversion
   IMPORTING
     RETURN                = ls_success.

  APPEND ls_success to et_success.
  if ls_success-type eq 'S'.
* deletes document from the index table, too.
   DELETE FROM zaif_plm_doc_idx                     "#EC CI_NOFIELD
   WHERE documenttype          = is_doc-doctype
      AND documentnumber        = is_doc-docnumber
      AND documentpart          = is_doc-docpart
      AND documentversion       = is_doc-docversion.
   endif.

endmethod.

Message was edited by: Matthew Billingham - formatted code to be readable

7 REPLIES 7
Read only

matt
Active Contributor
0 Likes
1,353

When you post in this site, after you've posted read what you've written and ensure the formatting is good. I've removed the extra blank lines in the code for you this time - next time, I'll just reject your post.

Read only

Former Member
0 Likes
1,353

I will take care next time, I'm sorry.

Read only

Former Member
0 Likes
1,353

Hello,

Have you used BAPI_TRANSACTION_COMMIT after ?

Read only

0 Likes
1,353

No, I haven't. Do I have to use it?

Does this change anything, because the 'BAPI_DOCUMENT_DELETE_DIRECT' returns an "success"- message which says that the material is used in a bom.

Read only

0 Likes
1,353

Sorry, i haven't read correctly your issue, my answer is wrong...

Read only

0 Likes
1,353

No problem, but thanks for answering anyway

Read only

0 Likes
1,353

Have you tried to identify the error(standard code raising message) by activating breakpoint at statement MESSAGE or RAISE ?