0% found this document useful (0 votes)
276 views

Exp 0011

exp_0011

Uploaded by

chandra9000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
276 views

Exp 0011

exp_0011

Uploaded by

chandra9000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 34

0

BAPIs

Contents:
 BAPI Basics
 Test Data for the Asset Master
 Transfer of Assets Using BAPIs

 SAP AG 1999

© SAP AG BC420 11-1


0.2
BAPIs: Unit Objectives

At the conclusion of this unit you will be able to:

 Describe external data transfer using BAPIs


 Transfer asset master data into R/3 using BAPIs

 SAP AG 1999

© SAP AG BC420 11-2


0.3
Course Overview Diagram

Call Transaction
Batch Input

Direct Input

TA Recorder
7 12 IDoc BAPI
9
10
11
11 12
Principles of Standard 4
Data Tansfer

DX Workbench 11
3 5
LSM Workbench
8 10 11

6 Basics 13

2 Datenübernahme 14

1 Course Overview

 SAP AG 1999

© SAP AG BC420 11-3


0.4
BAPIs

BAPIBasics
BAPI Basics

Test Data
Test Datafor
for the
the Asset
AssetMaster
Master

Transferof
Transfer of Assets
AssetsUsing
Using BAPIs
BAPIs

 SAP AG 1999

© SAP AG BC420 11-4


0.5
Overview of Standard Transfer Using BAPIs

Program
SAP Record
SAP Standard Layout
Structure

BAPI BAPI
& IDoc
SAP IDoc
Structure

Trans. R
e corder

Flat SAP
Structure

 SAP AG 1999

 This unit deals with the transfer of legacy data using BAPIs.

© SAP AG BC420 11-5


0.6
Interfaces for Standard Transfer Using BAPIs

FI BAPI

SAP System
MM BAPI

SAP IDoc
Structure

HR BAPI

 SAP AG 1999

 External data in the IDoc format is required for calling BAPIs from the DX-WB. Mapping tools,
such as the Legacy System Migration Workbench (LSMW), must therefore be used to convert the
external data to the IDoc format.

© SAP AG BC420 11-6


0.7
Business Application Programming Interface

 Business Application Programming Interface

 A BAPI is a precisely-defined interface for processes


and data of a business application system and is
implemented as a method
of an object in the Business Object Repository (BOR).

 SAP AG 1999

 Each BAPI that creates an object instance or changes the data belonging to an object leaves the
database consistent. All database changes are carried out completely or not at all.
 The "COMMIT WORK“ command to save the database changes are not called by the BAPI itself.
They have to be called by the calling program.
 BAPIs are non-dialog methods that do not have any screen dialogs with the user.

© SAP AG BC420 11-7


0.8
Characteristics of BAPIs

 Object-oriented
 Implemented as object methods of the BOR

 Stable interface
 The interface of a BAPI is “frozen”

 Can be used internally and externally


 BAPIs can be used in R/3 and from external systems

 No presentation layer
 Callers have to display the results themselves

 Success and error messages in export parameter


RETURN
 Structure or internal table (depending on BAPI )
 SAP AG 1999

 BAPIs can also be called by external clients as methods of objects that are instantiated in the client
itself.
 SAP guarantees that the interface of an SAP BAPI will not be changed.
 Also within R/3 BAPIs can be used locally to access business data. This makes customer and partner
enhancements of R/3 functionality easier.
 The calling program must present the data that is passed to or from a BAPI.
 The return parameter RETURN contains success and error messages of the BAPI and depending
on the R/3 Release it has the Dictionary structure BAPIRETURN, BAPIRETURN1, BAPIRET1,
BAPIRET2 or BAPIRET2_FIX. The (common) relevant fields of these structures are:
TYPE (message type: S(uccess), E(rror), W(arning), I(nformation) ) ;
ID (message class) ; NUMBER (message number) ; MESSAGE (message text) ;
MESSAGE_V1 , MESSAGE_V2 , MESSAGE_V3 , MESSAGE_V4 (message variables)
 If the message transfer is successful, RETURN is either empty (all fields have their initial value) or
the field TYPE contains the value 'S'. Refer to the documentation on the BAPI in question to find
out which option applies.

© SAP AG BC420 11-8


0.9
The Business Object “Asset"

E x ss
BO

am ets
a

pl
BUS1022 - Asset accounting ( fixed asset )

e
13002
H 13001
Asset Fixed asset
component
13003
S Tangible
asset
13004
Financial
asset
13005
Intangible
asset

 SAP AG 1999

 In this example of using a BAPI fixed assets are to be transferred. The business object BUS1022 can
be shown in the BO data model. Here you will also find documentation on the topic “fixed assets"
here. Path: Tools -> ABAP Workbench -> Development -> Business Object Builder; Display
BUS1022 ; then press the BOR data model button; then choose menu path Utilities -> Graphic.

 The business object “asset" is an object, a right or another item owned by the enterprise that is
intended for long-term use, and can be individually identified in the balance sheet. The development
of the values of an asset can be viewed for the asset as a whole, or can be viewed for the asset's
component parts (sub-numbers). Example: Fixed asset "printing press" with asset components
"rollers" and "replacement spindle."

© SAP AG BC420 11-9


0.10
The BAPI "CreateInclValues"

BAPI
FixedAsset.CreateInclValues
Create fixed asset with values ( initial data load)

Tools Business Framework BAPI Browser

Financial accounting Method CreateInclValues

- Asset accounting Of business object FixedAsset

Short description Assets with values..


- FixedAsset
CompanyCode ...
Asset
SubNumber Function module BAPI_FIXEDATASSET...
+ Change
+ ... ALE message type FIXEDASSET_CREATE..
+ CreateInclValues
... ... + ...
...

 SAP AG 1999

 One of the methods of the business object BUS1022 is CreateInclValues and it is used to transfer
assets into R/3.
 The function module, BAPI_FIXEDASSET_OVRTAKE_CREATE, described earlier that converts
the BAPI can be displayed in the BAPI Explorer or the Business Object Builder.
Path: Tools -> Business Framework -> BAPI Explorer; Financial Accounting -> Asset Accounting
-> Fixed Asset; Select FixedAsset.

© SAP AG BC420 11-10


0.11
BAPI Processing in the DX-WB

SAP IDoc
structure

Update
BAPI

Write
log

COMMIT
Start
WORK

 SAP AG 1999

 If a BAPI is to be used to transfer external data, the DX-WB is used.


 The DX-WB needs to have the external data in an IDoc format file. The individual steps within the
DX-WB are:
 Read the external data in packets
 Forward the packet to ALE inbound processing.
In ALE inbound processing the data is passed in records to the BAPI.
The return parameters from the BAPI are collected together and returned to the DX-WB.
 The DX-WB evaluates the status records in the returned.
 A log is written.
 If there is an error, either an error file is created or IDocs are created directly in R/3. (You can set
these options when you create the task in the DX-WB).
 Then the DX-WB transmits a COMMIT WORK to complete the whole process consistently.

© SAP AG BC420 11-11


0.12
Comparison of the LSMW and the DXWB

Convert data

Data transfer in the Data transfer in the


LSMW with a BAPI DX-WB with a BAPI
IDoc-
Format
ALEinbound processing

Call 3 1 call
2
BAPI Create BAPI
Read 1 IDoc
Create 4 IDoc 2 creates

FI FI
asset asset
DB
 SAP AG 1999

 The file in IDoc format could be processed either in the LSMW or in the DX-WB.
 As the graphic shows, in the left-hand case (LSMW) an IDoc is first created in the R/3 database,
read, and then passed to the BAPI.
 In the DX-WB the file in IDoc format is passed directly to the BAPI. No IDoc is created in the
database which speeds up the transfer procedure.

© SAP AG BC420 11-12


0.13
BAPIs

BAPIBasics
BAPI Basics

Test Data
Test Datafor
for the
the Asset
AssetMaster
Master

Transfer of
Transfer of Assets
AssetsUsing
Using BAPIs
BAPIs

 SAP AG 1999

© SAP AG BC420 11-13


0.14
Creating Test Data

 Create data record online


1

2 FI
asset
 Generate test data
Program 3

 Logical system
4
 Create a partner
profile for this 5
logical system

 Display / change test data

 SAP AG 1999

 For some objects, you can create test data for BAPIs using the DX-WB. The file you create contains
the data in IDoc format.
 To do this, create a data record in the SAP System using the online transaction (1).
 Generate a file containing test data. Use the Create file with data function in the DX-WB tools. The
system calls a program in the application, in which you specify the data record you have created (for
example, by company code and document number).
 This program reads the relevant data record from the database (2) and generates an outbound IDoc
on the database (3). The DX-WB triggers the ALE outbound processing. This generates a file in IDoc
formatto be sent to the external system, according to the partner profile (4). The DX-WB copies this
file (5) and changes the sender and receiver, so that this file can be used for ALE inbound processing.
 This file can be used both for testing and as a template that specifies how the data from the external
system are to be prepared.
 Important: A logical system and a partner profile for this logical system must be created in the
System, so that the file can be generated.

© SAP AG BC420 11-14


0.15
Online: Creating a Vehicle

Asset class 3100 Vehicles

Company code 1000 Master data

Quantity 1 Selection

General Time-dependent Allocations Origin Net worth tax Insurance

 Description  Cost center


Chevrolet Corvette 1000
 Capitalized on  License plate number
01.01.1998 (optional)
603-EFD (CT)

 SAP AG 1999

 To display asset master data, choose Accounting -> Financial Accounting -> Assets -> Asset
 This slide describes the creation of an asset (a vehicle) in asset class 3100 (vehicles). The parameters
Description and Cost center are required.
 Description: Description of asset
 Capitalized on: The system fills this field with the asset value date (the first posting that activated the
asset). The activation date is the value data of an asset, and can be manually set when creating an
asset master record. The manually set date does not activate the asset, but is used as a suggested asset
value date for the first acquisition posting (required for data transfer).
 Cost center: The SAP system uses the cost center assignment in the asset master record to determine
the cost center affected by later asset postings.
 Important to note: After you save the asset, the Asset number appears in the status bar. Write this
number down and you can use it later to create an asset test data record from the DX-WB.

© SAP AG BC420 11-15


0.16
Generating Test Data in IDoc Format

Goto Analyse files and data structures

Data Transfer Program


Object type BUS1022

Task type Load data into R/3

Program type BAPI

Program / method CREATEINCLVALUES

Input file
File type P

File name Test_asset.txt

Create file with data Maintain logical system

 SAP AG 1999

 To create test data in the IDoc format in the DX-WB, choose Goto -> Tools -> Files and data
structures. Choose Create file with data. The system then asks for a logical system:
 Definition of "logical system":
The distribution of data between systems requires that every system in a network is uniquely
identified, thus the "logical system". A logical system is an application system in which the
applications all access the same database. In SAP terms, a logical system is a client. In an ALE
environment, clients are assigned to logical systems.

© SAP AG BC420 11-16


0.17
Specifying the Logical System

Enter partner system


You must enter a logical
system
Logical system ?

 Create logical system


 Define a logical system (for example, DXWB) in Customizing
(transaction SALE)
 Create a partner profile for this system
 A partner profile (transaction "WEDI") must be created for the
logical system DXWB just defined.
 The outbound parameters must be defined for this profile. The
message type is important here.

 SAP AG 1999

 Logical systems are defined in Customizing (transaction SALE). The logical system DXWB is used
in this example.
Path: Basis -> Distribution (ALE) -> Sending and Receiving Systems -> Logical Systems -> Define
Logical Systems
 Only one partner profile has to be defined for this logical system.
 A partner profile is defined in transaction WEDI for the logical system.
 The new partner number is defined under the partner type "LS".
 The outbound parameters of the logical system must be set. (Press the "+“ icon, open the template
with the outbound processing parameters). Message types appropriate for the BAPI are entered
here.
 The message type is the most important field here. Message types are assigned to BAPIs in the
transaction BDBG.
 You have to select Collect IDocs under outbound parameter Mode.

© SAP AG BC420 11-17


0.18
Creating Test Data

Display file

Structure Contents
EDI_DD40 Ctrl.Rec. EDI_DC40 40000000146A 24 FIXEDASSET..
EDI_DD40 Ctrl.Rec. E2FIXEDASSET_CREATEINCLVALU000400..
EDI_DD40 Ctrl.Rec. E2BP1022_KEY000 400 000002000001021000
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG001000 400 0000030000010200003100BMW
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG001X000 400 00000400000102 XX XXXXX
EDI_DD40 Data rec. E2BP1022_FEGLG011000 400 000005000001020000000
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG011X000 400 00000600000102XXX
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG0020000 400 000007000001021998050100...
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG002X000 400 00000800000102XX X
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG0030000 400 0000090000010219000101999..
EDI_DD40 Ctrl.Rec. E2BP1022_FEGLG003X000 400 00001000000102 XXXXXXX...
...

The beginning of the The application data starts here.


record contains the
segment information.

Double-click record 4
 SAP AG 1999

 The slide shows a file in IDoc format with a sample asset from asset class 3100 (vehicles).

© SAP AG BC420 11-18


0.19
Detail Display of Test Data

Field Name Short Description Field Contents

SEGNAM Segment

MANDT Client

DOCNUM IDoc number

SEGNUM Segment number

PSGNUM No. of parent segment

HLLEVEL 02

SDATA Application data 00003100Chevrolet Corvette 30000000...

ASSETCLASS 00003100
To display application data
details, click this icon DESCRIPT Chevrolet Corvette

DESCRIPT2
...
 SAP AG 1999

 The application data of the fourth segment contains, for example, the description of the assets. The
segment contents can be examined in detail by selecting the magnifying glass icon.

© SAP AG BC420 11-19


0.20
BAPIs

BAPIBasics
BAPI Basics

Test Data
Test Datafor
for the
the Asset
AssetMaster
Master

Transfer of
Transfer of Assets
AssetsUsing
Using BAPIs
BAPIs

 SAP AG 1999

© SAP AG BC420 11-20


0.21
Mapping Program (LSMW)

Conversion

BAPI

• Structure Relationships

• Field Assignments

• Conversion Rules
• Source Structure Definitions

 SAP AG 1999

© SAP AG BC420 11-21


0.22
Main Steps for Data Transfer with BAPI

Maintain object attributes


Maintain source structures and source fields
Maintain structure relationships
Maintain field mapping and conversion rules
Read data
Convert data
SAP IDoc
Structure Start creating IDocs
Start IDoc processing
Create IDoc overview
BAPI
Start IDoc post-processing

 SAP AG 1999

 The work steps for transferring IDocs are the same as for transferring data using BAPIs.
 The data is converted into the IDoc format in the LSMW. This results in a file that is transferred to a
BAPI using the DX-WB.

© SAP AG BC420 11-22


0.23
Maintain Object Type Attributes - BAPI

Standard Batch / Direct Input

Batch Input Recording

BAPI BAPI Object type / Import technique

Business object method (BAPI)


Business object BUS1022
IDoc
Method CREATEINCLVALUES
Message type FIXED_ASSET_CREATEI...
Basic type FIXED_ASSET_CREATEI...

 SAP AG 1999

© SAP AG BC420 11-23


0.24
Example: Structure of External Data

Source fields

  LEGACY_ASSETS

Company code C(004) Company code


Class C(004) Class
Cost center C(004) Cost center
Business area C(004) Business area
Date DDMY (008) Date
Asset C(020) Asset
Vehicle registration C(010) reg. number

Sequential file with external asset data

1000 210A100990001.01.98BMW ... 653-XAK (CT)


1000 220A100990001.01.98Benz ... 825-AQQ (CT)
...

 SAP AG 1999

 In the example the external asset data should have the following structure:
Example of external data records:
Company code: 1000
Asset class: 210 or 220
Cost center: A100
Business area: 9900
Date: 01.01.98
Vehicle registration: 653-XAK (CT) ...

© SAP AG BC420 11-24


0.25
Mapping Rules for Legacy Asset Data

 IDoc Number (sequential number)


 Asset Class (translation, leading zeroes)
210 -> 00003100
220 -> 00003100

 Cost Center (translation)


A100 -> 1000

 Company Code (move)


 Capitalization Date (move)
 Business Area (move)
 Fill X Segments (constant = ‘X’)
These fields indicate field changes.

00003100 Chevrolet Corvette 30000000... Change which fields?

1 2 3 4 5
X X X X _ ..
 SAP AG 1999

 The IDoc number must be a sequential number.


The code for numbering is provided in the LSMW and must be checked (see next slide).
 You must define translations for the Asset class and Cost center fields.
 For the Company code, Capitalization date, and Business area fields, you just have to set transfers
(MOVE).
 Special fields:
 After every segment with application data comes a segment with change indicators for this
application data. For example, if the third field of an application segment is to be changed, the
corresponding third field of the following X segment must be marked with ‘X’.

© SAP AG BC420 11-25


0.26
Create a Project in the DX-WB

FI

Assets Project FI
Subproject Assets
Transfer using BAPI
Run definition Create
Load data Description Create asset using BAPI

Project FI
Subproject Assets
Run definition Create
Task Load
Description Transfer data
Task type LOA
Program type BAPI

Maintenance of run attributes


 SAP AG 1999

 After you have specified the project, run definition, and tasks in the DX-WB, you must define
special attributes.

© SAP AG BC420 11-26


0.27
Define Processing Attributes

Method CREATEINCLVALUES
Packet size Number of objects that
1
are transferred in one
Errors before term. 1
LUW to the BAPI
Input file
Type P
Name trans02\transpr\legacy_assets.txt
Delete file

Objects that could not be transferred


Write IDoc to file
Type P
Name Trans02\transpr\assets_error.err
Save IDoc in R/3

Create an IDoc in DB if there is an error?

 SAP AG 1999

 The processing attributes for transferring data using BAPIs are:


 Packet size. This specifies the number of objects that are passed to a BAPI in each LUW.
 Errors before terminating the transfer: When executing the task, if the specified number of errors
occur, the task is terminated. If this is not specified or set to zero, the task will not terminate
regardless of how many errors are encountered.
 Input file: Specification of the transfer file with input data.
 Delete file: After the data from this file has been transferred once, this file is deleted.
 Objects that could not be transferred: Select whether objects containing errors are to be saved in a
file or directly in an IDoc.

© SAP AG BC420 11-27


0.28
Transfer Test Data

Start run Process: Transferring using BAPIs

Project FI
Subproject Assets
Display log Run definition Create
Description Create asset using BAPI

Type Message text

Run 00001 started


Task Create started
Successful data transfer for 1 IDocs
Task Create executed without errors
Run 00001 executed without errors

 SAP AG 1999

 A log is created for each run.

© SAP AG BC420 11-28


0.29
Integrate the LSMW Program into the DX-WB

Main LSMW program:

/SAPDMC/SAP_LSMW_INTERFACE
Transfer with BAPI
As of 4.6C
Map data

Load data

ab 4.6A
Pragmatic solution:

 Call main LSMW program


/SAPDMC/SAP_LSMW_INTERFACE with variant
 An ABAP program must call the main program

 SAP AG 1999

 As of Release 4.6C the LSMW can be integrated into the DX-WB by defining a task that calls the
main program /SAPDMC/SAP_LSMW_INTERFACE with a variant.
 In Release 4.6A/B an additional program must be written to call the main LSMW program.

© SAP AG BC420 11-29


0.30
BAPIs: Unit Summary

You are now able to:

 Describe external data transfer using BAPIs


 Transfer asset master data into R/3 using BAPIs

 SAP AG 1999

© SAP AG BC420 11-30


BAPIs Exercises
Unit: BAPIs
Topic: Transfer of Asset Master Data Using BAPIs

 Basics of BAPI technology


 Generate installation test data
 Data transfer of installation data

Transfer the legacy FI installation data in R/3 using a BAPI. The


tools you should use are the LSMW and the DX-WB.

File with assets in legacy format: BC420_ASSET.LEG


Test asset file: BC420_##_TESTASSET

Note: You will find the relevant information for this excercise in the training course slides!

1 Create asset master data online!


Transaction: AS91
Asset class: 3100
Company code: 1000
Description: Racing car
Capitalized on: 01.01.1998
Cost center: 1000
License plate number: LRJ 624
Write down the asset number: ______________

2 Generate asset test data using DX-WB.

BOR object: BUS1022


Program type: BAPI
Method: CREATEINCLVALUES
File type: P
File name: BC420_##_TEST_ASSET

© SAP AG BC420 11-31


 Use the log. system DXWB_## to create test data.
 To generate an IDoc data record, you have to add the following:
Company code: 1000
Asset class: 3100
Asset number: see the number you wrote down
 Go back to the DX-WB Tools
 Display the file you generated.

3 Create the subproject ASSET-## in the DX-WB project FI-## using the
BOR object BUS1022.
3-1 Create the run BAPI_TEST-## with description “Test Asset BAPI”.
3-2 Create the task LOAD-## “Load the data”.

Task type: LOA


Program type: BAPI
Method: CREATEINCLVALUES
Package size: 1
Input file: BC420_##_TEST_ASSET

Do not delete the file after the run! Write all faulty IDocs into the file
ASSET_ERROR_##.
3-3 Analyze the log after you have started the test data run.

4 With the course material you will find a mapping plan for the transfer of legacy asset
data. Transfer the following data from the legacy system:
The file BC420_ASSET.LEG with asset data from the legacy system have the following
structure :

Field name Field type Length Name


CODE C 4 Company code
CLASS C 4 Asset class
COSTCENTER C 4 Cost center
AREA C 4 Business area
DATE C 8 Capitalization date
ASSET C 20 Asset name
PLATENO C 10 License plate number

5 Optional: Generate a test data record without asset data in the editor of the DX-WB. In
accordance with the mapping plan, enter the respective data into the empty record.
Import this record using a run in the DX-WB. Check the result.
© SAP AG BC420 11-32
6 Assign the asset data to the IDoc structure in LSMW.
6-1 Create the subproject ASSET-## with the name "Assets" in the LSMW project
BC420-##.
In this project create the object BAPI-## with the name "Assets with BAPI".
6-2 Maintain the object attributes for BAPI:
Business object: BUS1022
Method: CREATEINCLVALUES
6-3 Create the source structure ASSET_## and maintain the corresponding fields
(see table above).
6-4 Assign the following structures to the source structure:

E1FIXEDASSET_CREATEINCLVALU
E1BP1022_KEY
E1BP1022_REFERENCE
E1BP1022_FEGLG001
E1BP1022_FEGLG001X
E1BP1022_FEGLG011
E1BP1022_FEGLG011X
E1BP1022_FEGLG002
E1BP1022_FEGLG002X
E1BP1022_FEGLG003
E1BP1022_FEGLG003X
6-5 Field Mapping:
6-5-1 Do the mapping according to your mapping plan. Consider the special
features of the asset transfer using BAPIs (see training course material)

7 Maintain file name under "Specify Files":


Source file: BC420_ASSET.LEG.

8 Assign files :
ASSET: ......... BC420_ASSET.LEG

9 Now import the legacy data and check the result!

10 Convert the data and check the result!

11 Create the run in the DX-WB project FI-## under the subproject ASSET-##.
11-1 Create the run BAPI-## with description “Assets with BAPI”.
11-2 Create the task LOAD-## “Loading Data”.

© SAP AG BC420 11-33


Task type: LOA
Program type: BAPI
Method: CREATEINCLVALUES
Package size: 1
Input file: Converted data from LSMW, use the file name from
LSMW

Do not delete the file after the run ! Write all faulty IDocs into the file
ASSET_ERROR_##.
11-3 Analyze the log after you have started the test data run.

© SAP AG BC420 11-34

You might also like