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

Validating if ZDocument has attachments

Former Member
0 Likes
574

Hello everyone,

I'm using functions SWU_OBJECT_PUBLISH and SWU_OBJECT_REFRESH, using an object key concatenation of ZDOCUMENT-ID + ZDOCUMENT-YEAR + ZDOCUMENT+BUKRS.

This means that i allready created in my Z table that document, and those functions are uses to toggle between showing in the upper left corner the standard button for options in attaching documents to my rows of the ZDOCUMENT table.

Everything works fine, but i also wanted to verify in runtime, internally, if some object allready has attachments. Is there another function to do this ?

Thank you all,

Santi

3 REPLIES 3
Read only

Former Member
0 Likes
506

Hi ,

try this way to get the attachment avaialble for the object..


 SELECT * FROM sww_contob
             WHERE  objtype     = 'ZBUS2032'       "your business object
             AND    objkey      = wa_vbak-vbeln.     "and the object key..
SELECT * FROM swwwihead WHERE wi_id      EQ sww_contob-wi_id.
  if        swwwihead- NOTE_COUNT    ge 0.
    "it contains attachments for theObject ..
 endif.                                   

Regards,

Prabhduas

Read only

0 Likes
506

Thank you for your reply, Prabhu. I tryed selecting values from table sww_contob only with objtype = 'ZPAGS', my type of object, but the result is 0. I think it's not here where my attachments and/or notes are kept.

Read only

0 Likes
506

You need to try this way


 clear v_attno1.
  i_object1-typeid = 'YTEST'.  " Your Object ID name
  i_object1-catid  = 'BO'.
  i_object1-instid = i_yitem-docnumber.   " Your document number 
  call method cl_gos_attachment_query=>count_for_object
    exporting
     is_object = i_object1
     ip_arl    = space
    receiving
     rt_stat   = i_stat1.
  read table i_stat1 into wa_stat1 index 1.
  if sy-subrc eq c_0.
     move wa_stat1-counter to v_attno1.
  endif.
 endif.
 if v_attno1 ge 1.
    " You have attachments in against the document number 
endif.

a®