cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with adding attachments

shailendra_jain4
Participant
0 Kudos
684

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

Accepted Solutions (1)

Accepted Solutions (1)

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.

Answers (2)

Answers (2)

mithun_shetty4
Contributor
0 Kudos

I encountered a similar scenario please check the below blog

shailendra_jain4
Participant
0 Kudos

Hi Mithun,

Appreciate your time and help, but as you can already see my question was answered and I had solved my problem and also I required help via OOP classes.

anjan_paul
Active Contributor
0 Kudos

Hi,

I think Fm  ARCHIVOBJECT_GET_TABLE is not for attachment. You will find lot of post for attachment in workitem, usually it is done usin fm SAP_WAPI_ATTACHMENT_ADD.  Just search and try it

shailendra_jain4
Participant
0 Kudos

Fm  ARCHIVOBJECT_GET_TABLE will get me the file(s) attached to the PO in text/bin format.

Fm SAP_WAPI_ATTACHMENT_ADD has parameter ATT_TEXT but it is not table type, also where can I find the workitem_id to be passed in my workflow?

anjan_paul
Active Contributor
0 Kudos


Hi,

  you can find the workitem id usin FM SAP_WAPI_WORKITEMS_TO_OBJECT and pass BUS2012, key as PO no

shailendra_jain4
Participant
0 Kudos

Thanks Anjan,

But in Fm SAP_WAPI_ATTACHMENT_ADD the parameter ATT_TEXT is not table type.

Is there any other option apart from this?

Former Member
0 Kudos

once you have the binary data, convert it to a xstring and use the parameter att_bin. ATT_TXT and ATT_BIN are optional parameters, so once you want to upload binary data, use the second one.

shailendra_jain4
Participant
0 Kudos

Hi Jozef,

The FM ARCHIVOBJECT_GET_TABLE will get me the data of file attached to the PO in text/bin format and is multiline which is the problem therefore I cannot use the FM SAP_WAPI_ATTACHMENT_ADD to add attachments to the workitem.

Is there any other workaround other than this FM?