cancel
Showing results for 
Search instead for 
Did you mean: 

Create Custom Attachment in User Descision

Former Member
0 Kudos

Hello Everyone,

I am relatively new to the workflow world. Before raising this question i have gone through all the previous threads but could not find an answer to my problem. Here is my problem

I have created a business object as below to create an attachment

      zswr_att_header-file_type = 'B'.

      zswr_att_header-file_name = 'PurchaseOrder'.

      zswr_att_header-file_extension = 'PDF'.

      zswr_att_header-language = 'EN'.

      CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'

        EXPORTING

          workitem_id = workitemid

          att_header  = zswr_att_header

          att_bin    = lv_file_xstring

        IMPORTING

          att_id      = zswr_att_id.

    ENDIF.

  ENDIF.

ENDIF.

swc_set_element container 'ZSWR_ATT_ID' zswr_att_id.

swc_create_object sofm 'SOFM' zswr_att_id-doc_id.

swc_set_element container 'SOFM' sofm.

however when this attachment is passed back to the workflow it shows there is no instance of this. How do i create an instance so that i can get the attachment in  my workflow?

Thanks

Ashok

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185167
Active Contributor
0 Kudos

Hello,

The call of SAP_WAPI_ATTACHMENT_ADD should be enough to attach the document to the workitem, assuming all of the parameters are in order.

Why don't you show us the whole method instead of just part of it?

regards

Rick Bakker

Former Member
0 Kudos

Hello Rick,

Thanks for your response.

 

the code in the method goes as follows

begin_method attach_document changing container.

data:

      workitemid type swr_struct-workitemid,

      zswr_att_id type swr_att_id,

      sofm type swc_object,

      zswr_att_header type swr_att_header,

      purchase_order type ebeln,

      smartform_name type tdsfname.

data : lv_func_name type rs38l_fnam,

       ls_output_options type ssfcompop,

       ls_control_parameters type ssfctrlop,

       ls_otf_data type ssfcrescl,

       lt_lines type standard table of tline,

       lv_file_size type i,

       lv_file_xstring type xstring.

swc_get_element container 'WORKITEMID' workitemid

swc_get_element container 'PurchaseOrder' purchas

swc_get_element container 'Smartform_Name' smartf

call function 'SSF_FUNCTION_MODULE_NAME'

  exporting

    formname           = smartform_name

  importing

    fm_name            = lv_func_name

  exceptions

    no_form            = 1

    no_function_module = 2

    others             = 3.

if sy-subrc = 0.

  ls_output_options-tddelete = 'X'.

  ls_output_options-tdimmed = ' '.

  ls_output_options-tddest  = 'LOCL'.

ls_control_parameters-getotf = 'X'.

ls_control_parameters-no_dialog = 'X'.

call function lv_func_name

   exporting

     control_parameters = ls_control_parameter

     output_options     = ls_output_options

     ebeln              = purchase_order

   importing

     job_output_info    = ls_otf_data

   exceptions

     formatting_error   = 1

     internal_error     = 2

     send_error         = 3

     user_canceled      = 4

     others             = 5.

if sy-subrc eq 0.

   call function 'CONVERT_OTF'

     exporting

       format                = 'PDF'

     importing

       bin_filesize          = lv_file_size

       bin_file              = lv_file_xstring

     tables

       otf                   = ls_otf_data-otf

       lines                 = lt_lines

     exceptions

       err_max_linewidth     = 1

       err_format            = 2

       err_conv_not_possible = 3

       err_bad_otf           = 4

       others                = 5.

   if sy-subrc eq 0.

      zswr_att_header-file_type = 'B'.

      zswr_att_header-file_name = 'PurchaseOrder'.

      zswr_att_header-file_extension = 'PDF'.

      zswr_att_header-language = 'EN'.

      CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'

        EXPORTING

          workitem_id = workitemid

          att_header  = zswr_att_header

          att_bin    = lv_file_xstring

        IMPORTING

          att_id      = zswr_att_id.

    ENDIF.

  ENDIF.

ENDIF.

Thanks

Ashok

former_member185167
Active Contributor
0 Kudos

Hello,

Let SAP help you!

*"  EXPORTING

*"     VALUE(RETURN_CODE) LIKE  SY-SUBRC

*"     VALUE(ATT_ID) LIKE  SWR_ATT_ID STRUCTURE  SWR_ATT_ID

*"  TABLES

*"      MESSAGE_LINES STRUCTURE  SWR_MESSAG OPTIONAL

*"      MESSAGE_STRUCT STRUCTURE  SWR_MSTRUC OPTIONAL

Test the return code and if it's not zero then return the message lines and make the method go into error.

regards

Rick

Former Member
0 Kudos

Thanks Rick. The business requirement changed and now we are providing a link to display the purchase order from the work item.