You are on page 1of 40

SAP WORKFLOW

JH SOFTECH

For Online SAP Classes contact us at


Skype ID
Aditya.jhsoftech
Whats App 7842000555
For Free Online Material
Like us on www.fb.com/jhsoftech1
Follow us in www.twitter.com/jhsoftech
https://plus.google.com/+JhSoftech/

-1www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

JH SOFTECH
Your partner to excel

SAP WORKFLOW

JH SOFTECH
ISO 9001 2008 Certified

301,Pavani Anasuya Towers, Opp HUDA Complex, Tarnaka, Hyderabad.INDIA


Ph: 040 66310555, 66311555, 07842000555
www.jhsoftech.com

-2www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Basics of Workflow
Basics of BOR objects
Steps to create workflow
Followed by practical

-3www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Procedures
Procedures contain a set of statements, and are called from other ABAP programs.
The processing blocks that you call from ABAP programs are called procedures
You define procedures in ABAP programs. When the program is generated, they remain
as standalone modules. You can call procedures in the program in which they are
defined, or from external programs. Procedures have an interface for passing data, and
can also contain local data.
ABAP contains the following kinds of procedures:

Subroutines
Subroutines are principally for local modularization, that is, they are generally
called from the program in which they are defined. You can use subroutines to
write functions that are used repeatedly within a program. You can define
subroutines in any ABAP program.

Function Modules
Function modules are for global modularization, that is, they are always called
from a different program. Function modules contain functions that are used in the
same form by many different programs. They are important in the R/3 System for
encapsulating processing logic and making it reusable. Function modules must
be defined in a function group, and can be called from any program.

Methods
Methods describe the functions and behavior of classes and their instances in
ABAP Objects. Methods must be defined in classes. When you call them, you
must observe certain special rules of object-oriented programming.

BOR
Error! Reference source not found.Error! Reference source not found.Error!
Reference source not found.Error! Reference source not found.Definition
The Business Object Repository (BOR) is the object oriented repository in the R/3
System. It contains, among other objects, SAP Business Objects and their
methods.

-4www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

In the BOR a Business Application Programming Interface (BAPI) is defined as an


API method of an SAP Business Object. Thus defined, the BAPIs become
standard with full stability guarantees as regards their content and interface.
Use
With regard to SAP Business ObjectsError! Reference source not found. and
their BAPIs, the BOR has the following functions:
Provides an object oriented view of R/3 System data and processes.
R/3 application functions are accessed using methods (BAPIs) of SAP
Business Objects. Implementation information is encapsulated; only the
interface functionality of the method is visible to the user.
arranges the various interfaces in accordance with the component hierarchy,
enabling functions to be searched and retrieved quickly and simply.
Manages BAPIs in release updates.
BAPI interface enhancements made by adding parameters are recorded in the
BOR. Previous interface versions can thus be reconstructed at any time.
When a BAPI is created the release version of the new BAPI is recorded in the
BOR. The same applies when any interface parameter is created.
The version control of the function module that a BAPI is based on is managed
in the Function Builder.
Ensures interface stability.
Any interface changes that are carried out in the BOR, are automatically
checked for syntax compatibility against the associated development
objectsError! Reference source not found. in the ABAP Dictionary.
Error! Reference source not found.Error! Reference source not found.Error!
Reference source not found.Error! Reference source not found.Error! Reference
source not found.Error! Reference source not found.Error! Reference source not
found.Error! Reference source not found.Error! Reference source not
found.Definition
Some BAPIs and methods provide basic functions and can be used for most SAP
Business Objects. These BAPIs are:
BAPIs for Reading Data
The following BAPIs provide you with read-only access to data in the associated
Business Object:
GetList
With this BAPI you can select a range of objectError! Reference source not
found. key values, for example, company codes and material numbers. To
specify appropriate selection requirements the calling program must pass the
relevant parameters to the interface.
The key values selected by the BAPI GetList are returned to the calling
program in a table, together with other useful information, for example, short
texts. The key values can then be passed on to another BAPI for further
processing, for example, the BAPI GetDetail, as listed below.

-5www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

For further information on programming GetList BAPIsError! Reference


source not found. see Programming Value Ranges.
GetDetail
The BAPI GetDetail uses a key to retrieve details about a specific instance of
an objectError! Reference source not found. and returns this data to the
calling program.
GetStatus
The BAPI GetStatus is used to query the status of an SAP Business Object, for
example, to determine the processing status of a sales order. This BAPI is
used only for displaying the status of an object and does not retrieve full details
like the BAPI GetDetail.
ExistenceCheck
The BAPI ExistenceCheck checks whether an entry exists for an SAP
Business Object, for example, whether the customer master has been created.
You should implement this method as a workflow method and not as a BAPI
(RFC capable function module).
The method CompanyCode.ExistenceCheck of the business objectError!
Reference source not found. CompanyCode (BUS0002) is an example of
this. This workflow method is indirectly invoked when the calling program
instantiates an object, for example, by using GetSAPObject("CompanyCode")
from within Visual Basic.
Example of a Function Module
This exampleError! Reference source not found. function module implements
the BAPI CompanyCode.GetDetail of the SAP Business Object CompanyCode
(BUS0002).
The BAPI CompanyCode.GetDetail reads details of a company code.
Note the following in the source code:
The name of the function module is in the format: BAPI_<Business Object
name>_<Method name>.
Specific BAPI data structures are used, identified by the prefix BAPI.
The key field parameter "COMPANYCODEID" is defined as the import
parameter.
The function module performs authorization checks.
The function module covers all exceptions.
Source Code
function bapi_companycode_getdetail.
*"-----------------------------------------------------*"*"Local interface:
*" IMPORTING
*"
VALUE(COMPANYCODEID) LIKE BAPI0002_2-COMP_CODE

-6www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

*" EXPORTING
*"
VALUE(COMPANYCODE_DETAIL) LIKE BAPI0002_2
STRUCTURE BAPI0002_2
*"
VALUE(COMPANYCODE_ADDRESS) LIKE BAPI0002_3
STRUCTURE BAPI0002_3
*"
VALUE(RETURN) LIKE BAPIRETURN
STRUCTURE BAPIRETURN
*"------------------------------------------------------

* authority check: S_TABU_DIS V_T001


perform check_authority_t001 changing return.
check return is initial.
* company code
call function 'FI_COMPANY_CODE_DATA'
exporting
i_bukrs
= companycodeid
importing
e_t001
= t001
exceptions
error_message = 1
others
= 0.
if sy-subrc ne 0.
perform set_return using '10' changing return.
endif.
check return-code is initial.
endfunction.
SWO1

-7www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

-8www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

-9www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

- 10 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

- 11 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

SWC_SET_ELEMENT CONTAINER 'Return' RETURN.


SWC_SET_TABLE CONTAINER 'NetworkList' NETWORKLIST.
END_METHOD.

Extending Object Types: Inheritance and Delegation


Use
In particular situations you will need to modify an object type in conjunction with
delegation rather than create a new object type. This applies whenever you want to add
components to an object type which are not provided in the standard version and at the
same time need to ensure that productive scenarios with the original SAP object type
remain operational.
If no modifications are required, you can use any released object type provided by SAP
as it is.
Conventions for the other sections of the tutorial
The procedure described below consisting of create subtype and delegation is always
required when you have to extend an SAP object type to meet your requirements.
However, within this tutorial it is always assumed that the object type to be maintained
did not exist in the Business Object Repository and therefore is created from scratch.
This section therefore informs you about the procedure involved in certain extensions,
but does not really belong to the tutorial.
Procedure
Creating a subtype
Create a new object type as the subtype of the object type you want to extend. This
subtype automatically inherits all the components (methods, attributes, and events) of
the original object type including its implementation.
1. Choose
Business Workflow
Business Object Builder.
2. In the field Object type, enter the object type you want to extend. This is then the
supertype in the inheritance hierarchy.
3. Choose Subtype.

- 12 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH
4. For the new object type, enter:

A unique name that can be used to identify it


An object name
A name
A short description

1. Enter the name of the implementation program of the object type and assign the
code letter of your application.
2. Confirm your entries with and save the object type created as a local object or
with package in a transport request.
Entering a delegation type
Before you process "your" object type any further, define it as the delegation type of the
supertype.
1. Exit maintenance of the object type and go back to the Business Object Builder.
Choose Settings Delegation System-wide.
2. Add a new entry to the table. To do this, choose Table view Display Change,
then Edit New entries.
3. Enter the name of the object type (supertype) for which you want to specify a
delegation type.
4. Enter the name of the subtype as the delegation type.
5. Choose .
The delegation entered is cross-client.
In all SAP Business Workflow definition tools, you still have to use the "old" object type
(supertype). However, when the definition is read and evaluated (at runtime, for F4 input
help, and so on), the definition of the delegation type (subtype) is used.

STEP BY STEP Creation of BAPI

Scenario: Step-by-step creation of a BAPI to retrieve fields from table T001.


Procedure: Go to transaction SE11 and create a structure as shown or as per your
requirement.
Give the name in the Data type field and click create.

- 13 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

In the pop-up that comes up, select the radio button structure.

- 14 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

In the components tab of the structure, give the different fields and their corresponding
field types and press enter to check the compatibility and corrective ness.

Do not forget to save it in a package. You can even save it as a local object. For my
example, I save it in a package.

- 15 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Check the structure (ctrl + F2) and activate (ctrl + F3) the structure.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now we are done with the creation of a Structure.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Go to transaction SE37 where you create function modules. Click on create after you
enter the name of the Function module.

- 16 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

A screen as shown above would pop-up where you mention the function group to save
the function module and also provide some short text describing your function module.

In the next pop-up that follows, click on continue as shown above.

- 17 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

The function module screen would look like the one above.

Go to the Attributes tab and select the radio button reading remote-enabled module.
Come back to the imports tab and provide the import parameters as shown or as per
your requirement.

- 18 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Now in the Export tab, provide the export parameters as shown or as per your
requirement.

In the tables tab, provide the information as shown or as per your requirement.

The next screen you visit is the source code. It would look like this.

- 19 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

In the source code tab, write the following code in order to pick the data based on the
input you provide.

Now, save and check the code and activate the function module.
After successful activation,
moduleReleaseRelease.

Go

to

the

attributes

tab.

Go

to

- 20 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

Function

SAP WORKFLOW

JH SOFTECH

+++++++++++++++++++++++++++++++++++++++++++++++
Now we are done with the creation of a Function Module.
+++++++++++++++++++++++++++++++++++++++++++++++
Go to transaction SWO1 and enter the name of the BAPI you would like to create or as
shown in the screen and click the create button.

Give the name of the BAPI as above and click on create.

- 21 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Give the above-mentioned details and click on the continue icon.

Save in a package.

- 22 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH
The resulting screen is as follows.

Now click on the methods to drop down and see what methods are provided by default.
There would be two methods, showing in red color which come by default while creating
the BAPI.

- 23 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Click or select the method as shown above and go to the path UtilitiesAPI
methodsAdd methods.
On the screen that follows, provide the function module name and click on the continue
icon.

- 24 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

In the ultimate pop-up, click the next step icon. We observe that the information is
predefined in the fields.
This is the next screen where you would just click on the next icon.

- 25 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Click on Yes. You can see an information message reading ZBAPIFMT001 inserted.

Now save after you add the method. Select & Double click on the API method.
Go to Tab: ABAP Check 'API Function'.

- 26 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

The above screen is displayed. Go to the ABAP tab as shown below.

- 27 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Select the Radio button reading API Function as already said above.

- 28 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

click on the continue icon to proceed further.


Now select the Object ZBAPI_T001 as shown below.

- 29 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

Go to : EditChange Release StatusObject type To Modeled.

The above shown screen will be displayed. Click on yes.


The message shows, The object type status set to modeled. (or already modeled)
Go to : EditChange Release StatusObject type To Implemented.

- 30 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

You can see a message reading Object type status set to implemented
Now, go to: EditChange Release StatusObjectTo Released.

There would be two pop ups coming up. Click continue on the Pop Ups.
Keep the cursor on the 'Method'.
Go to: EditChange Release StatusObject type componentTO Modeled.

- 31 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

You can see the message reading status for method zbapifmt001 set to modeled.
Now, go to: EditChange Release StatusObject type component TO Implemented

You can see the message reading status for method zbapifmt001 set to
implemented.
Now go to: EditChange Releasse Status Object type component To Released

- 32 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

You can see the message reading status for method zbapifmt001 set to Released.
Click on Generate Button. (the red ball kind of button is the Generate button)

After clicking on the generate button, you can see the message reading Object type
'ZBAPI_T001' generated successfully.
Now go to BAPI Tcode (BOR) there we can find the BAPI (our BAPI)
The BAPI browser would look like the screen below.

- 33 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

You can click on the Alphabetical tab so that you can browse the BAPIs in an
alphabetical order. Find your BAPI as shown.

- 34 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now we are done with the creation of a BAPI.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Test Your BAPI.

Enter the name of your BAPI in the transaction SWO1 and click on Test.

on

the

Execute

icon

against

The above screen is displayed. Click


the
BAPI
as
shown.

- 35 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

The above screen is displayed where you would require entering the data against the
empty input fields.

We have entered some data in the Field.


After entering the data, click on the execute icon as shown below.

- 36 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

The following screen is displayed which has some values as is indicated by the
ITEMTAB.

Click on the Edit table icon as shown below.

- 37 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

The results as per our input are as shown below.

By this, we would get it confirmed that our BAPI is working properly.


We can even check it by passing different values again. Come back to the input and
execution screen.

- 38 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

After executing the BAPI based on the input provided, we get the following screen.

Hit on the execute icon.

- 39 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

SAP WORKFLOW

JH SOFTECH

In the above shown screen, hit on the edit table icon.

The above is the output we get from the input we provided.


We are now done with the creation and successful execution of a BAPI.

- 40 www.jhsoftech.in
Pavani Anasuya Towers, Tarnaka, Hyderabad, INDIA.Ph: +91 040- 66310555, 66311555

You might also like