Exp 0011
Exp 0011
BAPIs
Contents:
BAPI Basics
Test Data for the Asset Master
Transfer of Assets Using BAPIs
SAP AG 1999
SAP AG 1999
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
BAPIBasics
BAPI Basics
Test Data
Test Datafor
for the
the Asset
AssetMaster
Master
Transferof
Transfer of Assets
AssetsUsing
Using BAPIs
BAPIs
SAP AG 1999
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.
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 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.
Object-oriented
Implemented as object methods of the BOR
Stable interface
The interface of a BAPI is “frozen”
No presentation layer
Callers have to display the results themselves
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.
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."
BAPI
FixedAsset.CreateInclValues
Create fixed asset with values ( initial data load)
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 IDoc
structure
Update
BAPI
Write
log
COMMIT
Start
WORK
SAP AG 1999
Convert data
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.
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
2 FI
asset
Generate test data
Program 3
Logical system
4
Create a partner
profile for this 5
logical system
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.
Quantity 1 Selection
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.
Input file
File type P
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 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.
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...
...
Double-click record 4
SAP AG 1999
The slide shows a file in IDoc format with a sample asset from asset class 3100 (vehicles).
SEGNAM Segment
MANDT Client
HLLEVEL 02
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.
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
Conversion
BAPI
• Structure Relationships
• Field Assignments
• Conversion Rules
• Source Structure Definitions
SAP AG 1999
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 1999
Source fields
LEGACY_ASSETS
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) ...
1 2 3 4 5
X X X X _ ..
SAP AG 1999
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
After you have specified the project, run definition, and tasks in the DX-WB, you must define
special 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
SAP AG 1999
Project FI
Subproject Assets
Display log Run definition Create
Description Create asset using BAPI
SAP AG 1999
/SAPDMC/SAP_LSMW_INTERFACE
Transfer with BAPI
As of 4.6C
Map data
Load data
ab 4.6A
Pragmatic solution:
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 1999
Note: You will find the relevant information for this excercise in the training course slides!
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”.
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 :
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)
8 Assign files :
ASSET: ......... BC420_ASSET.LEG
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”.
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.