cancel
Showing results for 
Search instead for 
Did you mean: 

How to choose the specific attachement from Workflow

Former Member
0 Kudos

Hi Experts,

I have a requirement to attach the PDF to the email sent to workflow initiator in outlook mail after approval or rejection which I am able to do that.

There is a option to provide any comment during approval and these comment also stored as attachment. So now in the email I can see both the attachment. I am using  SAP_WAPI_ATTACHMENT_ADD inside a class method to attach this PDF. Now as I saw that all the attachment will be available for subsequent workitem or the activity. I am not able to separate these attachment. Can any one help me to get only PDF attachment to the Email.

Regards,

Chandrashekhar

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Simpler solution will be to use two different custom container elements for attachments. OBJECT TYPE SOFM.

During binding bind to separate container elements.

Based on your conditions then use any of the container elements.

Thanks,

Anubhav

Former Member
0 Kudos

Hi Anubhav,

Thanks for response. I tried the below code to create the SOFM object in task container. But somehow its not creating. Just to let you know I am using the Class method for below

  DATA: lt_return       TYPE bapirettab,
        lv_pdf_form     TYPE fpcontent,
        lv_subrc        TYPE sy-subrc,
        lt_msg          TYPE STANDARD TABLE OF swr_messag,
        lt_str          TYPE STANDARD TABLE OF swr_mstruc,
        l_wa_header     TYPE swr_att_header,
        lt_container    TYPE STANDARD TABLE OF swcont,
        lv_sofm         TYPE swr_att_id.

*--Get PDF Attachment data for TA form
  CALL FUNCTION 'PTRM_WEB_FORM_PDF_GET'
    EXPORTING
      i_employeenumber = im_pernr
      i_tripnumber     = im_reinr
      i_language       = co_langu_en
    IMPORTING
      e_pdf_form       = lv_pdf_form
    TABLES
      et_return        = lt_return.

*--Update the attachment Header information
  l_wa_header-file_type = co_file_type_b.
  l_wa_header-file_extension = co_file_ext_pdf.
  l_wa_header-file_name = im_reinr.
  l_wa_header-language = im_langu.

*--Create Workflow Attachment
  CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
    EXPORTING
      workitem_id    = im_workitemid
      att_header     = l_wa_header
      att_bin        = lv_pdf_form
      language       = im_langu
    IMPORTING
      return_code    = lv_subrc
      att_id         = lv_sofm
    TABLES
      message_lines  = lt_msg
      message_struct = lt_str.

  swc_container container.
  swc_create_container container.
  swc_set_element container 'SOFM' lv_sofm.

  swc_set_element container 'SOFM' lv_sofm-doc_id.

Former Member
0 Kudos

Hi,

1. Use SWC0 instead of SWC. Declare this as a TYPE GROUP in "Properties" tab of your class.

2. In CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'  put do_commit   = 'X'.

3. Directly use macro swc0_create_object e_attachment lv_objsofm lv_objtkey. No need to use last four lines of code you have written.

Let me know if this worked.

Thanks,

Anubhav

anjan_paul
Active Contributor
0 Kudos

Hi,

  If you are using CLASS method, did you implement the class with using IF_WORKFLOW interface. And did you implement FIND_BY_LPOR method and LPOR method.

check it

Former Member
0 Kudos

Hi Anubhav,

I had already added the macro defintion ( <CNTN02> , <CNTN03>.) in the class to use the macro. Is this type pool is different that those.

The do commit is already set to X by default in FM.

Former Member
0 Kudos

Hi Anjan,

I am using class and my other methods are working fine only this method is not able to create the contaner element.

anjan_paul
Active Contributor
0 Kudos

hi,

  If you already implemented the IF_WORKFLOW interface, then try with debugging. And share the screenshot of container elements at the point of  CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'

Former Member
0 Kudos

Hi,

Please implement the suggested steps and let me know. Its a tested approach.

Thanks,

Anubhav

Former Member
0 Kudos

Hi anubhav while trying this its throwoing an error stating that lcl_SWC is unknown. Not sure what I am doing wrong. I had added the SWC0 in type group in properties tab. The Objecttype is the SOFM and then its key. But what is the expected type decalrtion of the e_attachment and how this is used.

Former Member
0 Kudos

Hi Anjan,

At the FM call the container is empty.

anjan_paul
Active Contributor
0 Kudos

Hi,

  the variable im_workitemid, l_wa_header, lv_pdf_form, im_langu is it fillup up with proper value

Former Member
0 Kudos

Yes, Everything is getting filled properly. Even the attachment is also getting created to _ATTACH_OBJECT. Which I am trying to have Separately

Former Member
0 Kudos

Hi,

Do not use any other macro which belongs to SWC. Error is coming as you have declared SWC0 is type pool and using some macros which belong to SWC.

Just use swc0_create_object <Attachment Parameter> <'SOFM'> <Object Key>.

This will do.

Thanks,

Anubhav

bpawanchand
Active Contributor
0 Kudos

Hi,

So you are expecting out of two entries only the first entry in the container element _Attach_objects must be assigned to the decision step.

If you are sure that first entry is always the PDF attachment and the second entry is always comment then  pass/ define the binding  between WF container and task container as below:

Workflow Container          ->                   Task Container

_Attach_objects[1]               ->                 _Attach_objects

Regards

Pavan

Message was edited by: Pavan Bhamidipati

Former Member
0 Kudos

Hi Pavan, Thanks for response. We are not sure the order of the attachement so why I had not used this option.