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

SAP DMS; function module to delete object links table DRAD

Former Member
0 Likes
5,297

Hi,

we are looking for a function module or bapi to delete the object links in a document. See transaction CV03n.

We need to delete only the object links from a document version (table DRAD) but do not want to delete the document in itself.

we found BAPI_DOCUMENT_DELETE but it deletes of the entire document.

if anyone knows any bapi or FM to delete object links of a document please let us know.

Regards,

Simmi

5 REPLIES 5
Read only

Former Member
2,146

Hi Simmi,

Function module 'CV140_LINKS_DELETE' should do the trick.

Regards,

Jamie

Read only

2,146

Hi again,

I have included an example program below. Your solution will not be exactly the same as the sample program, but at least you can see the various functions that go along with 'CV140_LINKS_DELETE'. Note that I am no expert in this area and my answer does not come from an actual productive solution, but I was able to determine how SAP standard performs the document links deletion which allowed me to write the example program. Also note that the example program WILL DELETE actual data from table DRAD, so your solution should contain the appropriate controls to prevent unwanted loss of data. The purpose of this example program is just to show one way that a document link can be deleted. Here's the code:


REPORT zjrg_drad_link_delete .

PARAMETERS: p_doknr	LIKE	draw-doknr OBLIGATORY,
            p_dokar	LIKE	draw-dokar OBLIGATORY,
            p_dokob	LIKE	drad-dokob OBLIGATORY,
            p_objky	LIKE	drad-objky OBLIGATORY,
            p_doktl	LIKE	drad-doktl OBLIGATORY,
            p_dokvr	LIKE	drad-dokvr OBLIGATORY.

DATA: l_drad  TYPE drad.

l_drad-doknr = p_doknr.
l_drad-dokar = p_dokar.
l_drad-dokob = p_dokob.
l_drad-objky = p_objky.
l_drad-doktl = p_doktl.
l_drad-dokvr = p_dokvr.

* Get the documents entered on the selection screen
CALL FUNCTION 'CV140_LINKS_CREATE_WORKAREA'
     EXPORTING
          ps_drad      = l_drad
     EXCEPTIONS
          not_found    = 1
          record_exist = 2
          OTHERS       = 3.
IF sy-subrc <> 0.
  MESSAGE s001(00) WITH 'Could not create link work area.'.
  EXIT.
ENDIF.

* Change buffer by deleting the entry entered on the selection screen
CALL FUNCTION 'CV140_LINKS_DELETE'
     EXPORTING
          pf_doknr        = p_doknr
          pf_dokar        = p_dokar
          pf_dokob        = p_dokob
          pf_objky        = p_objky
          pf_doktl        = p_doktl
          pf_dokvr        = p_dokvr
     EXCEPTIONS
          not_found       = 1
          error_enque     = 2
          error_authority = 3
          OTHERS          = 4.
IF sy-subrc <> 0.
  MESSAGE s001(00) WITH 'Could not delete link.'.
  EXIT.
ENDIF.

* Update database
CALL FUNCTION 'CV140_LINKS_SAVE'
     EXCEPTIONS
          error  = 1
          OTHERS = 2.
IF sy-subrc <> 0.
  MESSAGE s001(00) WITH 'Could not delete link.'.
ELSE.
  COMMIT WORK.
  MESSAGE s001(00) WITH 'Link was deleted from DRAD.'.
ENDIF.

Regards,

Jamie

Read only

Former Member
0 Likes
2,146

Thanks Jamie.

Will update you if this helps.

Read only

0 Likes
2,146

Hi,

Yes, please update this message with your results so that future SDN'ers can benefit.

One last thing that I wanted to mention: The standard DMS functionality appears to be to set the deletion indicator before deleting a linked document (again, I'm no expert on DMS). Instead of 'CV140_LINKS_DELETE' it might be safer for you to use 'CV140_LINKS_DELFLAG_SET'. Of course that depends on how your requirement is specified. I just thought I'd throw that out there for you to think about.

Regards,

Jamie

Read only

0 Likes
2,146

Hello ,

Its the other way round.

You need to delete the object links in order to set the delete indicator flag.

By using 'CV140_LINKS_DELETE' , you delete the object links and then you could easily set the delete indicator flag.

Reward if useful,

Shubhendu