Oct 07, 2012 Create a simple SAP Workflow and then initiate it via a custom Web Dynpro for ABAP app. It is recommended then you first view part 2 and part 3 of my SAP Tutorial series. See all SAP Tutorials. He is also the SAP Technical consultant currently working in Cognizant Technologies Pvt Ltd. He has done his MS in Software Engineering from VIT University, Vellore. He has expertise in the areas of SAP ABAP, Workflow, Odata and NetWeaver Gateway etc.
- Sap Abap Submit Program
- How To Call Workflow From Abap Program Sap Free
- How To Call Workflow From Abap Program Sapphire
- How To Call Workflow From Abap Program Sap Login
- How To Call Workflow From Abap Program Sap Software
- I am developing in ABAP. I have a requirement to trigger a custom event in an ABAP Z-program. Can anyone pls tell me how can I call a custom event in a Z-program to send an email. (please note: It is not workflow, I need to complete this task in the Z-program).
- Feb 27, 2019 To Call workflow From abap Program Dear All Experts. Please i want step-by-Step To know how to call mu workflow from ZPrograme i know that FM SAPWAPISTARTWORKFLOW is Do that but it not working with my ( I did simple one. One mail step ) i want to call it from Zprograme. Trigger workflow when a record is created in a database table.
Structure of ABAP Program
ABAP program consists the following structure
- Header
- Global Declarations
- Processing Logic
- Definition of Reusable Blocks
Header
Header section provides the detailed information about the development and which is the standard template for all custom ABAP developments. The first statement of ABAP program starts with a word PROGRAM or REPORT. It is not mandatory to mention the program name, but for documentation purpose correct name of ABAP program should be used.
When the user creates a program, by default system inserts the first ABAP statement
- For module pools – PROGRAM <name of program>
- For executable pools – REPORT <name of report>
Global Declaration
Global declaration declares all the global variables
Processing Logic
Processing logic block is used to implement the business logic and it is written for declaration.
Definition of Reusable Blocks
You can define reusable components once and you can call components wherever they are need for business logic.
Pre-requisites to create an ABAP programs
- Every SAP ABAP program should have a name and should begin with a letter Y or Z. The letters from A to X is reserved for SAP programs.
- Title : – Description of the program
- Type : – Types of ABAP program are
- Executable program,
- Include program and
- module pool program.
- Package : – Package a place where the program has to be created and stored. In real time package is created for each module/sub-module but not individuals.
Characteristics of ABAP program
- ABAP programming language is not a case sensitive. But it is a space sensitive, it should have space between the programming words.
- ABAP is only case sensitive during camparison
- Every ABAP statement should end with a period (full stop).
- The program name should not contain a special characters such as ” , – ( ) “, spaces, etc.
- The program name should be unique and description length upto 30 characters long.
An Example of SAP ABAP Program
![Sap abap submit Sap abap submit](/uploads/1/2/6/2/126234900/125227193.png)
Where ABAP programs are stored?
ABAP Repository is a special memory in the database of SAP R/3 system and ABAP programs are stored in this memory.
Skip to end of metadataGo to start of metadataSap Abap Submit Program
General Scenario where you can use:
In General, we may come across the scenarios where, when ever a work item is created, or executed, we may need to update the database tables or we need to execute a separate task in background or we may need to get the workflow container values and manipulate them dynamically at run time and set the new values to the workflow container elements. In these sorts of cases we can use Program Exits in the workflows.
A Considered Case to explain the use of program exits:
A ZWORKITEM_INFO table with 7 fields
Field | Data Element | Description |
WI_ID | SWW_WIID | Work item ID |
WI_TYPE | SWW_WITYPE | Work item type |
WI_CREATOR | SWW_OBJID | Creator of work item |
WI_RH_TASK | SWW_TASK | Task ID |
WI_PRIO | SWW_PRIO | Priority of work item |
WI_CD | SWW_CD | Creation date of work item |
WI_EXECUTED | CHAR1 | Confirmation of execution |
How To Call Workflow From Abap Program Sap Free
Include a Decision step in the workflow whenever the respective work item is created an entry is inserted in the table ZWORKITEM_INFO. Once the work item is executed from SBWP, field WI_EXECUTED of the above table is set to 'X'.
Understanding the Interface IF_SWF_IFS_WORKITEM_EXIT:
IF_SWF_IFS_WORKITEM_EXIT is a Runtime Exit Workflow Interface. If you look at the interface it consists of one method EVENT RAISED and attributes are of CONSTANT type belong to SWW_EVTTYP Event Type for Workflow Runtime. This interface includes a type-group SWRCO which contains all the constant attribute values that are used in this interface like SWRCO_EVENT_AFTER_CREATE etc.
The following are the possible predefined events that can occur with respect to a work item.
- Before Creation
- After Creation
- Before Execution
- After Execution
- After Execution of a Synchronous Object Method
- Before Physical Deletion
- After a Status Change
- After Rule Execution
- After an Action
- Before an Action
How To Call Workflow From Abap Program Sapphire
As it has been already mentioned in the SAP help documentation that, the classes are used in the Program Exits tab must support the interface IF_SWF_IFS_WORKITEM_EXIT and this class must not have any call to the RFC function modules, or it must not contain any statements like COMMIT_WORK, ROLL BACK etc.
Defining the ABAP Class that Supports IF_SWF_IFS_WORKITEM_EXIT
Properties of the ABAP class should be as shown in the screen shot and add the type group SWRCO.
In the Interface tab add the interface IF_SWF_IFS_WORITEM_EXIT. After adding the interface look at the ATTRIBUTES tab it will be like the below screen.
Here we need to define two more attributes along with the included attributes they should be Instance specific and private and I have declared WI_CONTEXT as type ref to one more interface IF_WAPI_WORKITEM_CONTEXT this interface will provide you the current context for the work item. PROCESS_STATUS is another attribute which define the name of the property for semantic process status and initial value must be assigned as 'sap.bc.bmt.wfm.process.status'.
Check the METHOD Tab it will have one method included by default when you include the interface IF_SWF_IFS_WORKITEM_EXIT.
Here I have defined two more methods to handle the predefined events of the work item. Now implement the method of the interface EVENT_RASIED. The minimum code that is required to validate the event name and which method should act as event handler.
After execution of the Event Raised method the attribute WI_CONTEXT will have the current context (Current Status of the work item) of work item. i.e. the instance of the interface IF_WAPI_WORKITEM_CONTEXT is created.Once the instance of the IF_WAPI_WORKITEN_CONTEXT is created then by using its different methods, we can retrieve the information related to the workitem.
The interface IF_WAPI_WORKITEM_CONTEXT has the following methods by which we can retrieve the information that is needed about the work item.To see full list of methods, execute SE24 enter the interface name and click on the Methods tab.
Implementation of AFETR_CREATION ( ) method
In this method implementation observe the CALL METHOD statement where it is calling get_header method which belongs to the interface IF_WAPI_WORKITEM_CONTEXT, which will return the header information of the workitem for more information about the header information open the structure SWR_WIHDR in SE11.
Implementation of AFTER_EXECUTION ( ) method.
How To Call Workflow From Abap Program Sap Login
The same work item context is used in the AFTER_EXECUTION method to get the work item ID See the CALL METHOD statement in the AFTER_EXECUTION method.
Design the workflow having a simple Decision step and in the program exits tab include the class ZCLPROGRAM_EXIT_WORKFLOW Activate and execute the workflow. An entry is made in the table but the WI_EXECUTED field will not have any value. Now execute the work item from the SAP inbox (SBWP). Now the WI_EXECUTED field in the table will be updated by X.