`
evangxli
  • 浏览: 231933 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

转 Sending multiple attachment in user decision step of workflow

 
阅读更多

Sending multiple attachment in user decision step of workflow

By Lokesh Tripathi, Infosys from Link

Business Requirement

This document describes how to send multiple attachments in the user decision step of the workflow.
User can see multiple attachments and based on that take the necessary required decision.

This method would be helpful in business processes where user wants to introduce approval step before processing or accepting any finance report or other document.                                    

Functional Specification

User will execute the custom report/transaction that will trigger the workflow (we can associate starting event also to this workflow).
Workflow will send mail having multiple attachments to SAP Inbox as a user decision.
Based on user decision rest logic would happen.

Workflow Flow Diagram  

 

Technical Specification

For adding attachments in the user decision steps method EVENT_RAISED of interface IF_SWF_IFS_WORKITEM_EXIT needs to be implemented and it is used as a Function Exit in the user decision step.



Go to SE24, implement method EVENT_RAISED of interface IF_SWF_IFS_WORKITEM_EXIT
ZTEST_WFATTACH is created for the same.





In this method code for inserting attachments needs to be implemented (Please use below code for the same)
First check whether workflow container already have any attachments or not to avoid any duplications.

* Fetch the workflow work item Id
CALL METHOD IM_WORKITEM_CONTEXT->GET_WORKITEM_ID
    RECEIVING
    RE_WORKITEM = LV_ID.

* Fetch Container
CALL METHOD IM_WORKITEM_CONTEXT->GET_WI_CONTAINER
    RECEIVING
    RE_CONTAINER = LV_CONTAINER.

* Read attachment to confirm that there is no duplication
CLEAR LV_OBJ_RECORD.
CALL METHOD LV_CONTAINER->GET
    
EXPORTING
      NAME  = 
'_ATTACH_OBJECTS'
    
IMPORTING
      
VALUE = LV_ATTACH.
IF LV_ATTACH IS INITIAL.

If  there are no prior attachments then identify the folder id based on sy-user


CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
     
EXPORTING
       OWNER     = SY-UNAME
       REGION    = 
'B'
     
IMPORTING
       FOLDER_ID = LV_FOLDER_ID.


In this scenario we are converting spool output to PDF and attaching the same PDF in the user decision step    

Give spool number in  LV_SPOOL field

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
   
EXPORTING
        SRC_SPOOLID              =  LV_SPOOL
        NO_DIALOG                = 
''
        PDF_DESTINATION          = 
'X'
   
IMPORTING
        PDF_BYTECOUNT            = LA_BYTE_COUNT
   
TABLES
        PDF                      = GT_PDF
   
EXCEPTIONS
        ERR_NO_ABAP_SPOOLJOB     = 
1
        ERR_NO_SPOOLJOB          = 
2
        ERR_NO_PERMISSION        = 
3
        ERR_CONV_NOT_POSSIBLE    = 
4
        ERR_BAD_DESTDEVICE       = 
5
        USER_CANCELLED           = 
6
        ERR_SPOOLERROR           = 
7
        ERR_TEMSEERROR           = 
8
        ERR_BTCJOB_OPEN_FAILED   = 
9
        ERR_BTCJOB_SUBMIT_FAILED = 
10
        ERR_BTCJOB_CLOSE_FAILED  = 
11
        
OTHERS                   12.

LOOP AT GT_PDF INTO LWA_PDFLINE.
  
ASSIGN LWA_PDFLINE TO <L_XLINE> CASTING.
  
CONCATENATE PDF_XSTRING <L_XLINE>      
 
INTO PDF_XSTRING IN BYTE MODE.
ENDLOOP.

* Create and set document
IT_SOLIX_TAB1 = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX (PDF_XSTRING).

Creating First attachment

 LV_DATA-OBJ_NAME   = 'Test Sending Attachments'.
 LV_DATA-OBJ_DESCR  = 
'Attachment 1'.
 LV_DATA-OBJ_LANGU  = SY-LANGU.
 LV_DATA-SENSITIVTY = 
'P'.
 LV_DATA-DOC_SIZE   = LA_BYTE_COUNT.


 CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'
      
EXPORTING
          FOLDER_ID                  = LV_FOLDER_ID
          DOCUMENT_DATA              = LV_DATA
          DOCUMENT_TYPE              = 
'PDF'
      
IMPORTING
          DOCUMENT_INFO              = WA_DOCUMENT_INFO
      
TABLES
          CONTENTS_HEX               = IT_SOLIX_TAB1
      
EXCEPTIONS
          FOLDER_NOT_EXIST           = 
1
          DOCUMENT_TYPE_NOT_EXIST    = 
2
          OPERATION_NO_AUTHORIZATION = 
3
          PARAMETER_ERROR            = 
4
          X_ERROR                    = 
5
          ENQUEUE_ERROR              = 
6
          
OTHERS                     7.
* Populate object type and object key for create an instance
LV_OBJTYPE = 'SOFM'.
LV_OBJKEY  = WA_DOCUMENT_INFO-DOC_ID
.

Creating SOFM object

CALL FUNCTION 'SWO_CREATE'
     
EXPORTING
        OBJTYPE           = LV_OBJTYPE
        OBJKEY            = LV_OBJKEY
     
IMPORTING
        OBJECT            = LV_SOFM
        
RETURN            = LV_RETURN
     
EXCEPTIONS
        NO_REMOTE_OBJECTS = 
1
        
OTHERS            2.

* Prepare for attaching the object to container
LV_OBJJECT-HEADER = 'OBJH'.
LV_OBJECT-TYPE   
'SWO'.
LV_OBJECT-HANDLE  = LV_SOFM.

APPEND LV_OBJECT to TB_OBJ.

Similarly prepare other attachments and append their details to tb_obj internal table.
Finally send the attachment details in the task container

CALL METHOD LV_TAKS_CONTAINER->SET
      
EXPORTING
       NAME  = 
'_ATTACH_OBJECTS'
       
VALUE = TB_OBJ[].

* Commit the changes
CALL METHOD IM_WORKITEM_CONTEXT->DO_COMMIT_WORK.

 

Now create the workflow in SWDD and in the user decision step give class ZTEST_WFATTACH as a program exit.

 

 

Program exit would get triggered whenever user step is executed by the user.

 

Binding of user decision step:

 

 

 

 

Execution:

 

Once workflow is created you can associate with any event or you can directly execute it to check the result.

 

 

 

 

 

After reviewing the document user can take the necessary decision.

分享到:
评论

相关推荐

    Step by Step for configuration of sending customize IDOC

    ### SAP 自定义IDOC类型发送接收处理详细步骤 在企业级应用中,SAP系统间的交互经常通过IDOC(Intermediate Document)实现。IDOC是一种用于SAP系统间数据传输的标准格式,广泛应用于供应链管理等场景。...

    Java邮件开发Fundamentals of the JavaMail API

    your program to use IMAP instead of POP and expect everything in IMAP to be supported. Assuming your mail server supports IMAP, your JavaMail-based program can take Fundamentals of the JavaMail API...

    This is a complete email sending client in Visual Basic

    标题中的“这是一款完整的Visual Basic电子邮件发送客户端”表明这是一个使用Visual Basic编程语言开发的应用程序,其功能是允许用户发送电子邮件。在IT领域,这通常涉及到SMTP(Simple Mail Transfer Protocol)...

    Android.Programming.2nd.Edition.B00WMRMW8C

    Title: Android Programming, 2nd Edition Author: Kevin Lyn. Length: 163 pages ...Chapter 4: User Interface in Android Chapter 5: Event Handling in Android Chapter 6: Advanced features in Android

    oracle_10g提示java.lang.Exception_Exception_in_sending_Request__null解决方案

    ### Oracle 10g 提示 java.lang.Exception: Exception in sending Request :: null 解决方案 在使用Oracle 10g的过程中,部分用户可能会遇到一个特定的问题:在登录企业管理器(Enterprise Manager, EM)时,系统会...

    Sending Email using MAPI - A COM DLL(sending email demo and soucecode)

    The display name of the attachment (Sample.txt), by default, it’s the same as that specified in put_strAttachmentFilePath. get_strAttachmentFile Returns the attachment file name. Logon ...

    MIT@001-WorkFlow Management

    Of course, the database will have to be updated in order to reflect the new status of this person. This is done after sending the letters, by the same person from recruitment who sent the letter.

    Artech House - SMS and MMS Interworking in Mobile Networks

    13.7 Main Results in the Theory of Resultants and Sturm’s Theorem 206 13.7.1 Purpose of the Theory of Resultants 206 13.7.2 Main Result for Two Algebraic Equations 206 13.7.3 Sturm’s Theorem 208 ...

    sending_file.rtf.zip_This Just In..

    IT is a small program which illustrate the concept of sending the file to a remote destination.The concept given in this program is purely for the beginners who just needs to understand the concept ...

    Android.App.Development.in.Android.Studio.Java.Android.Edition.For.Beginners.pdf

    As the reader follows the development of the example apps, he/she will learn designing user interfaces, connecting interface objects to code, developing efficient Java code and testing the app on ...

    Go in Practice.pdf

    ### Go in Practice: Key Takeaways and Detailed Analysis #### Overview The book "Go in Practice" is an essential resource for developers looking to deepen their understanding and proficiency in the Go...

    Learning.Google.Apps.Script.178588

    You will be guided through all these tasks with plenty of screenshots and code snippets that will ensure your success in customizing and automating various Google applications This guide is an ...

    Recover4all Professional

    恢复删除的文件 LICENSE AGREEMENT FOR RECOVER4ALL PROFESSIONAL SOFTWARE PROGRAM ...You may register the name of each such individual by sending an email requesting registration to support@recover4all....

    基于微信小程序的校园约拍设计与实现ssm毕业论文.doc

    MySQL, as a Relational Database Management System (RDBMS), is used to store and manage the various types of data involved in the platform, including user profiles, merchant information, product ...

    分享在一键boot时出现sending boot FAILED的解决方案

    然而,一些用户在尝试一键boot时可能会遇到“sending boot FAILED”这样的错误,导致刷机过程无法正常进行,窗口瞬间关闭。这通常是由于设备与计算机之间的通信问题,或者是bootloader加载失败所引起的。 为了解决...

    计算机网络第六版答案

    Wifi (802.11) In a wireless LAN, wireless users transmit/receive packets to/from an base station (i.e., wireless access point) within a radius of few tens of meters. The base station is typically ...

Global site tag (gtag.js) - Google Analytics