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 Attachment - GOS

former_member194669
Active Contributor
0 Likes
8,358

Hi,

I am deleting a GOS attachment using following code.


 data: i_borident  type borident,
       i_attsrv    type ref to cl_gos_document_service.

  i_objectd-objtype = 'YATTA'.
  i_objectd-logsys  = 'BO'.
  i_objectd-objkey  = inumber.

  select * from srgbtbrel                " Get GOS Link
           into table i_srgbtbrel
           where instid_a eq i_objectd-objkey
             and typeid_a eq i_objectd-objtype
             and catid_a eq i_objectd-logsys
             and reltype eq 'ATTA'.
  if sy-subrc eq 0.
    create object i_attsrv.
    loop at i_srgbtbrel.
     i_borident-objkey =  i_srgbtbrel-instid_b.
     call method i_attsrv->delete_attachment
       exporting
*         is_object     = i_objectd
         ip_attachment = i_borident-objkey.
     commit work.
    endloop.
  endif.

I am getting proper binary key from table SRGBTBREL and passing to method DELETE_ATTACHMENT , and getting sy-subrc eq 0, then also attachment are showing in the document. But if you are going thru service object delete it has been deleting the attachment perfectly. What is the error in the code?

Thanks

aRs

Message was edited by:

aRs

Hi,

I am deleting a GOS attachment using following code.


 data: i_borident  type borident,
       i_attsrv    type ref to cl_gos_document_service.

  i_objectd-objtype = 'YATTA'.
  i_objectd-logsys  = 'BO'.
  i_objectd-objkey  = inumber.

  select * from srgbtbrel                " Get GOS Link
           into table i_srgbtbrel
           where instid_a eq i_objectd-objkey
             and typeid_a eq i_objectd-objtype
             and catid_a eq i_objectd-logsys
             and reltype eq 'ATTA'.
  if sy-subrc eq 0.
    create object i_attsrv.
    loop at i_srgbtbrel.
     i_borident-objkey =  i_srgbtbrel-instid_b.
     call method i_attsrv->delete_attachment
       exporting
*         is_object     = i_objectd
         ip_attachment = i_borident-objkey.
     commit work.
    endloop.
  endif.

I am getting proper binary key from table SRGBTBREL and passing to method DELETE_ATTACHMENT , and getting sy-subrc eq 0, then also attachment are showing in the document. But if you are going thru service object delete it has been deleting the attachment perfectly. What is the error in the code?

Thanks

aRs

Message was edited by:

aRs

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
3,867

You have the one parameter commented out. Do you need it?

exporting

<b>* is_object = i_objectd</b>

ip_attachment = i_borident-objkey.

Regards.

Rich Heilman

Read only

former_member194669
Active Contributor
0 Likes
3,867

Rich,

Here is_object is optional , we have to pass only the folder key(binary key) (ie ip_attachment)


    call method i_attsrv->delete_attachment
       exporting
*         is_object     = i_objectd
         ip_attachment = i_borident-objkey.

Thanks

aRs

Read only

Former Member
0 Likes
3,867

Hi

If you want to delete attached file....

This Program is needed to add Class Method input parameter value

Example) Refer to Following Souce Code...

................

LOOP AT i_srgbtbrel.

CALL METHOD i_attsrv->delete_attachment

EXPORTING

is_object = i_borident

ip_attachment = i_srgbtbrel-instid_b.

................

ENDLOOP.

Good Luck.

Read only

Former Member
0 Likes
3,867

Hi.

You are missing  SO_OBJECT_DELETE_IN_VB:

    ...

    data ls_folder_id type soodk.

    data ls_object_id type soodk.

    loop at i_srgbtbrel.

      i_borident-objkey =  i_srgbtbrel-instid_b.

      call method i_attsrv->delete_attachment

        exporting

*         is_object     = i_objectd

         ip_attachment = i_borident-objkey.

      ls_folder_id = i_borident-objkey(17).

      ls_object_id = i_borident-objkey+17(17).

      call function 'SO_OBJECT_DELETE_IN_VB'

         in update task

         exporting

           folder_id = ls_folder_id

           object_id = ls_object_id.

    endloop.

    commit work and wait.

At the end of cl_gos_document_service->delete_attachment, there is the line:

call function 'GOS_ADD_KEY' exporting ip_objkey = ip_attachment.

This function adds the deleted item to table gt_obj_to_delete.

Later, the standard makes the call to SO_OBJECT_DELETE_IN_VB at include LSGOSITSF01, form  DELETE_OBJECTS using gt_obj_to_delete.

Thanks.

Read only

Former Member
0 Likes
3,867

Hi, how were you able to solve this issue, since we have the same requirement.

Read only

keremkoseoglu
Contributor
0 Likes
3,867

You can find the sample code to delete GOS files here: https://github.com/keremkoseoglu/ABAP-Library/blob/master/zcl_bc_gos_toolkit.abap . This class also includes many further utilities regarding GOS.