bc420_46c - 011bapis

Upload: mkumarshahi

Post on 02-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 BC420_46C - 011BAPIs

    1/37

    0

    SAP AG 1999

    BAPI Basics

    Test Data for the Asset Master

    Transfer of Assets Using BAPIs

    Contents:

    BAPIs

    SAP AG BC420 11-1

  • 8/11/2019 BC420_46C - 011BAPIs

    2/37

    0.2

    SAP AG 1999

    Describe external data transfer using BAPIs

    Transfer asset aster data into !"# using BAPIs

    At the conclusion of this unit $ou %ill be able to:

    BAPIs: Unit &b'ecti(es

    SAP AG BC420 11-2

  • 8/11/2019 BC420_46C - 011BAPIs

    3/37

    0.#

    SAP AG 1999

    Course &(er(ie% Diagra

    Daten)bernahe

    D* +or,bench

    -M +or,bench

    Princi/les of tandard

    Data Tansfer

    DirectIn/ut

    BAPI

    TA!

    ecorder

    Course &(er(ie%

    Batch

    In/ut

    CallTransaction

    #

    DI

    Basics

    1

    3

    4 506

    50

    6

    55

    53

    52

    55

    52

    5

    2

    5555

    5#

    SAP AG BC420 11-3

  • 8/11/2019 BC420_46C - 011BAPIs

    4/37

    0.3

    SAP AG 1999

    BAPIs

    BAPI BasicsBAPI Basics

    Test Data for the Asset MasterTest Data for the Asset Master

    Transfer of Assets Using BAPIsTransfer of Assets Using BAPIs

    SAP AG BC420 11-4

  • 8/11/2019 BC420_46C - 011BAPIs

    5/37

    0.1

    SAP AG 1999

    &(er(ie% of tandard Transfer Using BAPIs

    Flat SAP

    Structure

    SAP Record

    Layout

    Structure

    SAP IDoc

    Structure

    BAPI

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

    SAP AG BC420 11-5

  • 8/11/2019 BC420_46C - 011BAPIs

    6/37

    0.7

    SAP AG 1999

    Interfaces for tandard Transfer Using BAPIs

    SAP System

    8!8!

    9I9I

    MMMM

    SAP IDocStructure

    BAPI

    BAPI

    BAPI

    External data in the IDoc format is required for calling BAPIs from the DX-B. !a""ing tools#

    such as the $egacy %ystem !igration or&'ench ($%!)# must therefore 'e used to con*ert the

    external data to the IDoc format.

    SAP AG BC420 11-6

  • 8/11/2019 BC420_46C - 011BAPIs

    7/37

    0.

    SAP AG 1999

    Business A//lication Prograing Interface

    Business A//lication Prograing Interface

    A BAPI is a /recisel$defined interfacefor /rocesses

    and data of a business a//lication s$ste and is

    i/leented as a ethod

    of an ob'ectin the Business &b'ect !e/ositor$ ;B&!

  • 8/11/2019 BC420_46C - 011BAPIs

    8/37

    0.4

    SAP AG 1999

    Characteristics of BAPIs

    &b'ectoriented

    I/leented as ob'ect ethods of the B&!

    table interface

    The interface of a BAPI is =fro>en?

    Can be used internall$ and externall$

    BAPIs can be used in !"# and fro external s$stes

    @o /resentation la$er

    Callers ha(e to dis/la$ the results thesel(es

    uccess and error essages in ex/ort /araeter

    !TU!@

    tructure or internal table ;de/ending on BAPI Business (rame)ork -> BAP* +,plorer; (inancial Accountin -> Asset Accountin

    -> (i,ed Asset; !elect (i,edAsset'

    SAP AG BC420 11-10

  • 8/11/2019 BC420_46C - 011BAPIs

    11/37

    0.55

    SAP AG 1999

    BAPI Processing in the D*+B

    SAP IDocstructure

    C&MMIT

    +&!

    U/date

    +rite

    tart

    log

    BAPI

    If a BAPI is to 'e used to transfer external data# the DX-B is used.

    The DX-B needs to ha*e the external data in an IDoc format file. The indi*idual ste"s within the

    DX-B are:

    /ead the external data in "ac&ets

    9orward the "ac&et to A$E in'ound "rocessing.

    In A$E in'ound "rocessing the data is "assed in records to the BAPI.

    The return "arameters from the BAPI are collected together and returned to the DX-B.

    The DX-B e*aluates 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 /23. (;ou can set

    these o"tions when you create the tas& in the DX-B).

    Then the DX-B transmits a !!IT /0 to com"lete the whole "rocess consistently.

    SAP AG BC420 11-11

  • 8/11/2019 BC420_46C - 011BAPIs

    12/37

    0.52

    SAP AG 1999

    Co/arison of the -M+ and the D*+B

    DB

    BAPI BAPI

    A-inbound /rocessing

    IDoc

    9orat

    Data transfer in the

    LS! %ith a BAPIData transfer in the

    D"#!$%ith a BAPI

    Create

    IDoc

    Call

    9I

    asset

    5

    #

    2

    !ead

    IDocCreate 3

    call5

    creates2

    9I

    asset

    Con(ert data

    The file in IDoc format could 'e "rocessed either in the $%! or in the DX-B.

    As the gra"hic shows# in the left-hand case ($%!) an IDoc is first created in the /23 data'ase#

    read# and then "assed to the BAPI.

    In the DX-B the file in IDoc format is "assed directly to the BAPI. 5o IDoc is created in the

    data'ase which s"eeds u" the transfer "rocedure.

    SAP AG BC420 11-12

  • 8/11/2019 BC420_46C - 011BAPIs

    13/37

    0.5#

    SAP AG 1999

    BAPIs

    BAPI BasicsBAPI Basics

    Test Data for the Asset MasterTest Data for the Asset Master

    Transfer of Assets Using BAPIsTransfer of Assets Using BAPIs

    SAP AG BC420 11-13

  • 8/11/2019 BC420_46C - 011BAPIs

    14/37

    0.53

    SAP AG 1999

    Create data record online

    Eenerate test data

    -ogical s$ste

    Dis/la$ " change test data

    Progra

    9I

    asset

    5

    2

    #

    3

    1

    Creating Test Data

    9or some o'+ects# you can create test data for BAPIs using the DX-B.The file you create contains

    the data in IDoc format.

    To do this# create a data record in the %AP %ystem using the online transaction (6).

    =enerate a file containing test data. 4se the .reate /ile )ith datafunction in the DX-B tools. The

    system calls a "rogram in the a""lication# in which you s"ecify the data record you ha*e created (for

    exam"le# 'y com"any code and document num'er).

    This "rogram reads the rele*ant data record from the data'ase (7) and generates an out'ound IDoc

    on the data'ase (3). The DX-B triggers the A$E out'ound "rocessing. This generates a file in IDoc

    format to 'e sent to the external system# according to the "artner "rofile (?). The DX-B co"ies this

    file (C) and changes the sender and recei*er# so that this file can 'e used for A$E in'ound "rocessing. This file can 'e used 'oth for testing and as a tem"late that s"ecifies how the data from the external

    system are to 'e "re"ared.

    Important: %o that the file can 'e generated# the DX-B requires a logical system that is

    automatically created 'y the DX-B in /elease ?.. In /eleases ?.A2B the user has to create this

    logical system and associated "artner "rofile in the %AP %ystem.

    SAP AG BC420 11-14

  • 8/11/2019 BC420_46C - 011BAPIs

    15/37

    0.51

    SAP AG 1999

    &nline: Creating a ehicle

    Asse& .lass #500

    Com#an$ .o%e 5000

    ;uan&i&$ 5

    as&er %a&a

    Eeneral ri*inTime-%e#en%en& Allo.a&ions (e& or&) &a "nsuran.e

    Selection

    Descri/tion

    Chevrolet Corvette

    Ca/itali>ed on

    01.01.1998

    Cost center

    1000

    :i.ense #la&e num'er

  • 8/11/2019 BC420_46C - 011BAPIs

    16/37

    0.57

    SAP AG 1999

    Eenerating Test Data in IDoc 9orat

    Go&o Anal$se iles an% %a&a s&ru.&ures

    'e.& &$#e

    Data Transfer Progra

    BU5022

    Tas! &$#e -oad data into !"#

    Pro*ram &$#e BAPI

    Pro*ram > me&)o% C!ATI@C-A-U

    File &$#eIn/ut file

    P

    File name Testasset.txt

    Crea&e ile i&) %a&a Maintain logical sste!

    To create test data in the IDoc format in the DX-B# choose &oto -> Tools -> (iles and data

    structures. hoose .reate /ile )ith data. The system then as&s for a logical system:

    Definition of ,logical system,:

    The distri'ution of data 'etween systems requires that e*ery system in a networ& is uniquely

    identified# thus the ,logical system,. A logical system is an a""lication system in which the

    a""lications all access the same data'ase. In %AP terms# a logical system is a client. In an A$E

    en*ironment# clients are assigned to logical systems.

    SAP AG BC420 11-16

  • 8/11/2019 BC420_46C - 011BAPIs

    17/37

    0.5

    SAP AG 2001

    Logical system ?

    nter /artner s$ste

    &ou must enter a lo'icalsystem

    Create logical s$ste

    Define a logical s$ste ;for exa/leF D*+B< in Custoi>ing

    ;transaction A-ation Date(!ove)

    Business Area (!ove)

    9ill * egents(constant % &')hese fields indicate field chan'es*

    0000#500 Che(rolet Cor(ette #0000000...

    * * * * ..

    Chan'e which fields/

    1 3 * +

    Ma//ing !ules for -egac$ Asset Data

    The IDoc num'er must 'e a sequential num'er.

    The code for num'ering is "ro*ided in the $%! and must 'e chec&ed (see next slide).

    ;ou must define translations for theAsset classand .ost centerfields.

    9or the .ompany code# .apitali0ation date# andBusiness areafields# you +ust ha*e to set transfers

    (!>E).

    %"ecial fields:

    After e*ery segment with a""lication data comes a segment with change indicators for this

    a""lication data. 9or exam"le# if the third field of an a""lication segment is to 'e changed# the

    corres"onding third field of the following X segment must 'e mar&ed with XJ.

    SAP AG BC420 11-25

  • 8/11/2019 BC420_46C - 011BAPIs

    26/37

    0.27

    SAP AG 1999

    -M+: 9illing * tructures

    if not E1$,10((_-EGLG001ASSETCLASS is initial.

    E1$,10((_-EGLG001/ASSETCLASS /.else.

    E1$,10((_-EGLG001/ASSETCLASS .

    endif.

    Fiel% a##in* %i& +++

    xtras+++ @&ili&ies S$s&em

    +++

    9ill * structures

    Is target field

    filled %ith dataH

    es

    *

    @o

    xa/le

    Chec, s$ntax

    %ome BAPIs ha*e X structures ( X segments). The X field of this structure must 'e filled# if the

    corres"onding a""lication data target field is filled and is to 'e used for data transfer.

    The $%! hel"s you to fill these structures. ith the function(ill 4 structures# the a'o*e ABAP

    code is generated in each field of an X structure.

    If a rule has already 'een defined in an X structure field# ABAP code is not generated for this field.

    The X structures are filled automatically for the field name of the corres"onding X structure. If#

    howe*er# this field is not identical with the name of the corres"onding data structure# the syntax of

    the code generated is not correct.

    ;ou can chec& this 'y using the .heck !ynta,function in the wor& ste"5aintainin (ield 5appin

    and .onversion %ule'The con*ersion "rogram will 'e generated and chec&ed. If there is an error# thecon*ersion "rogram will 'e dis"layed. Then you should carry out the syntax chec& again to dis"lay

    the exact location of the error.

    5ote: ;ou ha*e to correct the error in field ma""ing and not in the generated "rogram.

    SAP AG BC420 11-26

  • 8/11/2019 BC420_46C - 011BAPIs

    27/37

    0.2

    SAP AG 1999

    Creating !uns Using BAPIs

    Assets

    Ma/ data

    9I

    Transfer %ith BAPI

    Project F"

    SubprojectAsse&s

    Run definition Crea&e

    Task :oa%

    Description Transer %a&a

    Task type :A

    Program type BAP"

    aintenance of run attri+utes

    -oad data

    In the DX-B with the "rogram ty"e BAPI# a BAPI can 'e used for the data transfer. %"ecial

    attri'utes need to 'e defined for this (see next slide).

    SAP AG BC420 11-27

  • 8/11/2019 BC420_46C - 011BAPIs

    28/37

    0.24

    SAP AG 1999

    Defining Processing Attributes

    Method CAT"(C:/A:@S

    Packet size 1

    Errors before term. 1

    Input file

    Type

    Name

    Deete fie

    Objects that could not be transferred!rite "Doc to fieType

    BC420-00ASSTSBAP"+errName

    Sa#e "Doc in R$%

    BC420-00ASSTSBAP"+lsm+.on

    P

    P

    ,um+er of o+0ects that

    are transferred in one

    L1! to the $API

    Data records with

    errrors can +e stored

    in a file or as

    individual IDocs

    File with the converted

    data from the LS!

    The "rocessing attri'utes for transferring data using BAPIs are:

    Packet si0e. This s"ecifies the num'er of o'+ects that are "assed to a BAPI in each $4.

    +rrors be/ore terminatin the trans/er6 hen executing the tas if the s"ecified num'er of errors

    occur# the tas& is terminated. If this is not s"ecified or set to ero# the tas& will not terminate

    regardless of how many errors are encountered.

    *nput /ile6%"ecification of the transfer file with in"ut data.

    Delete /ile6After the data from this file has 'een transferred once# this file is deleted.

    Objects that could not be trans/erred: %elect whether o'+ects containing errors are to 'e sa*ed in a

    file or directly in an IDoc.

    SAP AG BC420 11-28

  • 8/11/2019 BC420_46C - 011BAPIs

    29/37

    0.26

    SAP AG 1999

    Transferring Test Data

    un 00001 s&ar&e%

    Tas! Create s&ar&e%

    Su..essul %a&a &ranser or 1 "o.s

    Tas! Createee.u&e% i&)ou& errors

    un 00001 ee.u&e% i&)ou& errors

    T$/e Message text

    is#la$ lo*

    S&ar& run Process: ransferrin' usin' $APIs

    Project F"

    Subproject Asse&s

    Run definition BAP"

    A log is created for each run.

    SAP AG BC420 11-29

  • 8/11/2019 BC420_46C - 011BAPIs

    30/37

    0.#0

    SAP AG 1999

    rror 8andling

    BAPI

    9ile or IDoc

    Collect

    records %ith

    errors in a

    file

    If the run has endedF

    the in/ut file is

    o(er%ritten %ith the

    error file

    52

    3

    #

    Post

    tart run

    DB

    9ehler

    Create IDoc on

    database for records

    %ith errors

    1

    rror file deleted

    rror file

    In/ut file %ith the

    con(erted data

    If BAPIs are used to transfer data# the DX-B "ro*ides two ways of "rocessing errors.

    Error "andling using an error #ile$

    The o"tion Write *Doc to /ilemust 'e selected in the DX-B

    During a run# the source file with the con*erted data is read (6). The BAPI "osts all error-free

    records to the data'ase (7). All records with errors are collected in the error file (3). hen the run

    has com"letely ended (all records ha*e 'een read from the source file# or a run containing errors

    has 'een terminated)# the error file is co"ied to the in"ut file (?). The in"ut file is deleted and then

    the error file is co"ied. After it has 'een successfully co"ied# the error file is deleted (C).

    Tip: There is no "oint in selecting the flagDelete /ile# 'ecause# if you do# the in"ut file containing

    the records with errors will 'e deleted.

    Error "andling b! creating I%ocs:

    The o"tion !ave *Doc in %78must 'e selected in the DX-B

    During a run# the source file with the con*erted data is read (6). The BAPI "osts all error-free

    records to the data'ase (7). IDocs are created from any records containing errors (3). During a

    run the source file is read with the con*erted data (6). hen the run has com"letely ended# the

    source file is read and IDocs must 'e further "rocessed with A$E ser*ices.

    The functionDelete /ilecan 'e selected here 'ecause with com"leted runs all the data records

    from the in"ut file are "rocessed.

    SAP AG BC420 11-30

  • 8/11/2019 BC420_46C - 011BAPIs

    31/37

    0.#5

    SAP AG 2001

    rror 8andling Using an rror 9ile

    rror in Custoi>ing

    5. Change Custoi>ing

    2. !estart run

    5.< Change file in editor

    2.< !estart run

    rror in the data

    rror /rocessing

    9e%

    5. Deterine data records ;e.g. fro /lant 5A$4E%

    C-3 reate the source structureA!!+T9:: and maintain the corres"onding fields (see

    ta'le a'o*e).

    C-? Assign the following structures to the source structure:

    E69IXEDA%%ET8/EATEI5$>A$4

    E6BP67780E;

    E6BP67789E=$=6

    E6BP67789E=$=6XE6BP67789E=$=7

    E6BP67789E=$=7X

    E6BP67789E=$=3

    E6BP67789E=$=3X

    C-C 9ield !a""ing:

    C-C-6 Do the ma""ing according to your ma""ing "lan. onsider the s"ecial

    features of the asset transfer using BAPIs (see training course material)

    C-C-7 To fill the X structures# the $%! ena'les them to 'e filled automatically

    for a com"lete structure. This wor&s automatically for the field name of

    the corres"onding X structure. owe*er# if this is not identical to the

    corres"onding data structure# the syntax of the generated code cannot 'e

    correct.

    ;ou can chec& this 'y using the syntax chec& in the field ma""ing wor&

    ste". The con*ersion "rogram will 'e generated and chec&ed. If there is an

    error# the con*ersion "rogram will 'e dis"layed. ;ou should carry out the

    syntax chec& again to dis"lay the exact location of the error.

    Ti": ;ou ha*e to correct the error in field ma""ing and not in the

    generated "rogram.The field name in the I9 condition (if not Ofield name is initial) must 'e

    changed

    ow many field names were not identicalQ 88888888888

    !aintain file name under ,%"ecify 9iles,:

    %ource file: B?78A%%ET.$E=.

    L Assign files :

    A%%ET: ......... B?78A%%ET.$E=

    H 5ow im"ort the legacy data and chec& the resultKG on*ert the data and chec& the resultK

    SAP AG BC420 11-36

  • 8/11/2019 BC420_46C - 011BAPIs

    37/37

    6 reate the run in the DX-B "ro+ect 9I-MM under the su'"ro+ect A%%ET-MM.

    6-6 reate the run BAPI-MM with descri"tion 1Assets with BAPIN.

    6-7 reate tas& !AP-MM 1on*erting DataN an.

    - Tas&: !AP-MM- 5ame: on*erting Data

    - Tas& ty"e: !AP

    - Program ty"e: $%!

    %elect the following $%! o'+ect:

    $%! "ro+ect: B?7-MM

    $%! su'"ro+ect: A%%ET-MM

    $%! o'+ect: BAPI-MM

    6-3 reate the tas& $AD-MM 1$oading DataN.

    Tas& ty"e: $A

    Program ty"e: BAPI

    !ethod: /EATEI5$>A$4E%

    Pac&age sie: 6

    In"ut file: on*erted data from $%!# use the file name from

    $%!

    Do not deletethe file after the run K rite all faulty IDocs into the file

    A!!+T9+%%O%9::.

    6-? /emem'er that you ha*e to correct the sequence of the tas&s.

    4se the 'uttons 2

    6-C %tart the run.

    6- Analye the log after you ha*e started the test data run.

    6-L !a&e a note of the num'ers of the assets created:

    888888888888 888888888888 888888888888 888888888888

    888888888888 888888888888 888888888888 888888888888