cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with adding attachments

shailendra_jain4
Participant
0 Kudos
682

Hi Experts,

I have a requirement of adding PO attachments to Work item using workflow class/method.

PO attachments I'm getting using Table: TOA03 after passing object_id as PO and sap_object as 'BUS2012'. Then I pass this info to FM: ARCHIVOBJECT_GET_TABLE.

How to pass this as attachment to Workflow and it should display as same file type.

P.S: Couldn't find solution to this using Class, Methods

Regards,

Shailendra

View Entire Topic
Former Member
0 Kudos

Hi,

Here you go. Follow below steps:

1) Create a method in your custom class and do following steps. Call this method from workflow activity step. But add this activity step before the user decision/activity step where you want to display attachments. Also pass _WORKITEM.WORKITEMID number from workflow container to your method via binding. This workitemid will be passed to SAP_WAPI_ATTACHMENT_ADD. So that all the attachments get stored in _ATTACH_OBJECTS standard workflow container and later on you can you _ATTACH_OBJECT via binding in your user decision step for displaying them to users.

  • Get the bin format data using FM ARCHIVOBJECT_GET_TABLE.
  • pass that multiline data to method  TABLE_TO_XSTRING of class  CL_SWF_UTL_CONVERT_XSTRING to get the multiline data in XSTRING format (single line) . This will give you mulyiline data in single line XSTRING format.
  • Now pass the XSTRING data to SAP_WAPI_ATTACHMENT_ADD in import paramter att_bin.
  • SAP_WAPI_ATTACHMENT_ADD expects a workitem id also where it add these attachments. This will be the very top most work item id which will come via binding.

2) now after execution of this method/activity step,you will get all your attachments in _ATTACH_OBJECT workflow container which you can then use to display to users via binding.

Regards,

Ibrahim

shailendra_jain4
Participant
0 Kudos

Thanks Ibrahim.

Everything you said worked precisely for my requirement.

Just I used below logic to convert BIN table to xstring

LOOP AT lint_binarchobj INTO wa_raw."DOC_BINARY into raw.
     ASSIGN wa_raw-line TO <fs_converter> CASTING.
      CONCATENATE wf_xstring <fs_converter> INTO wf_xstring IN BYTE MODE.
ENDLOOP.