How To Call Workflow From Abap Program Sap

SAP Workflow FAQ Techniques

Jan 06, 2009 Design the workflow having a simple Decision step and in the program exits tab include the class ZCLPROGRAMEXITWORKFLOW Activate and execute the workflow. An entry is made in the table but the WIEXECUTED field will not have any value. Now execute the work item from the SAP inbox (SBWP). For this task since we will be calling this thro’ workflow we are keeping it black. One can choose the task to be as background task. Also we can select other checkboxes which are Executable as form means which will run in foreground and If confirm end of processing is checked then it will ask for user input while ending task. He has expertise in the areas of SAP ABAP, Workflow, Odata and NetWeaver Gateway etc. Call function 'swustartworkflow' exporting task =. Language = sy-langu user =. Workitemid = tables. Messagelines = attachmentlist =.

What differences are there between a work item and a notification mail?

a) The work item cannot be used to notify several users. Mails can be routed to several users, just like work items. When a mail is sent, and one recipient reads and deletes the mail, all other recipients will still have access to their own copy in their own inbox. However, when a work item is processed by one of the recipients it will automatically disappear from all the other inboxes. So you can see that a work item is unsuitable for notifying several users. It is also worth noting that a mail can be forwarded in many different ways (fax, internet...) whereas the work item cannot.

b) The work item holds up the workflow
When the workflow sends a mail (usually as a background step) it continues with the process immediately after transmitting the mail. When a work item is generated, the workflow will not continue until the work item has been processed. This slows down the process. Occasionally this is what is intended (using the work item as an approval step without the ability to reject) but
usually you will better off using mails for notifications.

Note: You can send business objects as references with the mail either as a business object reference attached to the mail or as an URL (ABAP required).

What is the difference between sending a mail to a recipient list compared to sending individual mails via a dynamic loop?

Performance. Sending 1 mail to 20 recipients will cost considerably less performance than sending 20 individual mails. If the mail is sent as a SAP Office mail (as opposed to e-mail, fax...) disk space will also be a factor because the SAP office mail will only exist once in the database, with references being created for each of the recipients.

The only time you need to consider individual mails with a dynamic loop is when the text of the mail varies from one recipient to another.

How do I send a standard text as an e-mail from workflow?

It is very easy sending standard text , which may include data from the workflow. You simply create a background step which sends the work item description. This may include variables which will be substituted when mail is sent.

In early releases you have to create your own task based on the method SELFITEM SendTaskDescription. In later releases a wizard is available for creating the step and in release 4.6 there is even a step type which does this all for you automatically.
Whichever path you take, there is very good online documentation describing exactly what has to be done.

How do I send a complex text from the workflow?

You may create mails using SAPscript. These mails can include conditions which are evaluated in order to determine which text blocks which are used in the mail. Workflow variables can be used in these conditions and workflow variables can be substituted into the body of the e-mail text.

How do I send really complex mails from the workflow?

How To Call Workflow From Abap Program Sap

If you this is not enough for you will probably want to write your own ABAP routines for generating the text and generating the attachments to go with the text.

Use the function group SO01 which contains functions of the form SO_*_API1 which are ideal for creating your own sophisticated messages. There are plenty of advantages of how these are used within the SAP system.

How do I send reports?

There are wizards (Release 3.1) which will create workflows for you to send reports to a distribution list. You can specify whether the results should be transmitted or evaluated at the time the recipient wishes to view the report. It is usually better to send the evaluation because this allows the recipient to see the results instantaneously, without having to wait for the
report to execute first.

Deadlines
How can I configure the workflow so that different types of messages are sent out to different people depending on how late the processing is?

How To Call Workflow From Abap Program Sap System

Follow these steps:

1. Specify a deadline period for the step.
2. Specify a name for the event. This adds new branch from the step. More...
3. Add a new step to the branch which sends a mail message.
4. Add another step to the branch which sends out the second deadline warning (see mail steps above). Use deadlines in this step to configure an earliest start so that the second message is not sent until a further time has elapsed.
5. Repeat step 5 as often as you like.

How can I configure the workflow so that when the deadline is missed the workflow step is simply skipped?

This is tricky to explain but easy to implement once you know how.
Follow these steps (in later releases there is a wizard which takes you through the steps):
1. In the terminating events view of the workflow step activate the 'obsolete' event and give it a name. More...
2. Specify a deadline period for the step.
3. Specify a name for the event. This adds new branch from the step. More...
4. Add a new step to the deadline path. This step must be of type 'process control'.
5. Select the control 'Make step obsolete' and use the search help to specify the workflow step that has the deadline. Only steps with obsolete paths defined will be displayed (see step 1).

How do I trigger a workflow with an e-mail?

You can customize the system to call a BOR method when an external mail (fax, e-mail...) arrives in the system. You BOR method should either trigger the e-meil directly or trigger an event. To customize this user exit use the transaction SCOT.

How can I make sure that user's access their tasks via the workflow and not via the menu or launch pad?

The routing mechanism for work items uses roles and organizational assignments to determine who receives which work item. However the routing does not provide extra authorization checks based on the routing configuration. If you want to ensure that the tasks are executed within the workflow, and not via the standard transaction, service or MiniApp, then you will have to apply your own protection.
The simplest way of doing this is to remove the standard transaction from the user's menu or Workplace role (but include it in the supervisor's role, just in case).

If you want to allow the user to execute the task from the menu if and only if they have received the work item then you should replace the standard transaction with your own custom built transaction. Your own transaction simply calls the standard transaction but performs it's own authorization check first, based on the routing mechanism used in the workflow.
Tip: Add a second (ored) authorization check to make sure that a supervisor can execute the transaction in an emergency.

New branch for deadline step

By specifying the event name for a missed deadline (of whatever type) you are indirectly telling the workflow system that you want to add flow logic to your workflow to meet this event.
Don't be put off by he fact that the branch does not lead anywhere. This is because the branch is not an alternative to the other results of the step. It is followed in addition to the other paths. In other words the workflow processing specified for a missed deadline is followed without affecting the standard flow. The step with the missed deadline remains where it is and can still be processed as normal.

Read Also
Useful TCodes Used In SAP Workflow

SAP WF Reference Books:
SAP Workflow Configuration, Interview Questions and Certification, Books

Back to:
SAP Business Workflow Hints and Tips

Return to :-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity. Information used on this site is at your own risk.
All product names are trademarks of their respective companies. The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.


Here is an SAP Smartforms step by step example to open and call Smartform within ABAP code.
Within ABAP programs an SAP Smartform can be called and opened by calling the ABAP function SSF_FUNCTION_MODULE_NAME, we will see in the example ABAP code which is included with this Smartforms tutorial.

First, create a SAP Smartform report using ABAP transaction code 'smartforms' within ABAP Editor.
Or you can use an existing simple SAP Smartforms report to call from the example ABAP program.

In this SAP SmartForms tutorial, the example uses a SmartForm named 'ZSMARTFORMS_SALES_DOCUMENTS'.
The SmartForm application 'ZSMARTFORMS_SALES_DOCUMENTS' takes a table valued parameter to use as an internal table within SmartForms ABAP codes.
This SmartForms parameter table is 'it_vbak' which is declared in type table of VBAK SAP Sales and Distribution table.
SAP VBAK table is contains Sales Document header data.
As you will see in the below ABAP codes, the program select a range of VBAK Sales Document records into an internal table variable it_vbak.
Later the variable table is passed to the SAP SmartForm as a TABLE argument.

It is important that the table variable is correctly declared within the Smartform 's 'Global Settings > Form Interface > Tables' section.
As you will see in the below screenshot, it_vbak is declared as :
IT_VBAK TYPE VBAK

Abap

Example ABAP Program to Call Smartform

How To Call Workflow From Abap Program Sap Modules

Here is the example ABAP code to call SAP SmarForms from a program or an ABAP report.
Please note that we have ABAP codes which call ABAP function SSF_FUNCTION_MODULE_NAME with formname parameter is set to the target SAP Smartforms document.
The SSF_FUNCTION_MODULE_NAME ABAP call returns the FM_NAME which is the compiled ABAP program identifier and is in type rs38l_fnam.
The returned fm_name variable is then called using an ABAP Call Function method to open Smartform.
While calling Smartform, the Table parameter is passed as an input argument.

I hope, SAP Smartforms developers will find this sample ABAP code useful as beginning to SAP Smartforms.