51
8/20/2019 Apostila BAPI http://slidepdf.com/reader/full/apostila-bapi 1/51 BAPI User Guide BAPI User Guide................................................................................................................... 1 Introduction........................................................................................................................... 3  Business Framework........................................................................................................ 4  SAP Business Objects..................................................................................................... 6  Business A!ication Pro"rammin" Inter#ace $BAPI%................................................... ..... &  Ad'anta"es o# Usin" BAPIs...................................................................................... 1(  )*aracteristics o# BAPIs............................................................................................ 11  Standardi+ed BAPIs.................................................................................................. 13  Ser'ice BAPIs #or ,e! Functions............................................................................. 1-  SAP n*ancements to BAPIs................................................................................... 1/  BAPIs o# SAP Inter#ace 0es........................................................................................ 1&  Business Object 2eositor........................................................................................... 1& Pro"rammin" wit* BAPIs.................................................................................................... (  Objectoriented Access to BAPIs....................................................................................  Functionoriented Access to BAPIs................................................................................ -  Pro"rammin" 5ia!o" A!ications................................................. .................................. 6  Pro"rammin" 5istributed A!ications............................................................................  0ransaction 7ode! #or 5e'e!oin" BAPIs....................................................................... /  BAPI 0ransaction 7ode! wit* )ommit....................................................................... /  BAPI 0ransaction 7ode! 8it*out )ommit.................................................... .............. 3(  5eterminin" BAPIs o# Business Objects........................................................................ 3  Seci#in" t*e 9e Fie!ds o# t*e Business Object..................................................... 33  Seci#in" t*e BAPI Parameters............................................................................... 33  5eterminin" t*e :ame o# t*e Function 7odu!e......................................................... 34  5is!ain" BAPI 5ocumentation................................................................................ 34  5eterminin" BAPIs o# Inter#ace 0es............................................................................ 3-  Seci#in" t*e BAPI Parameters............................................................................... 3-  5is!ain" BAPI 5ocumentation................................................................................ 36  ;am!es o# BAPI )a!!s................................................................................................. 3  )a!!in" BAPIs #rom <a'a............................................................................................ 3  )a!!in" BAPIs #rom =isua! Basic................................................................................ 4(  )a!!in" BAPIs #rom ABAP.......................................................................................... 43 7odi#in" BAPIs.................................................................................................................. 4-  User ;its...................................................................................................................... 4-  )ustomer n*ancements.............................................................................................. 4  n*ancements 0*rou"* 7odi#ication........................................................................ 4  )ustomer 5e'e!oments........................................................................................... 4&  :amesaces................................................................................................................. -( 1

Apostila BAPI

Embed Size (px)

Citation preview

Page 1: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 1/51

BAPI User GuideBAPI User Guide................................................................................................................... 1Introduction........................................................................................................................... 3  Business Framework........................................................................................................ 4

  SAP Business Objects..................................................................................................... 6  Business A!ication Pro"rammin" Inter#ace $BAPI%........................................................&  Ad'anta"es o# Usin" BAPIs......................................................................................1(  )*aracteristics o# BAPIs............................................................................................ 11  Standardi+ed BAPIs.................................................................................................. 13  Ser'ice BAPIs #or ,e! Functions.............................................................................1-  SAP n*ancements to BAPIs...................................................................................1/  BAPIs o# SAP Inter#ace 0es........................................................................................1&  Business Object 2eositor...........................................................................................1&Pro"rammin" wit* BAPIs....................................................................................................(  Objectoriented Access to BAPIs....................................................................................  Functionoriented Access to BAPIs................................................................................-  Pro"rammin" 5ia!o" A!ications................................................................................... 6

  Pro"rammin" 5istributed A!ications............................................................................  0ransaction 7ode! #or 5e'e!oin" BAPIs......................................................................./  BAPI 0ransaction 7ode! wit* )ommit......................................................................./  BAPI 0ransaction 7ode! 8it*out )ommit..................................................................3(  5eterminin" BAPIs o# Business Objects........................................................................3  Seci#in" t*e 9e Fie!ds o# t*e Business Object.....................................................33  Seci#in" t*e BAPI Parameters...............................................................................33  5eterminin" t*e :ame o# t*e Function 7odu!e.........................................................34  5is!ain" BAPI 5ocumentation................................................................................34  5eterminin" BAPIs o# Inter#ace 0es............................................................................3-  Seci#in" t*e BAPI Parameters...............................................................................3-  5is!ain" BAPI 5ocumentation................................................................................36  ;am!es o# BAPI )a!!s................................................................................................. 3

  )a!!in" BAPIs #rom <a'a............................................................................................ 3  )a!!in" BAPIs #rom =isua! Basic................................................................................ 4(  )a!!in" BAPIs #rom ABAP..........................................................................................437odi#in" BAPIs..................................................................................................................4-  User ;its......................................................................................................................4-  )ustomer n*ancements..............................................................................................4  n*ancements 0*rou"* 7odi#ication........................................................................ 4  )ustomer 5e'e!oments........................................................................................... 4&  :amesaces.................................................................................................................-(

1

Page 2: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 2/51

BAPI User Guide

Use0*e Business Framework t*e oen comonentbased arc*itecture enab!in" so#tware

comonents #rom SAP and ot*er ro'iders to be inte"rated is "ainin" more and moremomentum.

SAP Business Objects are at t*e *eart o# t*e Business Framework and are t*erere>uisite #or t*e interoerabi!it o# so#tware comonents. 0*e co'er a wide sectrumo# 2?3 business data and rocesses.

SAP Business Objects are accessed t*rou"* BAPIs $Business A!ication Pro"rammin"Inter#aces%@ w*ic* are stab!e@ standardi+ed met*ods. SAP Business Objects and t*eirBAPIs ro'ide an objectoriented 'iew o# 2?3 business #unctiona!it.

In 2e!ease 3.1 SAP ro'ided t*e #irst BAPIs #or customers and e;terna! ro'iders@enab!in" t*em to inte"rate t*eir so#tware comonents into t*e 2?3 Sstem and t*e

Business Framework. In 2e!ease 4.-A t*ere are about 1((( BAPIs enab!in" objectoriented access to t*e 2?3 Sstem.

0*is User Guide is an introduction to t*e tec*nica! concets o# BAPIs. It a!so ro'ides ano'er'iew o# *ow ou can use BAPIs to ac*ie'e a seam!ess inte"ration between t*e 2?3Sstem and e;terna! a!ications@ !e"ac sstems and addons.

Prerequisites0*e Use Guide is tar"eted at a!ication de'e!oers wantin" to create new inte"ratedacti'ities usin" SAP Business Objects and t*eir BAPIs.

• Inte"ration o# e;terna! a!ications wit* an 2?3 Sstem

• Inte"ration o# e;istin" business a!ications wit* an 2?3 Sstem

•  A!ternati'e #rontend inter#aces to 2?3 Sstems@ #or e;am!e@ so t*at occasiona!

users can access 2?3.

0*ese #rontends can be im!emented as 8indowsbased c!ient a!ications@ #ore;am!e@ as macros #or deskto a!ications $7icroso#t ;ce! or Access%@ w*ic*are usua!! written in =isua! Basic #or A!ications or im!emented as a!icationsin =isua! Basic@ <a'a or ).

• 8ebbased access to an 2?3 Sstem t*rou"* Internet or Intranet a!ications.

• )omonenti+ation wit*in t*e 2?3 Sstem in t*e conte;t o# Business Framework

Required Knowledge

0o use BAPIs to access SAP Business Objects ou must be #ami!iar wit* t*e basicconcets o# objectoriented tec*no!o" and ro"rammin". A!t*ou"* ou do not need to*a'e a detai!ed know!ed"e o# t*e 2?3 Sstem to work wit* BAPIs@ ou s*ou!d *a'e a basicunderstandin".

BAPIs can be accessed #rom 'arious ro"rammin" en'ironments@ #or e;am!e@5e!*i?)onnect #rom Inrise $#ormer! Bor!and%@ 7icroso#ts =isua! Studio@ ) and <a'a!at#orms. Cou must be #ami!iar wit* t*e de'e!oment en'ironment used to access BAPIs.BAPIs are a'ai!ab!e outside o# 2?3 #rom de'e!oment !at#orms t*at suort t*e 2emoteFunction )a!! $2F)% rotoco!. I# ou are de'e!oin" our a!ication in a nonobjectoriented ro"rammin" !an"ua"e@ ou need to *a'e 2F) ro"rammin" ski!!s to ca!! BAPIs'ia 2F). In articu!ar ou need to know *ow to er#orm 2F) ca!!s.

 

Page 3: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 3/51

Introduction

UseSAP *as introduced objectoriented tec*no!o" in t*e 2?3 Sstem b makin" 2?3rocesses and data a'ai!ab!e in t*e #orm o# SAP Business Objects.

;terna! a!ications can access SAP Business Objects t*rou"* standardi+ed@!at#ormindeendent inter#aces BAPIs. SAP Business Objects and t*eir BAPIsro'ide an objectoriented 'iew o# 2?3 business #unctiona!it.

0*is "uide ro'ides an o'er'iew o# t*e Business Framework@ SAP Business Objectsand SAP Inter#ace 0es and t*eir BAPIs as we!! as t*e Business Object 2eositor in

w*ic* business objects and BAPIs are de#ined and stored.

3

Page 4: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 4/51

Business Framework

Use0*e SAP 2?3 Business Framework ro'ides a structure #or 2?3 #unctiona!it based ona!ication comonents $business comonents% and object mode!s. 0*e Business

Framework enab!es customers and artners to !ink t*eir own comonents to t*e 2?3Sstem.

0*e use o# objectoriented tec*no!o" and object mode!s reduces t*e com!e;it o# t*e

o'era!! sstem.

FeaturesBusiness Framework arc*itecture ro'ides t*e basis #or de'e!oin" SAP Business)omonents.  0*e basic comonents o# SAP 2?3 Business Framework areD

 

Business )omonents 

SAP Business )omonents ro'ide autonomous business #unctions and consisto# business objects. For e;am!e@ t*e business objects Employee and Applicant  are assi"ned to t*e Business )omonent Human Resources. Business rocessesare eit*er im!emented wit*in a Business )omonent or across se'era!)omonents $distributed business rocesses%.

 

Business Objects

0*e objectoriented structure o# t*e 2?3 Sstem is based on Business Objects.0*e encasu!ate business data and #unctiona!it and de#ine t*e #unctiona! scoeand boundaries o# a Business )omonent.

Business A!ication Pro"rammin" Inter#aces $BAPI%

BAPIs are inter#aces #or Business Objects.  0o"et*er wit* t*e Business Objects@BAPIs de#ine and document t*e inter#ace standard at t*e business !e'e!.

 

Inte"ration Ser'ice@ A!ication Eink nab!in" $AE% 

0*e AE Inte"ration Ser'ice enab!es t*e inte"ration o# business rocesses t*atare carried out in di##erent 2?3 and nonSAP sstems.  It is based on t*e sstemwide distribution o# Business Objects usin" t*e AE distribution mode!.

4

Page 5: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 5/51

0*e "ra*ic be!ow i!!ustrates t*is arc*itecture.

  Application Component

Application Link Enaling

!ALE"

Business

#$ect

BAPI

Integration ser%ices&or usinessprocesses anddistriution o& usiness o$ects

'istriuted usinessprocesses

(AP R)*

BAPI

BAPI

 

)ommunication ser'ices

0*ese are t*e communication tec*no!o"ies@ #or e;am!e@ 5istributed )omonent

Object 7ode! $5)O7% and 2emote Function )a!! $2F)%@ w*ic* use t*e BusinessFramework to access BAPIs.

0*e "ra*ic be!ow i!!ustrates t*is arc*itecture.

Application Component

!'"C#+ C#RBA

Business#$ect

BAPI

Communication ser%ices

'istriuted usiness ,processes

(AP R)*

BAPI

BAPI

(AP RemoteFunction Call

!RFC"

-

Page 6: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 6/51

(AP Business #$ects

'e&initionBusiness object tec*no!o" and business object ro"rammin" are based on t*e concet o# business objects. 2ea! wor!d objects@ #or e;am!e an em!oee or a sa!es order@ are

mode!ed as business objects in business a!ication sstems@ suc* as t*e 2?3 Sstem.

SAP Business Objects encapsulate 2?3 data and business rocesses@ t*us *idin" t*edetai!s o# t*e structure and im!ementation o# t*e under!in" data.

(tructure0o ac*ie'e t*is encasu!ation@ t*e SAP Business Objects are constructed as entities #romse'era! !aersD

•  At t*e core o# an SAP Business Object is t*e kerne!@ w*ic* reresents t*e objects

in*erent data.

• 0*e second !aer@ t*e inte"rit !aer reresents t*e business !o"ic o# t*e object. It

comrises t*e business ru!es #or consistent embeddin" in t*e en'ironment and t*e

constraints re"ardin" t*e 'a!ues and domains t*at a! to t*e business object.

• 0*e t*ird !aer@ t*e inter#ace !aer@ describes t*e im!ementation and structure o# t*e

SAP Business Object@ and de#ines t*e objects inter#ace to t*e outside wor!d.

• 0*e #ourt* and outermost !aer o# a business object is t*e access !aer@ w*ic* de#ines

t*e tec*no!o"ies t*at can be used #or e;terna! access to t*e objects data@ #ore;am!e@ )O7?5)O7 $)omonent Object 7ode!?5istributed )omonent Object7ode!%.

Busi,

ness

Rules

H C#+ ) 'C#+

H RFC

H -A.A

H C#RBA

+et/od!BAPI"

+et/od

!BAPI"Con,

straints

Legend0

)O7?5)O7 )omonent Object 7ode! ?

  5istr ibuted )omonent Object 7ode!

2F) 2emote Function )a!!

)O2BA )ommon Object 2e>uest Broker 

  Arc*itecture

Integration

Accessing Business #$ects

6

Page 7: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 7/51

 As t*e abo'e "ra*ic s*ows@ t*e inter#ace !aer searates a business objects data andt*e a!ications and tec*no!o"ies t*at can be used to access it. 0o t*e outside@ t*e SAPBusiness Objects re'ea! on! t*eir inter#ace@ w*ic* consists o# a set o# c!ear! de#inedmet/ods. A!ications can on! access t*e business object data b t*e objects met*ods.

 An a!ication ro"ram t*at accesses an SAP Business Object and its data on! needs t*e

in#ormation re>uired to e;ecute t*e met*ods. 0*ere#ore@ an a!ication ro"rammer canwork wit* t*e SAP Business Objects and in'oke t*eir met*ods wit*out *a'in" to know orconsider t*e objects under!in" im!ementation detai!s.

0*e set o# met*ods t*at is associated wit* a business object reresents t*e objectse/a%ior . 8*en a met*od is e;ecuted on a business object@ t*e met*od can c*an"e t*eobjects interna! state@ t*at is@ t*e objects data.

For e;am!e@ one met*od t*at ou can use on t*e business object Employee is to c*eck#or t*e em!oees e;istence.

In t*e 2?3 Sstem a!! SAP Business Object tes and t*eir met*ods are de#ined anddescribed in t*e Business Object 2eositor $BO2%.

#$ect 12pes and #$ect Instances

ac* indi'idua! business object be!on"s to a seci#ic object c!ass@ deendin" on t*enature and "enera! c*aracteristics o# t*e object. 0*ese object c!asses are ca!!ed o$ectt2pes. For e;am!e@ t*e indi'idua! em!oees workin" in an or"ani+ation are a!! art o# t*eEmployee object te.

0*e object tes are descritions o# t*e actua! SAP Business Objects t*at can e;ist in 2?3Jt*at is@ eac* indi'idua! SAP Business Object is a reresentation@ or instance@ o# its objectte. For e;am!e@ t*e em!oee wit* t*e name )*ar!es <ones and t*e em!oee number134 is an instance o# t*e Employee object te.

8*en writin" objectoriented a!ication ro"rams@ a!ication de'e!oers identi# t*e

object tes t*at are to be used and oerated on b t*eir ro"rams. At runtime@ t*ea!ication ro"ram accesses t*e seci#ic instances o# t*e de#ined object tes.

8*en an instance o# a business object is used b an a!ication ro"ram@ t*e objectinstance resonds on! to t*e set o# c*aracteristics and met*ods de#ined #or its own objectte. 0*e SAP Business Object tes are de#ined b t*e #o!!owin"D

  #$ect t2pe

0*e object te describes t*e #eatures common to a!! instances o# t*at object te.0*is inc!udes in#ormation suc* as t*e uni>ue name o# t*e object te@ itsc!assi#ication@ and t*e data mode!.

Ke2 &ields

0*e ke #ie!ds determine t*e structure o# an identi#in" ke@ w*ic* a!!ows ana!ication to access a seci#ic instance o# t*e object te. 0*e object teEmployee and t*e ke #ie!d Employee.Number  are e;am!es o# an object te anda corresondin" ke #ie!d.

  +et/ods

 A met*od is an oeration t*at can be er#ormed on a business object and t*atro'ides access to t*e object data. A met*od is de#ined b a name and a set o#arameters and e;cetions@ w*ic* can or must be ro'ided b t*e ca!!in" ro"ramin order to use t*e met*od. BAPIs are e;am!es o# suc* met*ods.

  Attriutes

 An attribute contains data about a business object@ t*us describin" a articu!ar

object roert. For e;am!e@ Employee.Name is an attribute o# t*e Employee object te.

Page 8: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 8/51

  E%ents

 An e'ent indicates t*e occurrence o# a status c*an"e o# a business object.

In/eritance and Pol2morp/ism

One objecti'e and t*e main bene#it o# objectoriented tec*no!o" is so#tware reusabi!it.0*e reuse o# so#tware code is ac*ie'ed b deri'in" new object tes #rom e;istin" ones.

8*en an object te is "enerated #rom an e;istin" object te@ t*e new object te isca!!ed t*e subte and t*e e;istin" object te is ca!!ed t*e suerte. For e;am!e@ t*eobject te Employee is a subte w*ic* *as been deri'ed #rom t*e suerte Person.:ote t*at subte and suerte are sometimes re#erred to as subc!ass andsuerc!ass.

 A subte in/erits a!! t*e roerties and met*ods de#ined #or t*e suerte #rom w*ic* itdescends@ but can a!so *a'e additiona! roerties and met*ods. A subte ma a!soim!ement a di##erent be*a'ior #or t*e met*ods in*erited #rom t*e suerte.Pol2morp/ism is t*e term used to describe w*en t*e same met*od tri""ers di##erenttes o# be*a'ior in di##erent business object tes.

For #urt*er in#ormation on creatin" business objects re#er to t*e documentation on SAPBusiness 8ork#!ow.

/

Page 9: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 9/51

Business Application Programming Inter&ace !BAPI"

Use0*e SAP Business Objects *e!d in t*e Business Object 2eositor $BO2% encasu!atet*eir data and rocesses. ;terna! access to t*e data and rocesses is on! ossib!e b

means o# seci#ic met*ods BAPIs $Business A!ication Pro"ram Inter#aces%.

 A BAPI is de#ined as a met*od o# an SAP Business Object. 

For e;am!e@ t*e #unctiona!it t*at is im!emented wit* t*e SAP BusinessObject te Material  inc!udes a c*eck #or t*e materia!s a'ai!abi!it. 0*us@ t*ebusiness object te Material  o##ers a BAPI ca!!ed Material.CheckAvailability .

0*e BAPIs in t*e 2?3 Sstem are current! im!emented as #unction modu!es a!! o# w*ic*are created and mana"ed in t*e Function Bui!der. ac* #unction modu!e under!in" a

BAPID• Suorts t*e 2emote Function )a!! $2F)% rotoco!

• ,as been assi"ned as a met*od to an SAP Business Object in t*e Business

Object 2eositor

• Is rocessed wit*out returnin" an screen dia!o"s to t*e ca!!in" a!ication

Integration0*e "ra*ic be!ow s*ows t*e re!ations*i between an SAP Business Object te@ itsassociated BAPIs and its #unction modu!es.

Business #$ect wit/ BAPIs and Associated Function +odules

0*is arc*itecture enab!es SAP to c*an"e t*e detai!s o# a BAPIs im!ementation wit*outa##ectin" e;terna! a!ications t*at are usin" t*e BAPI. For in#ormation on SAP o!ic #oren*ancin" BAPIs and t*e re!ease o!ic #or BAPIs see SAP n*ancements to BAPIs.

Prerequisites0o use a BAPI met*od to access data in SAP Business Objects@ an a!ication ro"ramon! needs to know *ow to ca!! t*e met*od. In#ormation re>uired isD

&

Page 10: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 10/51

  0*e name o# t*e BAPI

  5etai!s o# t*e BAPI inter#aceD

− Imort arameters@ w*ic* contain data to be trans#erred #rom t*e ca!!in"

ro"ram to t*e BAPI

− ;ort arameters@ w*ic* contain data to be trans#erred #rom t*e BAPI back tot*e ca!!in" ro"ram

− Imort?e;ort $tab!e% arameters #or bot* imortin" and e;ortin" data

 A!ication ro"rammers can work wit* SAP Business Objects and im!ement t*eir BAPIswit*out needin" to know t*e under!in" im!ementation and codin" detai!s.

Ad%antages o& Using BAPIsUse

BAPIs are standardi+ed met*ods o# SAP Business Objects t*at enab!e customers andt*ird arties to inte"rate t*eir so#tware comonents wit* t*e 2?3 Sstem and t*e BusinessFramework. 0*is section !ists some o# t*e ad'anta"es o# usin" BAPIs as a means o#accessin" t*e SAP Business Objects.

Business (tandard

SAP Business Objects and t*eir BAPIs are t*e standard #or t*e business #unctions in t*e2?3 Sstem. 0*e enab!e t*e 2?3 Sstem and ot*er so#tware roducts to be inte"rated onone business !e'e!.

(tandards Con&ormance

BAPIs are bein" de'e!oed as art o# t*e SAP joint initiati'e wit* customers@ artners@ and!eadin" standards or"ani+ations. BAPIs are becomin" a communication standard betweenbusiness sstems.

Cou can access SAP Business Objects and t*eir BAPIs b usin" objectorientedinter#acin" tec*no!o"ies suc* as 7icroso#ts )O7?5)O7 $)omonent Object7ode!?5istributed )omonent Object 7ode!%.

0*e SAP Business Objects a!read com! wit* t*e Object A!ication Grou $OAG%seci#ications@ and@ in conjunction wit* ObjectBrid"e #rom =isua!d"e@ con#orm to t*eObject 7ana"ement Grous )O2BA $)ommon Object 2e>uest Broker Arc*itecture%"uide!ines.

(tailit2 and 'ownwards Compatiilit2

Once SAP *as de'e!oed and re!eased a BAPI@ its inter#ace de#inition and arametersremain stab!e #or t*e !on" term. 0*is ensures t*at a!ication ro"rams are not a##ected bc*an"es to t*e under!in" 2?3 so#tware and data.

SAP can make an necessar e;tensions to t*e BAPIs@ #or e;am!e@ add otiona!arameters@ wit*out destabi!i+in" t*e oeration o# e;istin" a!ications and@ at t*e sametime@ can o##er t*e en*anced #unctiona!it to new a!ications.

1(

Page 11: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 11/51

For in#ormation on SAP BAPI o!ic see SAP n*ancements to BAPIs.

#$ect #rientation

 As met*ods o# t*e SAP Business Objects@ BAPIs ro'ide access to 2?3 data androcesses #o!!owin" an objectoriented ro"rammin" mode!. BAPIs can be ca!!ed usin"objectoriented inter#acin" tec*no!o"ies@ suc* as )O7?5)O7@ t*us enab!in" so#twarecomonents #rom SAP and t*ird arties to interact #ree!.

#penness

Cou can access BAPIs #rom a!! de'e!oment !at#orms t*at suort t*e SAP 2emoteFunction )a!! $2F)% rotoco!.

C/aracteristics o& BAPIs

Use0*is section describes t*e BAPI c*aracteristics ou s*ou!d know about be#ore ou be"ininte"ratin" BAPI ca!!s into our a!ication ro"rams.

3aming Con%entions

BAPIs are identi#ied b t*e name o# t*e business object in >uestion #o!!owed b t*e nameo# t*e BAPI. $BAPI names are in n"!is* and describe w*at t*e BAPI does to t*e businessobject%. A eriod searates t*e two arts o# t*e name.

For e;am!e@ t*e #u!! name o# t*e BAPI CheckAvailability  o# t*e businessobject Material  is Material.CheckAvailability.

0*ere are some standardi+ed BAPIs t*at can be im!emented #or most o# t*e businessobjects. 0*ese BAPIs *a'e seci#ic #unctions@ suc* as !istin" e;istin" instances o#business objects.

0*ese BAPIs are im!emented accordin" to seci#ied ru!es and are assi"ned t*e same

name #or a!! business objects. 0*e BAPI GetList, w*ic* !ists e;istin" object instances canbe used #or man business objects@ #or e;am!e@ CompanyCoe.GetList  andMaterial.GetList .

For in#ormation about t*ese BAPIs see Standardi+ed BAPIs.

'ataase Consistenc2

ac* BAPI t*at creates an instance o# an object or udates t*e data o# an object isresonsib!e #or database consistenc. A!! database c*an"es are carried out com!ete! ornot at a!!.

,owe'er@ t*e )O77I0 8O29 command must not be e;ecuted b t*e BAPI itse!#J it must

be e;ecuted b t*e ca!!in" ro"ram. For #urt*er in#ormation see t*e 0ransaction 7ode! #or5e'e!oin" BAPIs.

11

Page 12: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 12/51

3o 'ialog #rientation

BAPIs do not return dia!o" screens #rom t*e 2?3 ser'er sstem to t*e ca!!in" ro"ram.

Aut/ori4ation An interaction wit* t*e 2?3 Sstem re>uires t*e user to *a'e a certain set o#aut*ori+ations. 0o e;ecute a BAPI as art o# our a!ication ro"ram@ t*e users o# oura!ication must *a'e t*e aroriate aut*ori+ations set u in t*eir 2?3 master records.0*e documentation ro'ided wit* t*e BAPI contains in#ormation about t*e re>uiredaut*ori+ations.

 An attemts to e;ecute a BAPI t*at #ai! as a resu!t o# insu##icient aut*ori+ation arereorted back to t*e ca!!in" a!ication.

'ata 12pes and 'ata 'ispla2

BAPIs are ro"rammin" inter#aces #or business a!ications. :eutra! $interna!% data tes

and data #ormats are t*ere#ore used a!most e;c!usi'e! in BAPI inter#aces. 0*ere aresome e;cetions@ #or e;am!eD

)urrenc codes

  Interna! kes

  Kuantities

For in#ormation about t*ese e;cetions see Interna! and ;terna! 5ata Formats in t*eBAPI Pro"rammin" "uide!ines.

)on'ersion BAPIs are ro'ided #or t*e aroriate con'ersions between interna! ande;terna! #ormats. For in#ormation see Ser'ice BAPIs #or Genera! BAPI Functions.

BAPI arameters can use most o# t*e suorted SAP data tes. 0*e data tes aredocumented in t*e indi'idua! arameters structure entr in t*e ABAP 5ictionar.

Processing +odes

8*en BAPIs are ca!!ed direct!@ #or e;am!e@ usin" BAPI Acti'eL )ontro!@ t*e 2?3 5)O7)omonent )onnector or b direct! ca!!in" t*e under!in" #unction modu!e@ BAPIs arerocessed in snc*ronous mode.

For in#ormation about ca!!in" BAPIs in a distributed en'ironment $AE% see Pro"rammin"5istributed n'ironments.

Business #$ect Attriutes0*e attributes o# business objects are accessed t*rou"* t*e BAPI inter#ace itse!#@ #ore;am!e@ t*e BAPI Get!etail  o# t*e business object CompanyCoe.

1

Page 13: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 13/51

(tandardi4ed BAPIs

UseSome BAPIs and met*ods ro'ide basic #unctions and can be used #or most SAPBusiness Objects. Suc* BAPIs are known as Mstandardi+edN BAPIs.

Features8it* object met*ods and esecia!! wit* BAPIs@ ou can di##erentiate between instancemet/ods and class met/ods. Instance met*ods re#er to recise! one instance $oneseci#ic occurrence% o# an SAP Business Object te@ #or e;am!e@ to one e;!icit!seci#ied customer order. 8*ereas c!ass met*ods are instanceindeendent. 0*is sectionro'ides an o'er'iew o# t*e standardi+ed BAPIs and *ow t*e are assi"ned to met*odtes.

BAPIs &or Reading 'ata

0*e #o!!owin" BAPIs ro'ide ou wit* readon! access to data in t*e associated businessobjectD

GetList 

8it* t*e BAPI GetList  ou can se!ect a ran"e o# object ke 'a!ues@ #or e;am!e@ comancodes and materia! numbers.

+et/od t2peD )!ass met*ods

For more in#ormation see Pro"rammin" GetEist BAPIs.

GetDetail 

0*e BAPI Get!etail  uses a ke to retrie'e detai!s about an instance $one seci#icoccurrence% o# a business object and returns t*is data to t*e ca!!in" ro"ram. 0*en t*is

in#ormation is reorted back to t*e ca!!in" ro"ram.

+et/od t2peD Instance met*od

For more in#ormation see Pro"rammin" Get5etai! BAPIs.

GetStatus

0*e BAPI Get"tatus is used to >uer t*e status o# an SAP Business Object@ #or e;am!e@t*e rocessin" status o# a sa!es order. 0*is BAPI is used on! #or dis!ain" t*e status o#an object and does not retrie'e #u!! detai!s !ike t*e BAPI Get!etail .

+et/od t2peD Instance met*od

For more in#ormation see Pro"rammin" GetStatus BAPIs.

ExistenceCheck 

0*e BAPI E#istenceCheck  c*ecks w*et*er an entr e;ists #or an SAP Business Object@ #or e;am!e@ w*et*er t*e customer master *as been created.

+et/od t2peD Instance met*od

For more in#ormation see Pro"rammin" ;istence)*eck BAPIs.

13

Page 14: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 14/51

BAPIs &or Creating or C/anging 'ata

0*e #o!!owin" BAPIs can create@ c*an"e or de!ete instances o# a business objectD

Create or CreateFromData 

0*e BAPI Create or Create$rom!ata creates an instance o# an SAP Business Object@ #ore;am!e@ a urc*ase order.

+et/od t2peD )!ass met*ods

For more in#ormation see Pro"rammin" )reate BAPIs. 

Change

0*e BAPI Chan%e c*an"es an e;istin" instance o# a SAP Business Object@ #or e;am!e@ aurc*ase order.

+et/od t2peD Instance met*od

For more in#ormation see Pro"rammin" )*an"e BAPIs. 

Delete and Undelete

0*e BAPI !elete de!etes an instance o# an SAP Business Object #rom t*e database@ #ore;am!e@ a urc*ase order.

0*e BAPI &nelete remo'es a de!etion #!a".

+et/od t2peD Instance met*od

For more in#ormation see Pro"rammin" 5e!ete BAPIs.

 Add<sub-object and !emo"e<sub-object

0*e BAPI A'sub(ob)ect* adds a subobject to an e;istin" object instance and t*e BAPIand Remove'sub(ob)ect* remo'es a subobject #rom an object instance.

+et/od t2peD Instance met*od

For #urt*er in#ormation see Pro"rammin" 7et*ods #or SubObjects. 

BAPIs &or +ass Processing

0*e BAPIs !isted in t*e abo'e section@ MBAPIs #or )reatin" or )*an"in" 5ataN@ can a!so beused #or mass rocessin". ,ere@ w*en a BAPI is ca!!ed@ se'era! business object instances

are rocessed at t*e same time.

8it* BAPIs #or mass rocessin"@ t*e su##i; M7u!ti!eN is added to t*e met*od name@ #ore;am!e@ Chan%eMultiple, CreateMultiple, !eleteMultiple.

+et/od t2pe0 )!ass met*ods

BAPIs &or Replicating Business #$ect Instances

0*e #o!!owin" BAPIs are used #or re!icatin" business object instancesD

!e#licate and Sa"e!e#lica

0*e BAPIs Replicate and "aveReplica are im!emented as met*ods o# re!icab!ebusiness objects. 0*e enab!e seci#ic instances o# an object te to be coied to one or

14

Page 15: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 15/51

more di##erent sstems. 0*ese BAPIs are used main! to trans#er data between distributedsstems wit*in t*e conte;t o# A!ication Eink nab!in" $AE%.+et/od t2peD )!ass met*ods

For more in#ormation see Pro"rammin" 2e!icate?Sa'e2e!icaBAPIs.

(er%ice BAPIs &or 5elp Functions

Use A number o# ser'ice BAPIs ro'ide basic *e! #unctions. Ser'ice BAPIs ro'idein#ormation or ser'ices #or t*e BAPIs #rom indi'idua! Business )omonents.Ser'ice BAPIs are created in t*e BO2 under t*e a!ication comonent *ierarc* s*ownbe!owD

Cross,Application Components  Business Framework Arc/itecture

BAPI 1ec/nolog2

Features

BAPIs &or Accessing Inter&ace 'ocumentation

Usin" t*e BAPIs be!ow@ ou can dis!a t*e documentation and descritions o# BAPIinter#acesD

  Help+alues.GetList 

0*is met*od determines t*e a!!owed inut 'a!ues $F4 *e!% #or a #ie!d in a BAPIarameter. 0*e met*od dis!as 'a!id inut 'a!ues #or a seci#ic BAPI arameter#ie!d@ enab!in" endusers to enter a correct 'a!ue in t*e inut #ie!d.

  api"ervice.$ielHelpGet!ocu

0*is met*od reads t*e documentation $F1 *e!% #or t*e #ie!ds in a BAPI arameter.0*e ro'ide endusers wit* t*e descritions o# t*e #ie!ds in a BAPI arameter.

api"ervice.-nteraceGet!ocu

0*is met*od reads t*e entire inter#ace documentation o# a BAPI. 8it* t*is met*odou can access documentation on t*e business object@ met*od@ arameters andarameter #ie!ds.

BAPIs &or Interpreting Error +essages

0*e BAPIs be!ow *e! ou to interret BAPI error messa"esD

  api"ervice.Messa%eGet!etail 

0*is met*od dis!as t*e s*ort and !on" te;ts o# BAPI error messa"es.

api"ervice.ApplicationLo%Get!etail 

0*is met*od reads t*e detai!s o# entries in t*e a!ication !o".

BAPIs &or Controlling C#++I1 and R#LLBACK

0*e transaction mode! $see 0ransaction 7ode! #or 5e'e!oin" BAPIs% stiu!ates t*at e'erBAPI w*ic* creates object instances or c*an"es object data is resonsib!e #or databaseconsistenc.

1-

Page 16: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 16/51

0*e commands used to commit c*an"es to t*e database or to reset c*an"es $)O77I0and 2OEEBA)9%@ must not be e;ecuted b t*e BAPI itse!#@ t*e *a'e to be ca!!ed direct!#rom t*e e;terna! a!ication ro"ram.

;terna! ro"rams can use t*e #o!!owin" ser'ice BAPIs #or t*ese ca!!sD

api"ervice./ransactionCommit 

0*is met*od e;ecutes a )O77I0 8O29 command. 8*en ou ca!! BAPIs in ourro"ram t*at c*an"e data in t*e 2?3 Sstem@ ou must t*en ca!! t*is met*od toass t*e c*an"es to t*e database.

  api"ervice./ransactionRollback 

0*is met*od e;ecutes a 2OEEBA)9 8O29 command. 8*en ou ca!! BAPIs inour ro"ram t*at c*an"e data in t*e 2?3 Sstem@ a#terwards ou must ca!! t*ismet*od to ass t*e c*an"es to t*e database. 0*is works ro'ided t*at t*e BAPIapi"ervice./ransactionCommit  *as not a!read assed t*e c*an"es to t*edatabase.

BAPIs &or Con%erting Between Internal and E6ternal 'ata Formats

!'omain Con%ersion"BAPIs are ro"rammin" inter#aces@ not enduser inter#aces. For t*is reason a neutra! data#ormat $wit* some e;cetions% must be used in BAPIs. Fie!ds in BAPI arameters aredis!aed in t*e BAPI inter#ace in t*e interna! #ormat used in t*e database@ not in a#ormatted #orm.

8*en ou ca!! a BAPI in our ro"ram@ ou need to use t*e e;terna! data #ormat@ todis!a data on t*e screen@ #or e;am!e. Cou can use t*e #o!!owin" con'ersion BAPIs todis!a t*e data in t*e re>uired #ormatD

  api"ervice.!ataConversion-nt0E#t 

0*is BAPI con'erts data #rom t*e interna! #ormat into t*e re>uired e;terna! #ormat.

api"ervice.!ataConversionE#t0-nt 

0*is BAPI con'erts data #rom t*e e;terna! #ormat into t*e re>uired interna! #ormat.

0*ese con'ersions can on! be carried out ro'ided t*at@ t*e con'ersion routines #or t*edomains under!in" t*e data to be con'erted@ are maintained in t*e ABAP 5ictionar.Ot*erwise t*e data is returned uncon'erted.

16

Page 17: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 17/51

0*e "ra*ic be!ow s*ows w*ere con'ersion BAPIs are usedD

Con%ersion BAPIs

Application

program

Application

program

GUIGUI

BAPI

;terna! data #ormat@ #or

e;am!e@ on t*e screen $GUI%

Interna! data #ormat

Acti%itiesFor detai!s o# indi'idua! ser'ice BAPIs re#er to t*e documentation created in t*e BO2 #ort*e BAPI in >uestion.

1

Page 18: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 18/51

(AP En/ancements to BAPIs

PurposeOn t*e basis o# SAP 2e!ease strate" and t*e strict ru!es #or en*ancin" e;istin" BAPIs@a!ication de'e!oers can re! on t*e stabi!it o# BAPI inter#aces.

ac* en*ancement to a re!eased BAPI is carried out ensurin" t*at t*e snta; andcontents are downward! comatib!e. 0*is means t*at a!ications ro"rammed wit*BAPIs in a articu!ar 2?3 2e!ease are not a##ected b c*an"es to t*is BAPI in !aterre!eases.

I# c*an"es t*at are not downwards comatib!e need to be made to an e;istin" BAPI@ anew inter#ace@ t*at is@ a new additiona! BAPI is created. 0*is BAPI *as t*e same name o#t*e e;istin" BAPI to be re!aced but wit* a number added at t*e end@ #or e;[email protected]!etail1 .

0*e BAPI to be re!aced is marked as e;irin" $obso!ete% in t*e 2e!ease in w*ic* t*esuccessor BAPI is im!emented@ but wi!! continue to be suorted in t*e ne;t two

#unctiona! 2e!eases.

BAPIs t*at are set to Mobso!eteN in an 2?3 2e!ease are !isted in :ote (1(644@M)o!!ecti'e :ote #or Obso!ete BAPIs as o# 2e!ease 4.-AN in t*e On!ineSo#tware Ser'ice $OSS%

Process Flow0*e "ra*ic be!ow i!!ustrates t*e e;ir *ase o# BAPIsD In t*is e;am!e@ t*e successor

BAPI was im!emented in 2e!ease 4.(. 0*e re!aced BAPI wi!! t*ere#ore be suorted in2e!ease 4.( $t*at is@ in t*e correction re!ease in w*ic* t*e successor BAPI wasim!emented% and in t*e ne;t two #unctiona! re!eases@ MF1N and MFN. In t*e #o!!owin"#unctiona! re!ease MF3N@ t*is BAPI wi!! no !on"er be a'ai!ab!e.

E6pir2 P/ase o& a BAPI

Release

BAPI

Business#$ect

BAPIBAPI

Business#$ect

BAPIBAPI

3ew

F7*87 98: F;

Suorted unti! F3

Suorted as o# 4.(

F #unctiona! 2e!ease

F*

For #urt*er in#ormation see n*ancin" ;istin" BAPIs in BAPI Pro"rammin".

1/

Page 19: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 19/51

BAPIs o& (AP Inter&ace 12pes

Use

From 2e!ease 4.-A BAPIs can a!so describe inter#aces im!emented outside t*e 2?3Sstem t*at an 2?3 Sstem can ca!! in e;terna! sstems. Suc* BAPIs are known as  BAPIs&or outound processing. 0*e tar"et sstem #or t*e BAPI can be determined t*rou"* t*edistribution mode! in A!ication Eink nab!in" $AE%.

BAPIs used #or outbound rocessin" are de#ined in t*e Business Object 2eositor as APImet*ods o& (AP Inter&ace 12pes.

Functions im!emented outside t*e 2?3 Sstem can be standardi+ed and made a'ai!ab!eas BAPIs.

Business #$ect Repositor2

'e&inition A!! SAP Business Object tes and SAP Inter#ace 0es and t*eir met*ods are de#inedand described in t*e 2?3 Business Object 2eositor $BO2%. 0*e Business Object2eositor was introduced in 2?3 2e!ease 3.(@ at t*e same as time as SAP BusinessObjects and SAP Business 8ork#!ow. Present!@ t*e BO2 is main! used b SAP Business8ork#!ow.

Use8it* t*e introduction o# BAPIs in 2?3 2e!ease 3.1@ t*e BO2 assumed an imortant newro!e it is now t*e centra! access oint #or e;terna! a!ications to access SAP BusinessObjects and SAP Inter#ace 0es and t*eir BAPIs.

0*e BO2 *as two essentia! #unctionsD

• It de#ines and describes SAP Business Objects and SAP Inter#ace 0es and t*eir 

BAPIs.

I# ou are de'e!oin" an a!ication ro"ram@ ou retrie'e detai!s o# t*e SAPBusiness Object tes or SAP Inter#ace 0es@ t*eir ke #ie!ds and t*eir BAPImet*ods #rom t*e BO2. 0*e BO2 contains a!! t*e in#ormation ou need tointe"rate t*e correct object te de#initions and BAPI ca!!s into our a!ication

ro"ram.

• It creates instances o# SAP Business Objects.

0*e runtime en'ironment o# t*e Business Object 2eositor recei'es re>uests#rom c!ient a!ications to create runtime objects and t*en creates t*e re!e'antobject instances.

For #urt*er in#ormation on creatin" business objects re#er to t*e documentation on SAPBusiness 8ork#!ow.

1&

Page 20: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 20/51

Programming wit/ BAPIs

UseIn t*is section it is assumed t*at t*e a!ication ou de'e!oed is to use t*e data *e!d inbusiness objects in t*e 2?3 Sstem and t*at t*is data is to be accessed b ca!!in" one or

more BAPIs. Cour a!ication can be as sim!e or as com!e; as ou !ike and can inc!udeca!!s #or one or more BAPIs.

IntegrationBAPIs are de#ined in t*e Business Object 2eositor $BO2% as met*ods o# SAP BusinessObjects or SAP Inter#ace 0es and are im!emented as #unction modu!es. 0*e searationo# a BAPI de#inition #rom its actua! im!ementation enab!es ou to access a BAPI in twowasD

• Cou can ca!! t*e BAPI in t*e BO2 t*rou"* objectoriented met*od ca!!s $see

Objectoriented Access to BAPIs%.

• Cou can make 2F) ca!!s to t*e #unction modu!e on w*ic* t*e BAPI is based $see

Functionoriented Access to BAPIs%.

0*e two aroac*es are i!!ustrated in t*e "ra*ic be!ow.

<a2s o& Accessing BAPIs

R)* (er%er 

Business #$ect Repositor2

Business #$ect0

(ales

#rder 

Function module!RFC capale"BAPIBAPI

BAPIBAPI

BAPIBAPI

Function module!RFC capale"

Function module!RFC capale"

Function Builder 

#$ect,oriented access RFC access

Features A!ications accessin" BAPIs can be broad! di'ided into two cate"oriesD

5ia!o" a!ications

8it* dia!o" a!ications t*e ca!!er usua!! waits unti! t*e met*od ca!! *as beenrocessed@ #or e;am!e@ wait #or t*e resu!ts o# a GetEist BAPI.

For more in#ormation see Pro"rammin" 5ia!o" A!ications.

(

Page 21: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 21/51

  5istributed a!ications

BAPIs can a!so be used in A!ication Eink nab!in" $AE% to e;c*an"e andre!icate data between two distributed sstems. For more in#ormation see5istributed A!ications Pro"rammin".

Acti%ities2e"ard!ess o# t*e tec*no!o" used@ ou *a'e to carr out t*e #o!!owin" stes to ca!! BAPIs#rom our a!ication ro"ramD

1ask For Furt/er In&ormation0

1. Identi# t*e SAP Business Object 0eor SAP Inter#ace 0e and t*e re>uiredBAPI.

5eterminin" BAPIs o# Business Objects or5eterminin" BAPIs o# Inter#ace 0es

. 5etermine t*e arameter in#ormation #or t*e BAPI inter#ace.

5eterminin" BAPIs o# Business Objects or

5eterminin" BAPIs o# Inter#ace 0es3. Inc!ude t*e BAPI ca!! or #unction ca!!

and t*e arameter dec!arations in oura!ication ro"ram.

Pro"rammin" 5ia!o" A!ications or Pro"rammin" 5istributed A!ications

For e;am!es o# ca!!in" BAPIs #rom'arious de'e!oment !at#orms see;am!es o# BAPI )a!!s.

1

Page 22: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 22/51

#$ect,oriented Access to BAPIs

PurposeObjectoriented access to BAPIs in t*e BO2 is ossib!e #rom a number o# !at#orms.

'e%elopment tool )+iddleware )ProgrammingEn%ironment

Furt/er In&ormation

'e%elopment 1ool )+iddleware

BAPI Acti%e= Control

$8indows &- and8indows :0%

0*e BAPI Acti'eL )ontro! #rom SAP a!!ows e;terna!c!ient a!ications to access t*e SAP Business Objectsin t*e BO2 b in'okin" BAPIs t*rou"* OE AutomationFor more in#ormation see BAPI Acti'eL )ontro!.

BAPI C>> Class Lirar2in (AP Assistant

 A BAPI ) )!ass Eibrar is a'ai!ab!e in t*e SAP Assistant ro'idin" a ) ro; c!ass #or eac* SAPBusiness Object and its BAPIs.

For #urt*er in#ormation see 0*e ) BAPI Pro;)!asses in t*e SAP Assistant documentation.

BAPI -a%a ClassLirar2 in (APAssistant

 A dnamic BAPI <a'a )!ass Eibrar is a'ai!ab!e in SAP Assistant enab!in" objectoriented access to BAPIs#rom <a'a !at#orms. 0o ca!! BAPIs@ t*e usua! datates and c!asses in <a'a can be used instead o# t*eSAP interna! data tes and structures.

For #urt*er in#ormation see 0*e <a'a BAPI Pro;)!asses in t*e SAP Assistant documentation.

R)* 'C#+ ComponentConnector 

$8indows :0%

0*e 2?3 5)O7 )omonent )onnector de'e!oed joint! b SAP and 7icroso#t enab!es 2?3 objects and)O7 objects to be seam!ess! inte"rated. SAPBusiness Objects and t*eir BAPIs can be accesseddirect! #rom )O7based de'e!oment too!s@ and t*eot*er wa around@ )O7 comonents can be accessed#rom t*e SAP de'e!oment en'ironment.

0*e 2?3 5)O7 )omonent )onnector So#tware5e'e!oment 9it $S59% is s*ied as art o# 2F) S59#or 8indows :0.

#$ectBridge#rom =isua! d"e

=isau! d"es midd!eware roduct MObjectBrid"eNenab!es automatic access to BAPIs #rom a!! )O2BA

.(enab!ed Object 2e>uest Brokers $O2Bs% as we!! as#rom ot*er objectoriented rotoco!s suc* as Acti'eL?5)O7.

For #urt*er detai!s see t*e ObjectBrid"e roductin#ormation.

Programming En%ironments

'elp/i)Connect &or (AP#rom Inrise

For #urt*er detai!s see 5e!*i?)onnect roductin#ormation.

Access Builder &or (APR)* #rom IB7

 Access Bui!der #or SAP 2?3 is used to inte"rate BAPIsinto IB7s de'e!oment en'ironment@ =isua! A"e #or<a'a. Access Bui!der #or SAP 2?3 enab!es t*e

de'e!oment o# BAPIenab!es <a'a a!ications@ <a'aa!ets and <a'aBeans #or t*e 2?3 Sstem. For #urt*er

Page 23: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 23/51

detai!s see t*e roduct in#ormation #or Access Bui!der#or SAP 2?3

.isual (tudio!Enterprise Edition"#rom 7icroso#t

From now on BAPIs im!emented in 2?3 2e!eases3.1, and 4.(A wi!! be a'ai!ab!e !oca!! #rom 7icroso#tsde'e!oment en'ironment =isua! Studio $nterrise

dition%.

Process Flow A!ications run di##erent! on di##erent de'e!oment en'ironments and t*e stes re>uiredto in'oke t*em are a!so di##erent.

0*e e;am!e be!ow i!!ustrates t*e stes in'o!'ed w*en t*e BAPI Acti'eL )ontro! is used toaccess BAPIs. 8*en t*e 2?3 Sstem is connected to@ t*e c!ient a!ication accesses t*eSAP Business Objects at runtime b #orwardin" t*e OE automation re>uests to t*e BAPI Acti'eL )ontro!.

0*e stes in'o!'ed areD

  )reatin" a BAPI Acti'eL )ontro! object

(et oBAPICtrl ? Create#$ect!@(AP8BAPI87"

  )reatin" a !o"on contro! objectD

(et oLogonCtrl ? Create#$ect!@(AP8Logoncontrol87"

  )reatin" a connection object to t*e 2?3 SstemD

(et oBAPICtrl8Connection ? oLogonCtrl83ewConnection

  Eo""in" on to 2?3 Sstem b ca!!in" t*e !o"on met*od o# t*e connection objectD

I& oBAPICtrl8Connection8Logon!&rm(tart8/wndFAL(E" ? FAL(E t/en

+sgBo6R)* Connection &ailedEnd

Endi& 

  2e>uestin" t*e creation o# a !oca! instance o# t*e SAP Business Object

Be#ore our a!ication can ca!! a BAPI o# an SAP Business Object@ it must #irstre>uest t*at an instance o# t*e object is created.

0*e #o!!owin" command #rom a =isua! Basic ro"ram s*ows t*e use o# t*e BAPI Acti'eL )ontro! object and t*e Get"AP2b)ect  met*od to re>uest t*e creation o#an instance o# t*e business object "ales2rer.

(et o#rder ? oBAPICtrl8Get(AP#$ect!(ales#rder"

 

)reatin" t*e arameter objects

(et o#rder5eader ? oBAPICtrl8'imAs!o#rder D   CreateFrom'at7 #rder5eaderIn"

(et otaItems ? oBAPICtrl8'imAs!o#rder D   CreateFrom'at7 #rderItemsIn"

(et otaPartners ? oBAPICtrl8'imAs!o#rder D   CreateFrom'at7 #rderPartners"

0*en t*e re!e'ant data must be entered in t*e arameter objects.

)a!!in" t*e BAPIs o# t*e business objects

Once t*e object instance *as been created@ t*e a'ai!ab!e BAPIs can be ca!!ed.

0*e #o!!owin" command #rom a =isua! Basic ro"ram i!!ustrates a BAPI ca!!D

3

Page 24: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 24/51

o#rder8CreateFrom'at7 #rder5eaderIn0?o#rder5eader D   #rderPartners0?otaPartners D   #rderItemsIn0?otaItems D   Return0?oReturn

  2e!easin" t*e SAP Business Object and re!easin" t*e BAPI Acti'eL )ontro! object.

0*e #o!!owin" #i"ure i!!ustrates t*e rocess o# accessin" SAP Business Objects and t*eirBAPIs t*rou"* t*e BAPI Acti'eL )ontro!.

Using t/e BAPI Acti%e= Control

4

Page 25: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 25/51

Function,oriented Access to BAPIs

PurposeCou can access BAPIs #rom !at#orms t*at do not ro'ide direct objectoriented access toSAP Business Objects b makin" 2emote Function )a!!s $2F)s% to t*e #unction modu!e

t*at a BAPI is based on.

0*is aroac* can be used on a!! de'e!oment !at#orms suortin" t*e 2F) rotoco!@ #ore;am!e@ ABAP or e;terna! !at#orms usin" )?) )!ass Eibrar.

Process Flow5urin" runtime our a!ication ro"ram uses t*e 2F) Eibrar or t*e )?) )!ass Eibrettoto make an 2F) ca!! to t*e #unction modu!e under!in" t*e BAPI. 0*e Eibrar trans!atesc!ient ca!!s into communication stes in accordance wit* t*e 2F) rotoco!.

0*is is *ow c!ient re>uests are #orwarded to t*e re!e'ant #unction modu!e in t*e 2?3 ser'ersstem.

0*is aroac* is i!!ustrated in t*e "ra*ic be!ow.

Accessing a BAPI Function +odule 1/roug/ RFC Calls

For #urt*er in#ormation about 2F) ca!!s to #unction modu!es see 2emote )ommunications.

-

Page 26: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 26/51

Programming 'ialog Applications

UseSAP ro'ides 'arious ser'ice #unctions to suort dia!o" a!ication ro"rammin".

FeaturesIn dia!o" a!ications ou can make use o# t*e #o!!owin" *e! #unctionsD

1ransaction Control

ac* dia!o" transaction usin" BAPIs to c*an"e data in one or more objects must direct!e;ecute t*e )O77I0 8O29 command to sa'e t*e data. 0*e BAPIapi"ervice./ransactionCommit  is used #or t*is and it writes t*e c*an"es to t*e database.

I# data is not to be written to t*e database@ t*e BAPI api"ervice./ransactionRollback canreset t*e c*an"es@ ro'ided t*at t*e c*an"es *a'e not a!read been assed to t*edatabase wit* t*e BAPI api"ervice./ransactionCommit.  

Possile Entries !F9 5elp"

0o ro'ide ossib!e entries $F4 *e!% #or an inut #ie!d #orwarded w*en a BAPI is ca!!ed@ou can inc!ude t*e ser'ice BAPI Help+alues.GetList  in our ro"ram. 0*is BAPI su!iest*e inut 'a!ues a!!owed #or t*e #ie!d in a BAPI arameter.

0*e met*od Help+alues.GetList  met*od re#ers to t*e *e! 'iew #or t*e c*eck tab!e@matc*codes or domain #i;ed 'a!ues !inked to t*e #ie!d in t*e ABAP 5ictionar. Forin#ormation about c*eck tab!es@ matc*codes and domain #i;ed 'a!ues see t*e ABAP5ictionar.

Input 5elp !F7 5elp"

0o ro'ide inut *e! $F1 *e! or #ie!d *e!% #or inut #ie!ds in our a!ication ou can uset*e BAPI api"ervice.$ielHelpGet!ocu.  0*is met*od reads t*e documentation $F1 *e!%#or t*e #ie!ds in a BAPI arameter.

Interpreting Return +essages

ac* BAPI contains a arameter named Return. 0*is arameter returns e;cetionmessa"es or success messa"es to t*e ca!!in" ro"ram.

0wo ser'ice BAPIs are ro'ided to dia"nose and rocess error messa"es #rom BAPI ca!!sD

  api"ervice.Messa%eGet!etail w*ic* dis!as t*e s*ort and !on" te;ts o# BAPI

error messa"es.

  api"ervice.ApplicationLo%Get!etail @ wit* w*ic* in#ormation in a!ication !o"s can

be dis!aed.

Furt/er In&ormationFor #urt*er in#ormation about t*ese BAPIs re#er to t*e BAPI documentation in t*e BusinessObject 2eositor.

6

Page 27: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 27/51

Programming 'istriuted Applications

Use As o# 2?3 2e!ease 4.( BAPIs can a!so be used in A!ication Eink nab!in" $AE% toe;c*an"e and re!icate data between distributed sstems. 8*en data is e;c*an"ed

between two distributed sstems t*ere is a di##erence between usin" snc*ronous andasnc*ronous BAPIs.

Features

(2nc/ronous BAPIs

Snc*ronous BAPIs are used to read data #rom a remote !o"ica! sstem@ #or e;am!e@ todis!a a !ist o# customers.

Cou *a'e to determine t*e 2F) destination o# t*e remote sstem or BAPI ser'er be#oreca!!in" t*e BAPI. A!ication de'e!oers can use an API to determine t*e 2F) destinationo# t*e BAPI.

As2nc/ronous BAPIs Asnc*ronous BAPIs are used to re!icate data on one or more !o"ica! sstems@ #ore;am!e@ to distribute artic!e master data.

0o trans#er data asnc*ronous! usin" BAPIs@ an AE I5oc inter#ace must be "enerated.0*is inter#ace *and!es t*e entire data e;c*an"e between t*e !o"ica! sstems usin" I5octec*no!o". 0*us@ t*e a!ication ca!!s t*e "enerated AE I5oc inter#ace !oca!!@ instead o#ca!!in" t*e BAPI.

 As wit* snc*ronous BAPIs@ t*e re!e'ant !o"ica! sstems o# t*e BAPI must be seci#iedbe#ore ca!!in" t*e AE I5oc inter#ace. 0*ese are trans#erred to t*e AE I5oc inter#ace asinut arameters.

ALE 'istriution +odel As wit* messa"e tes@ snc*ronous and asnc*ronous BAPIs wit*in t*e AE #rameworkare maintained in t*e AE distribution mode!. 0*e !o"ica! sstems $in t*e case o#asnc*ronous BAPIs% or t*e 2F) destinations $in t*e case o# snc*ronous BAPIs aredetermined at runtime usin" t*e distribution mode!.

For more in#ormation on t*e use o# BAPIs in AE see AE Pro"rammin".

Page 28: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 28/51

1ransaction +odel &or 'e%eloping BAPIs

Use0*e transaction mode! in w*ic* BAPIs are used determines *ow ou *a'e to ro"ramBAPIs.

Logical Unit o& <ork !LU<" and (tatelessness

8it*in t*e conte;t o# t*e transaction mode! used to de'e!o BAPIs #or 2?3 2e!eases 3.1and 4.( a transaction reresents one rocessin" ste or one !o"ica! unit o# work $EU8%. An2?3 EU8 is a!! t*e stes in'o!'ed in a transaction inc!udin" udatin" t*e database.0*e w*o!e transaction must be ro"rammed to be state!ess.

0*e A)I5 rinci!e a!ies to transaction mode!s@ meanin" t*at transactions areD

  Atomic

8*en a transaction is ca!!ed@ database oerations are eit*er #u!! e;ecuted or notat a!!. it*er all re!e'ant data *as to be c*an"ed in t*e database or none at a!!.

 

ConsistentI# a transaction is ca!!ed more t*an once@ eac* ca!! must *a'e t*e same resu!t. :odata is imorted t*at ma indirect! a##ect t*e resu!t.

Iso!ated

0*ere must be no #unctiona! deendencies between two transactions@ onetransaction must not a##ect anot*er transaction.

'urab!e

)*an"es cannot be re'ersed and transactions cannot be cance!ed.

Features

0*e #o!!owin" sections describe *ow t*e transaction mode! e##ects BAPI de'e!omentDIn 2e!ease 3.1 t*e BAPIs t*emse!'es e;ecuted t*e )O77I0 8O29 command@ BAPIs*ad t*e same urose as an EU8 or transaction. 0o inte"rate BAPIs into an EU8@ t*enew BAPIs no !on"er e;ecute )O77I0 8O29 commands as o# 2e!ease 4.(.

0*e outcome is two transaction mode!sD

BAPI 0ransaction 7ode! wit* )ommit $as o# 2e!ease 3.1%BAPI 0ransaction 7ode! 8it*out )ommit $as o# 2e!ease 4.(%

 

I# a BAPI e;ecutes a )O77I0 8O29 command@ t*is must be mentioned int*e BAPI documentation. 0*is is t*e on! wa users are ab!e to know t*at t*eBAPI contains a )O77I0 8O29 command.

BAPI 1ransaction +odel wit/ Commit

Use0*e e;am!e be!ow o# an e;terna! ro"ram ca!!in" a BAPI to c*an"e data in an 2?3Sstem@ i!!ustrates *ow t*e transaction mode! a##ects BAPI de'e!oment in 2e!ease 3.1.For e;am!e@ t*is cou!d in'o!'e a transaction im!emented wit* =isua! Basic. On! data

#rom t*e 2?3 Sstem is to be c*an"ed.

/

Page 29: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 29/51

0*e 2F) connection is !i'e t*e w*o!e time t*e e;terna! ro"ram is !o""ed on to t*e 2?3Sstem to a'oid *a'in" to connect and disconnect reeated!. 8*en t*e 2F) connectionis a!read estab!is*ed@ an 2F) ca!! does not essentia!! take u an more )PU time t*an adirect ca!! to t*e #unction modu!e #rom wit*in t*e 2?3 Sstem.

0*ere is one BAPI ca!! #or eac* transaction in t*e transaction mode! suorted in 3.1.

BAPIs can on! be ca!!ed snc*ronous!. A BAPI ca!! is essentia!! t*e ca!! o# t*eunder!in" 2F) caab!e #unction modu!e.

0*e rocess #!ow o# t*e ro"ram consists o# t*e #o!!owin" stes be!ow $see "ra*ic be!ow%D

Eo" on

... Source code

)a!! BAPI to read and?or c*an"e data

... Source code

)a!! BAPI to read and?or c*an"e data

... Source code

Eo" o## 

1ransaction +odel &or Release *87

8*at do t*e terms EU8 and state!essness mean to BAPIs t*at *a'e beenim!emented in t*e #ramework o# t*is transaction mode!

I# a transaction reresents one Eo"ica! Unit o# 8ork and in addition is suosed to bestate!ess@ BAPIs are a##ected as #o!!owsD

  Initia! state eac* time a BAPI is ca!!ed

 A reeated ca!! o# one BAPI must roduce t*e same resu!t. On! data t*at is nota##ected b t*e e;ecution o# t*e BAPI@ #or e;am!e@ )ustomi+in" data@ can bebu##ered.

&

Page 30: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 30/51

For BAPIs t*is means@ #or e;am!e@ t*at due to transarenc@ Set and Getarameters and t*e "!oba! memor s*ou!d not be used.

,owe'er@ ou can kee )ustomi+in" data in a "!oba! memor as t*is data remainsunc*an"ed e'en i# transaction ca!!s are reeated.

   A!! or not*in" rinci!e

 A database c*an"e@ #or e;am!e@ creatin" a new sa!es order@ must be carried outcom!ete! or not at a!! $EU8%.

0*is is w* BAPIs to be im!emented in 3.1 are created wit* inte"rated commitcontro!. 0*e )O77I0 8O29 command is a!was in'oked at t*e end o# t*e#unction modu!e o# a BAPI t*at modi#ies data.

  :o #unctiona! deendenc between two BAPIs

 A BAPI ca!! must not be ne"ati'e! a##ected b an ear!ier ca!! o# anot*er BAPI. A#o!!ow u ca!! must not resuose an ear!ier ca!!. For t*is reason a!so@ ou s*ou!dnot use Set and Get arameters in t*e BAPI nor use t*e "!oba! memor.

7ake sure t*at a )O77I0 8O29 command on! de!etes t*e memor o# t*e

#unction modu!e@ and not t*e memor o# t*e #unction "rou. 0*e "!oba! data o# t*e#unction "rou remains and cou!d re'ent anot*er BAPI #rom bein" ca!!ed@ andt*us imair t*e BAPIs #unctiona! indeendence.

Ot*er searate EU8s are not tri""ered

0*e ca!! o# a BAPI must not tri""er #urt*er EU8s t*at are indeendent o# t*e BAPI.For t*is reason BAPIs must not contain t*e #o!!owin" commandsD

− )AEE 02A:SA)0IO:

− SUB7I0 2PO20

− SUB7I0 2PO20 A:5 20U2:

 BAPI 1ransaction +odel <it/out Commit

UseIn 2e!ease 4.( t*e commit contro! must be taken out o# write BAPIs@ t*at is@ t*ose BAPIst*at cause database c*an"es. ,owe'er@ t*e e;istin" transaction mode! used in 2e!ease3.1 s*ou!d not be c*an"ed. 0*is is ac*ie'ed b usin" t*e met*od /ransactionCommit  o#t*e object api"ervice w*ic* e;ecutes t*e command )O77I0 8O29.0*e rocess #!ow o# t*e ro"ram consists o# t*e #o!!owin" stes $see "ra*ic be!ow%D

Eo" on

... Source code

)a!! BAPI to read and?or c*an"e data

)a!! BAPI api"ervice./ransactionCommit 

... Source code

)a!! BAPI to read and?or c*an"e data

)a!! BAPI api"ervice./ransactionCommit 

... Source code

3(

Page 31: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 31/51

Eo" o## 

E6tended 1ransaction +odel

,api"ervice./ransactionCommit 

BAPI Call

Call

Log off Log on

RFC Session

I# termiantion messa"e is dis!aed $messa"e te A% in t*e Return arameter@ a databasero!!back can be e;ecuted b t*e BAPI. 0*is causes a!! t*e acti'ities carried out since t*e!ast )O77I0 8O29 command to be cance!ed. 0*is situation is described in t*e Return arameter documentation #or t*e BAPI in >uestion.

0*e same ru!es a! in t*is mode! as in t*e BAPI 0ransaction 7ode! 8it* )ommit. 

Oerations t*at c*an"e t*e database can on! be carried out t*rou"* udatin".

31

Page 32: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 32/51

'etermining BAPIs o& Business #$ects

ProcedureSAP Business Objects and t*eir BAPIs are mana"ed in t*e Business Object 2eositor$BO2% in a structure based on t*e 2?3 A!ication )omonent *ierarc*.

In t*e BAPI Browser  ou can dis!a a!! t*e SAP Business Objects in t*e a!ication*ierarc* #or w*ic* BAPIs *a'e been im!emented.

Fo!!ow t*e stes be!owD

1. Eo" on to t*e 2?3 Sstem.

. )*oose /ools → usiness $rame3ork →  AP- ro3ser or enter t*e transaction

code BAPI in t*e SAP"ui command #ie!d. 0*e AP- ro3ser  o# t*e BO2 isdis!aed in w*ic* a!! Business Objects wit* BAPIs are dis!aed in t*e 2?3a!ication *ierarc*.

3. ;and t*e nodes and t*e subordinate nodes o# one o# t*e a!ication comonents

unti! ou "et to t*e !e'e! w*ere t*e SAP Business Objects are assi"ned. On! t*osebusiness objects #or w*ic* BAPIs *a'e been im!emented are dis!aed.

4. 0o oen a business object@ doub!ec!ick on it. 0*e nodes 4ey iels and Methos are dis!aed.

-. ;and t*e node Methos to dis!a a !ist o# t*e BAPIs a'ai!ab!e #or t*e se!ectedSAP Business Object te. Se!ect t*e in#ormation icon to dis!a descritions o#indi'idua! BAPIs.

6. ;and t*e node 4ey iels, to !ist t*e ke #ie!ds o# t*e object. Se!ect t*ein#ormation icon to dis!a descritions o# indi'idua! ke #ie!ds.

)*oose &tilities → Color 4ey to dis!a a descrition o# indi'idua! icons in t*e

BAPI Browser.

 A#ter ou *a'e #ound t*e BAPI ou want@ ou *a'e to seci# t*e in#ormation ou *a'e to#orward to ca!! t*e BAPI or #unction in our a!ication ro"ram.

In#ormation re>uired isD

• 0*e 9e Fie!ds o# t*e SAP Business Object

• 0*e Imort@ ;ort and Imort?;ort Parameters o# t*e BAPI

• 0*e :ame o# t*e Function 7odu!e@ i# ou direct 2F) ca!!s to t*e #unction modu!e

under!in" t*e BAPI. A!so re#er to t*e 5ocumentation@ ro'ided wit* eac* BAPI.

Once ou *a'e "at*ered a!! t*e necessar in#ormation@ ou can add t*e BAPI ca!! to oura!ication code.

3

Page 33: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 33/51

(peci&2ing t/e Ke2 Fields o& t/e Business #$ect

Prerequisites0*e ke #ie!ds o# SAP Business Objects seci# t*e identi#ication structure wit* w*ic*c!ient ro"rams can uni>ue! access a seci#ic instance o# t*e object te.

0*e ke #ie!ds o# an SAP Business Object are re>uired i# t*e BAPI in >uestion is usin"seci#ic object te instances.

BAPIs can be di'ided into t*e #o!!owin" cate"ories accordin" to w*et*er t*e accessseci#ic object instancesD

• Instancedeendent BAPIs

Instancedeendent BAPIs use seci#ic instances o# an object te w*ic* t*ec!ient a!ication must seci# in t*e ke #ie!ds o# t*e Business Object. An e;am!e

o# an instacnedeendent BAPI is CompanyCoe.Get!etail  and w*en used t*ec!ient a!icaiton must seci# t*e coman code I5@ #or e;am!e@Get"AP2b)ect56CompanyCoe6,6777168.

• Instanceindeendent BAPIs

Instanceindeendent BAPIs do not use seci#ic object instances. 0*e usua!!return a !ist o# object instances in tab!es to t*e ca!!in" ro"ram. Instanceindeendent BAPIs are a!so ca!!ed c!ass met*ods. An e;am!e o# t*is BAPI isCompanyCoe.GetList @ w*ic* returns a !ist o# coman codes.

Some instancedeendent BAPIs "enerate object instances and reorts backin#ormation on t*e "enerated object instance to t*e ca!!in" a!ication. An e;am!eo# t*is te o# BAPI is "ales2rer.Create$rom!ata@ w*ic* creates a customer

order and reorts back in#ormation to t*e ca!!in" ro"ram.

Procedure0o dis!a t*e ke #ie!ds o# an SAP Business Object@ se!ect t*e Business Object in t*eBAPI Browser and e;and t*e node 4ey iels, as described in 5eterminin" BAPIs o#Business Objects.

Se!ect t*e re!e'ant icon in t*e BAPI Browser to dis!a #urt*er in#ormation about t*e

indi'idua! ke #ie!ds. )*oose &tilities → Color 4ey to dis!a a descrition o# indi'idua!

icons in t*e BAPI Browser.

(peci&2ing t/e BAPI Parameters

PrerequisitesOnce ou *a'e #ound t*e BAPI ou want ou *a'e to seci# w*ic* arameters ou can or must dec!are. BAPIs *a'e imort?e;ort arameters $tab!e arameters% as we!! as imortarameters and e;ort arameters #or imortin" and e;ortin" data.

Procedure0o dis!a t*e arameters o# t*e BAPID

1. Oen t*e Business Object and t*e node Methos in t*e BAPI Browser@ asdescribed in 5is!ain" BAPIs in t*e BAPI Browser .

33

Page 34: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 34/51

. ;and t*e node #or t*e re!e'ant BAPI and t*en t*e node Parameters.

Result A !ist o# a!! t*e BAPIs arameters is dis!aed.

Se!ect t*e re!e'ant icon in t*e BAPI Browser to dis!a #urt*er in#ormation about t*e

indi'idua! arameters. )*oose &tilities → Color 4ey to dis!a a descrition o# indi'idua!

icons in t*e BAPI Browser.

'etermining t/e 3ame o& t/e Function +odule

PrerequisitesI# ou want to ca!! t*e BAPI b makin" an 2F) ca!! to t*e under!in" #unction modu!e@ ou*a'e to know t*e name o# t*e #unction modu!e.

Procedure0o determine t*e name o# t*e #unction modu!e im!ementin" t*e BAPID

1. Oen t*e Business Object in t*e BAPI Browser@ as described in 5is!ain" BAPIsin t*e BAPI Browser .

. Oen t*e node Methos and osition t*e cursor on t*e re!e'ant BAPI.

3. 0o dis!a t*e BAPI documentation se!ect t*e in#ormation icon. 0*e name o# t*e#unction modu!e is "i'en at t*e start o# t*e documentation.

0*e names o# BAPI #unction modu!es a!was be"in wit* MBAPIN.

)*oose &tilities → Color 4ey to dis!a a descrition o# indi'idua! icons in t*e BAPI

Browser.

'ispla2ing t/e Function +odule

Cou can dis!a t*e BAPI #unction modu!e in t*e Function Bui!derD

1. )*oose /ools →  AAP 9orkbench and t*en $unction uiler. A!ternati'e! enter

t*e 0ransaction SE37 in t*e SAP"ui command #ie!d.

. 5is!a t*e BAPI #unction modu!e b enterin" t*e names o# t*e #unction modu!e int*e #ie!d $unction moule and se!ectin" !isplay .

'ispla2ing BAPI 'ocumentation5ocumentation describin" #unctiona!it and arameters is ro'ided on eac* BAPI.0o dis!a documentation on a articu!ar BAPID

1. Oen t*e Business Object in t*e BAPI Browser@ as described in 5is!ain" BAPIsin t*e BAPI Browser .

. Oen t*e node Methos and osition t*e cursor on t*e re!e'ant BAPI.

3. Se!ect t*e in#ormation icon to dis!a t*e documentation on t*e BAPI and itsassociated arameters.

)*oose &tilities → Color 4ey to dis!a a descrition o# indi'idua! icons in t*e BAPI

Browser.

34

Page 35: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 35/51

'etermining BAPIs o& Inter&ace 12pes

ProcedureSAP Inter#ace 0es and t*eir BAPIs are mana"ed in t*e Business Object 2eositor$BO2% in a structure based on t*e 2?3 A!ication )omonent *ierarc*. In t*e Business#$ect Builder ou can dis!a a!! t*e SAP Inter#ace 0es in t*e a!ication *ierarc* .

Fo!!ow t*e stes be!owD

1. Eo" on to t*e 2?3 Sstem.

. )*oose /ools → usiness $rame3ork →  AP- !evelopment → usiness 2b)ect

uiler or enter t*e transaction code SWO1 in t*e SAP"ui command #ie!d.

3. Se!ect usiness 2b)ect Repository .

4. In t*e ne;t dia!o" bo; se!ect t*e #i!ter 2ther settin%s. In t*e #ie!d /ype se!ect t*esettin" -nterace and deacti'ate t*e settin" 2b)ect, in t*e #ie!d /ype se!ect t*esettin" 2thers and mark a!! t*e settin"s in t*e #ie!d "tatus. 

0*e usiness 2b)ect Repository ro3ser  is dis!aed in w*ic* a!! t*e SAPInter#ace 0es wit* BAPIs are dis!aed in t*e 2?3 a!ication *ierarc*.

-. ;and t*e nodes and t*e subordinate nodes o# one o# t*e a!ication comonentsunti! ou "et to t*e !e'e! w*ere t*e SAP Inter#ace 0es are assi"ned.

6. 0o oen an SAP Inter#ace 0e@ doub!ec!ick on it. 0*e nodes -nteraces, Attributes,

Methos and Events are dis!aed.

. ;and t*e node Methos to dis!a a !ist o# t*e met*ods a'ai!ab!e #or t*e se!ectedSAP Inter#ace 0e. BAPIs are marked b a "reen circ!e ne;t to t*e met*od name.

Once ou *a'e #ound t*e BAPI ou want@ ou s*ou!d retrie'e t*e in#ormation on t*e BAPIinter#ace w*ic* ou need to im!ement and use t*e BAPI $see Seci#in" t*e BAPIParameters%. A!so use t*e 5ocumentation@ ro'ided wit* eac* BAPI.

Once ou *a'e "at*ered a!! t*e necessar in#ormation@ ou can im!ement t*e inter#aceand use t*e BAPI in our a!ication ro"ram.

(peci&2ing t/e BAPI Parameters

PrerequisitesOnce ou *a'e #ound t*e BAPI ou want@ ou *a'e to seci# t*e otiona! and mandatorarameters o# t*e BAPI inter#ace. BAPIs *a'e imort?e;ort arameters $tab!earameters% as we!! as imort arameters and e;ort arameters #or imortin" ande;ortin" data.

Procedure0o dis!a t*e arameters o# a BAPID

1. In t*e Business Object 2eositor Browser e;and t*e node Methos, as

described in 5eterminin" BAPIs o# Business Objects.. Position t*e cursor on t*e re!e'ant BAPI and se!ect Parameters

3-

Page 36: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 36/51

'ispla2ing BAPI 'ocumentationFor eac* BAPI o# an inter#ace te@ documentation is a'ai!ab!e describin" t*e BAPIsarameters and t*e #unctiona!it to be im!emented.

0o dis!a documentation on a articu!ar BAPID

1. In t*e Business Object 2eositor Browser e;and t*e node Methos, asdescribed in 5eterminin" Inter#ace 0e BAPIs. 

. Position t*e cursor on t*e re!e'ant BAPI and c*oose Goto → !ocumentation

36

Page 37: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 37/51

E6amples o& BAPI Calls0*e #o!!owin" e;am!es i!!ustrate *ow BAPIs are ca!!ed #rom di##erent de'e!oment!at#orms.

)a!!in" BAPIs #rom <a'a

  )a!!in" BAPIs #rom =isua! Basic  )a!!in" BAPIs #rom ABAP

Calling BAPIs &rom -a%a0*is is an e;am!e ro"ram #or ca!!in" a BAPI #rom t*e IB7 de'e!oment !at#orm@ AccessBui!der #or SAP 2?3.

5etai!ed ro"ram e;am!es are s*ied wit* t*e Access Bui!der #or 2?3.

Access Builder &or (AP R)*

//Importing the required classes:

import com.sap.rfc.*;import com.sap.rfc.exception.*;import com.ibm.sap.bapi.*;import com.ibm.sap.bapi.generated.*;

//Connecting to the R/3 System:

static priate I!fc"onnection estab#is$"onnection%&idd#e'areInfoa&idd#e'areInfo(

t$ro's )!fc!emoteException

I!fc"onnection a"onnection + n,## ;

"onnectInfo a"onnectInfo + n,## ;-serInfo a-serInfo + n,## ;String orbSererame + a&idd#e'areInfo.getOrbSererame%( ;// P#ease ad0,st t$e a#,es 'ritten in -PPE!"ASE E22E!S// in t$e #ines be#o' so t$at t$e fit to o,r needs4// If o, don5t 6no' t$e correct a#,es as6 o,r sstem// administrator4// After correcting t$ese a#,es o, s$o,#d c$ange t$e// bAd0,sted8 ariab#e in t$e fo##o'ing #ine// from 9fa#se9 to 9tr,e9.// 2$en o, can re:compi#e %90aac Samp#e"ompan"ode.0aa9( and// re:r,n %90aa Samp#e"ompan"ode :conn )I9( t$is samp#e...boo#ean bAd0,sted + tr,e;if %4bAd0,sted(

t$ro' %ne' )!fc!fc"onnectionException %9P#ease ad0,st t$e "onnection:Parameters to o,rneeds4 %See met$od 9estab#is$"onnection9(9((;

<

  //Connection information:

a"onnectInfo + ne' "onnectInfo %3= // int a!fc&ode 3+!/3 or >+!/>n,##= // String [email protected]>.79= // String aostame O-! OS2A&E %e.g. IP:

//address(C= // int aSstemo O-! SS2E&:-&BE!n,##= // String aDate'aostn,##= // String aDate'aSericen,##= // String aSstemame

n,##= // String aDro,pamen,##= // String a&sgSererfa#se= // Boo#ean isoadBa#ancing

3

Page 38: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 38/51

tr,e(; // Boo#ean is"$ec6A,t$oriation

  //User information:

a-serInfo + ne' -serInfo %9&-S2E!9= // String a-serame= O-! -SE!I?9I?ES9= // String aPass'ord= O-! PASSWO!?9FCC9= // String a"#ient= O-! "IE2 -&BE!

9e9= // String aang,age= O-! P!EGE!!E?//AD-ADE

11C3(; // int a"odePage O-! !EH-I!E? "O?EPADE

  //Technical conversion for the selected middleware  // !pen connection:

I!fc"onnectionGactor a"onnectionGactor +Gactor&anager.getSing#eInstance%(.get!fc"onnectionGactor%( ;

a"onnection + a"onnectionGactor.create!fc"onnection%a"onnectInfo=a-serInfo( ;

a"onnection.open%( ;  //!et,rning t$e connection

ret,rn a"onnection ;<

//Calling the main method:p,b#ic static oid main %0aa.#ang.StringJK args(

  //Setting up the connection using the selected middleware:

&idd#e'areInfo a&idd#e'areInfo + ne' &idd#e'areInfo%args( ;Gactor&anager aGactor&anager + Gactor&anager.getSing#eInstance%( ;aGactor&anager.set&idd#e'areInfo%a&idd#e'areInfo( ;

  //Initiali"ing the connection o#$ect:

I!fc"onnection a"onnection + n,## ;tr

a"onnection + estab#is$"onnection%a&idd#e'areInfo( ;<

catc$ %Exception ex(

Sstem.o,t.print#n%9E!!O! "o,#d not create connection 9 Lex( ;

Sstem.exit%:1( ;<Sstem.o,t.print#n%9"onnection estab#is$ed.9(;

  // ::: 2ES2 "O?E %start( ::::::::::::::::::::::::::::::::::::::tr

printist%a"onnection( ;

//Calling the %&'I:

//(eclare an empty !#$ect I( for the %usiness !#$ect

  //CompanyCode:

ob0ectId + "ompan"ode.getEmptOb0ectId%( ;

//)ntering a value in the o#$ect I(:

ob0ectId.getMeGie#d%9"O&PA"O?EI?9(.setString%91CCC9( ;

//Instantiate the o#$ect CompanyCode with the o#$ect I(:

compan"ode + ne' "ompan"ode%ob0ectId( ; // "reate >nd"ompan"odeSstem.o,t.print#n %9S,ccessf,## created ne' "ompan"ode 59

L compan"ode L 959( ;print?etai#s%compan"ode= a"onnection( ;

<// ::: 2ES2 "O?E %end( ::::::::::::::::::::::::::::::::::::::::

catc$ %Exception ex(Sstem.o,t.print#n %9-nexpected exception occ,rred9(;

3/

Page 39: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 39/51

Sstem.o,t.print#n %ex(;<

<priate static oid print?etai#s%"ompan"ode compan"ode= I!fc"onnectionconnection(

tr

  //(eclare the parameters of the %&'I CompanyCode*+et(etail:

"ompan"odeDetdetai#Params a"ompan"odeDetdetai#Params +ne' "ompan"odeDetdetai#Params%( ;

  //&ufruf des %&'Is CompanyCode*+et(etail auf die !#$e,tinstan":

compan"ode.getdetai#%connection=a"ompan"odeDetdetai#Params(;

  //Splitting the parameter o#$ect into its separate components//-Stru,tur.:

BapiCCC>N>Str,ct,re str,ct +a"ompan"odeDetdetai#Params.get"ompancode?etai#%( ;

Sstem.o,t.print#n %92$e detai#s of t$e compancode are 9( ;

  //Splitting the structure into individual fields:

Sstem.o,t.print#n %9"omp"ode 59 Lstr,ct.get"omp"ode%( L 959 (;

Sstem.o,t.print#n %9"ompame 59 Lstr,ct.get"ompame%( L 959 (;

Sstem.o,t.print#n %9"it1 59 L str,ct.get"it%(L 959 (;

Sstem.o,t.print#n %9"o,ntr1 59 Lstr,ct.get"o,ntr%( L 959 (;

Sstem.o,t.print#n %9",rrenc 59 Lstr,ct.get",rrenc%( L 959 (;

Sstem.o,t.print#n %9ang,1 59 Lstr,ct.getang,%( L 959 (;

Sstem.o,t.print#n %9"$rtAccts 59 Lstr,ct.get"$rtAccts%( L 959 (;

Sstem.o,t.print#n %9Gariant 59 Lstr,ct.getGariant%( L 959 (;

Sstem.o,t.print#n %9at!ego 59 Lstr,ct.getat!ego%( L 959 (;

Sstem.o,t.print#n %9"ompan 59 Lstr,ct.get"ompan%( L 959 (;

Sstem.o,t.print#n %9Addro 59 Lstr,ct.getAddro%( L 959 (;

Sstem.o,t.print#n%( ;<catc$ %Exception ex(

Sstem.o,t.print#n%9Exception in print?etai#s%( 9 L ex( ;

<ret,rn;

<priate static oid printist%I!fc"onnection connection(

tr

  //(eclaring the parameter o#$ect:

"ompan"odeDet#istParams a"ompan"odeDet#istParams +ne' "ompan"odeDet#istParams%( ;

  //&ctual %&'I call:

"ompan"ode.get#ist%connection= a"ompan"odeDet#istParams(;

  //Splitting the parameter o#$ects into its separate components  //-Ta#le.:

3&

Page 40: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 40/51

BapiCCC>N12ab#e tab#e +a"ompan"odeDet#istParams.get"ompancodeist%(;

int ro'"o,nt + tab#e.get!o'"o,nt%( ;Sstem.o,t.print#n %9!et,rned tab#e $as 9 L ro'"o,nt L 9

#ines.9(;

  //)valuating the ta#le row #y row:

for %int i + C; i ro'"o,nt; iLL(

BapiCCC>N12ab#e!o' ro' + tab#e.get!o'%i( ;Sstem.o,t.print#n%9t9 L ro'.get"omp"ode%( L 9t9 L

ro'.get"ompame%(( ;<Sstem.o,t.print#n%( ;

<catc$ %Exception ex(

Sstem.o,t.print#n%9Exception in printist%( 9 L ex( ;<ret,rn;

<

<

Calling BAPIs &rom .isual Basic0*is is an e;am!e ro"ram #or ca!!in" a BAPI #rom =isua! Basic. 0*is reort uses t*eser'ice BAPI api"ervice.Messa%eGet!etail,  to dis!a t*e s*ort te;t and t*e !on" te;t o#error messa"es.

5

5 is,a# BASI" .C5 "oprig$t SAP AD Wa##dorf ),#i 1@@F55 read a message s$ort and #ongtext ,sing t$e BAPI

5 BAPIN&ESSADENDE2?E2AI of t$e ob0ect BapiSerice

5 constant for ,ser identification"onst cstr&-sr"#ient As String + 9CCC9"onst cstr&-sr-ser As String + 9&-SE!9"onst cstr&-srPass'ord As String + 9&PASS9"onst cstr&-srang,age As String + 9E9

5 constant for sstem identification"onst cstr&SsSstem As String + 9PQ9"onst cstr&Ss&essageSerer As String + 9pQmain.'df.sap:ag.de9"onst cstr&SsDro,pame As String + 9P-BI"955 constant a#,es for reading message texts"onst cstr&&sgId As String + 9SR9"onst cstr&&sg,mber As String + 91C19"onst cstr&&sgariab#e1 As String + 9ar19"onst cstr&&sgariab#e> As String + 9ar>9"onst cstr&&sgariab#e3 As String + 9ar39"onst cstr&&sgariab#eQ As String + 9arQ9"onst cstr&&sgang,age As String + 9?E9

5 ot$er constant

4(

Page 41: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 41/51

"onst cstr&Pat$fi#e As String + 9?Asaptext.rtf9

5 pass'ord for #ogin in !/3?im str&-srPass'ord As String

5 react on b,tton S2A!2

Priate S,b cmd&sgStartN"#ic6%(

5 define ob0ect for BAPI ActieR contro#  ?im oBAPI"tr# As Ob0ect5 define ob0ect for !/3 #ogon contro#  ?im oogon"tr# As Ob0ect5 b,siness ob0ect BapiSerice  ?im boBapiSercice As Ob0ect

5 for BAPI BapiSerice.&essageDet?etai#  ?im o&sg!et,rn As Ob0ect  ?im o&sg2ext As Ob0ect  ?im int"o,nter As Integer

5 to open t$e fi#e o, need a fi#e c$anne#  ?im int"$anne# As Integer

5 create BAPI ActieR contro# ob0ect  Set oBAPI"tr# + "reateOb0ect%9SAP.BAPI.19(5 create !/3 #ogon contro# ob0ect  Set oogon"tr# + "reateOb0ect%9SAP.ogoncontro#.19(5 connection ob0ect is part of t$e BAPI ActieR "ontro# ob0ect  Set oBAPI"tr#."onnection + oogon"tr#.e'"onnection

5 fi## #ogon parameters for sstem to ,se  oBAPI"tr#."onnection.Sstem + txtSsSstem

  oBAPI"tr#."onnection.&essageSerer + txtSs&essageSerer  oBAPI"tr#."onnection.Dro,pame + txtSsDro,pame5 fi## #ogon parameter for ,ser  oBAPI"tr#."onnection."#ient + txt-sr"#ient  oBAPI"tr#."onnection.-ser + txt-sr-ser  oBAPI"tr#."onnection.Pass'ord + str&-srPass'ord  oBAPI"tr#."onnection.ang,age + txt-srang,age

5 ,ser #ogon to !/3  If oBAPI"tr#."onnection.ogon%frmStart.$Wnd= Ga#se( + Ga#se2$en  &sgBox 9!/3 connection fai#ed9  End

  End If

5 create BAPI serice ob0ect  Set boBapiSerice + oBAPI"tr#.DetSAPOb0ect%9BapiSerice9(

5 ca## met$od of BapiSerice  boBapiSerice.&essageDet?etai# id+txt&sgId= N  ,mber+txt&sg,mber= N  ang,age+txt&sgang,age= N

 2extformat+cbo&sg2extformat.2ext= N  message+str&sgS$orttext= N  !et,rn+o&sg!et,rn= N

  2ext+o&sg2ext

5 fi## fie#d in form

41

Page 42: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 42/51

5 If txt&sgS$orttext + 99 2$en5 &sgBox 9o message read95 End If

5 ,ser #ogoff from !/3  oBAPI"tr#."onnection.ogoff

5 error $and#ing c$ec6 if !E2-! parameter is not empt andreact  If o&sg!et,rn.a#,e%92PE9( 8 99 2$en  #b#!et,rn."aption + o&sg!et,rn.a#,e%92PE9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9I?9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9-&BE!9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9&ESSADE9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9&ESSADEN19( L N

  9 . 9 L N  o&sg!et,rn.a#,e%9&ESSADEN>9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9&ESSADEN39( L N  9 . 9 L N  o&sg!et,rn.a#,e%9&ESSADENQ9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9ODNO9( L N  9 . 9 L N  o&sg!et,rn.a#,e%9ODN&SDNO9(

  E#se

5 fi## form fie#ds  txt&sgS$orttext + str&sgS$orttext  arra2ext + o&sg2ext.?ata

5 $and#ing of non !2G texts  If cbo&sg2extformat.2ext 8 9!2G9 2$en  Gor int"o,nter + 1 2o o&sg2ext.!o'"o,nt  If int"o,nter + 1 2$en  rtf&sgongtext.2ext + arra2ext%int"o,nter= 1(  E#se  rtf&sgongtext.2ext + rtf&sgongtext.2ext L N  "$r%13( L "$r%1C( L N  arra2ext%int"o,nter= 1(

  End If  ext int"o,nter  End If

5 $and#ing of !2G texts  If cbo&sg2extformat.2ext + 9!2G9 2$en5 sae text as rtf fi#e  int"$anne# + GreeGi#e  Open cstr&Pat$fi#e Gor O,tp,t As int"$anne#  Gor int"o,nter + 1 2o o&sg2ext.!o'"o,nt  Print int"$anne#= arra2ext%int"o,nter= 1(  ext int"o,nter  "#ose int"$anne#  rtf&sgongtext.oadGi#e cstr&Pat$fi#e= rtf!2G  End If  End If

4

Page 43: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 43/51

End S,b

Calling BAPIs &rom ABAP0*is reort uses t*e ser'ice BAPI api"ervice.Messa%eGet!etail,  to dis!a t*e s*ort te;tand t*e !on" te;t o# error messa"es.*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::** read a message s$ort and #ong text ,sing t$e BAPI** BAPIN&ESSADENDE2?E2AI of t$e ob0ect BapiSerice.**:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::*

'ata declaration

?A2A &NI? IME BAPI!E2>:I?=  &N-&BE! IME BAPI!E2>:-&BE!=  &N2ER2GO!&A2 IME BAPI2DA:2ER2GO!&A2=  &N&ESSADEN1 IME BAPI!E2>:&ESSADEN1=  &N&ESSADE IME BAPI!E2>:&ESSADE=  &N!E2-! 2PE BAPI!E2>.?A2A BEDI OG &N2ER2 O""-!S 1.  I"-?E S2!-"2-!E BAPI2DB.?A2A E? OG &N2ER2.

Enter %alues in o$ect

&OE 5GI5 2O &NI?. 9message id of message to read&OE 5C>Q5 2O &N-&BE!. 9message n,mber of message toread&OE 5AS"5 2O &N2ER2GO!&A2. 9text format= $ere AS"II&OE 5CCC15 2O &N&ESSADEN1. 9text to fi## into message

BAPI call

"A G-"2IO 5BAPIN&ESSADENDE2?E2AI5  ERPO!2ID  I? + &NI?  -&BE! + &N-&BE!

* AD-ADE + S:AD-  2ER2GO!&A2 + &N2ER2GO!&A2  &ESSADEN1 + &N&ESSADEN1* &ESSADEN> +* &ESSADEN3 +* &ESSADENQ +  I&PO!2ID  &ESSADE + &N&ESSADE  !E2-! + &N!E2-!  2ABES  2ER2 + &N2ER2  .

Print resultsW!I2E / 5Inp,t5 "OO! .

43

Page 44: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 44/51

W!I2E / 5mNid...........5= &NI?.W!I2E / 5mNn,mber.......5= &N-&BE!.W!I2E / 5mNtextformat...5= &N2ER2GO!&A2.W!I2E / 5mNmessageN1...5= &N&ESSADEN1.W!I2E / 5O,tp,t5 "OO! .W!I2E / 5mNmessage........5= &N&ESSADE.

W!I2E / 5mNret,rn.........5= &N!E2-!.W!I2E / 52ext o,tp,t5 "OO! .OOP A2 &N2ER2.  W!I2E / &N2ER2.E?OOP.

44

Page 45: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 45/51

+odi&2ing BAPIs

UseCou can modi# SAP Business Object tes and t*eir BAPIs@ i# ou want@ #or e;am!e@ toadd a arameter to a BAPI or add a met*od to a business object te.

FeaturesBAPIs can be modi#ied in 'arious was to suit customer needsD

12pe o& +odi&ication Furt/er In&ormation

User ;its 0*is re#ers to en*ancements to BAPIs t*at do not in'o!'emodi#cation.

For more in#ormation see User ;its.

7odi#ications For more in#ormation see )ustomer n*ancements.

)ustomeren*ancements For more in#ormation see )ustomer n*ancements.For detai!ed in#ormation about im!ementin" andro"rammin" BAPIs see BAPI Pro"rammin".

User E6its

UseBAPIs can contain rede#ined user e;its enab!in" a!ication de'e!oers to en*ance BAPIinter#aces wit*out modi#ications.

FeaturesUser e;its are im!emented usin" seci#ic standardi+ed arameters w*ic* are used ascontainers to trans#er t*e data.

BAPIs can ro'ide standard or secia! user e;its.

(tandard User E6its

Standard user e;its are en*ancements to BAPI inter#aces t*at a!!ow customers to modi#t*e ro"ram code in a )AEE )US0O72 FU:)0IO: command.

In t*is case t*e container arameter #or trans#errin" t*e data is ca!!ed E#tension: @ w*ere :  is a number. Se'era! e;tension arameters ma be ro'ided in one inter#ace@ so t*at t*e

same arameters can be used #or imortin" and e;ortin" data@ #or e;am!e.

0*rou"* e;tension arameters aends as we!! as structured data and unstructured datacan be incororated into a BAPI.

 An SAP BAPI wit* t*is te o# user e;its cou!d !ook !ike t*is@ #or e;am!eD

Inter&ace

BAPINOb0ect8N&et$od8

Parameter1 IME Str,ct,re1:Gie#d1 Import Gie#dParameter> IME Str,ct,re1:Gie#d> Import Gie#dParameter3 IME Str,ct,re> Export Str,ct,reParameterQ IME Str,ct,re>:Gie#d3 Export Gie#d

Parameter IME Str,ct,re3 Imp/Ex. tab#e....

4-

Page 46: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 46/51

ER2ESIO1 IME "ontainer str,ct,re8Import Str,ct,reER2ESIO> IME "ontainer Str,ct,re8Imp/Ex. tab#e

...

Program code

G,nction BAPINOb0ect8N&et$od8

...GormParam + Parameter1...Gorm2ab#e + Parameter...Parameter3+ 5"ontent5..."A "-S2O&E!:G-"2IO Tt$ree digit n,mber8U

%Interface as aboe(....

endf,nction

Function +odule 3ame

0*e customerseci#ic #unction is ca!!ed usin" t*e command )AEE )US0O72FU:)0IO:. 0*is #unction modu!e must *a'e t*e namin" con'entionLI0Qmoule pool nameRQthree i%it number R.

(pecial User E6its

0*ese are standardi+ed en*ancements to BAPI inter#aces #or w*ic* customers do not*a'e to c*an"e t*e ro"ram code. In t*is case t*e container arameter #or t*e datatrans#er *as t*e namin" con'entionD

E#tension'name*@ w*ere 'Name* describes t*e te o# en*ancement.

For e;am!e@ t*e container arameter E#tension2rer  cou!d be used in t*e0ab!e "ALE" $sa!es order master data% o# t*e associated BAPI #or t*ecustomer I:)EU5 C-;"ALE". 

Furt/er In&ormation

For #urt*er in#ormation see 5e#inin" User ;its in BAPIs in BAPI Pro"rammin".0*e standard ru!es #or user e;its a! and maintenance wit* 0ransaction S&O? $SAP

interna! de'e!oment% and "&O? $customer de'e!oment%. 2e#er a!so to t*e documentation

on SAP n*ancement 7ana"ement $S&O?% and to B) n*ancin" t*e SAP Standard $"&O?%.

46

Page 47: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 47/51

Customer En/ancements

Purpose)ustomers can modi# an e;istin" BAPI or de'e!o t*eir own BAPIs@ i# re>uired.

Process FlowBe#ore ou decide to modi# an SAP BAPI@ #ami!iari+e ourse!# wit* t*e "enera! rocedure#or makin" customer en*ancements to t*e SAP standard sstem. For more in#ormationre#er to t*e document B) n*ancements to t*e SAP Standard. For #urt*er in#ormationsee a!so Guide!ines #or 7odi#in" t*e SAP Standard Sstem in SAPnet.

0*is document does not co'er en*ancements to t*e SAP Standard@ it dea!s seci#ica!!wit*D

  BAPI modi#ications

For #urt*er in#ormation see n*ancments B 7odi#ications.

  BAPI 5e'e!oment

For #urt*er in#ormation see )ustomer 5e'e!oment.

Once ou *a'e made t*e re>uired modi#ication to t*e #unction modu!e@ or *a'e createdour own #unction modu!e@ assi"n it as a met*od to t*e re!e'ant business object te in t*eBusiness Object 2eositor usin" t*e BO2?BAPI 8i+ard. For #urt*er in#ormation about t*eBO2?BAPI 8i+ard see 5e#inin" 7et*ods in t*e BO2 Usin" t*e BO2?BAPI 8i+ard.

I# t*e modi#ication *as a!read been assi"ned to t*e #unction modu!e in t*e BO2@ it doesnot *a'e to be assi"ned a"ain. 0*e e;cetion is t*e creation o# subtes@ seen*ancements 0*rou"* 7odi#ication.

En/ancements 1/roug/ +odi&ication

Purpose)ustomers can make modi#ications to e;istin" BAPIs@ #or e;am!e@ i# new arameters orarameter #ie!ds are needed.

Process FlowI# a BAPI modi#ication is needed@ we recommend t*at ou create a subte o# t*ebusiness object in >uestion and make t*e c*an"es to t*e subte. 0*en ou *a'e toascertain t*e de!e"ation re!ations*i between t*e ori"ina! SAP Business Object te$suerte% and t*e subte.

In t*is wa t*e SAP Standard de!i'ered to customers is not c*an"ed and t*e modi#icationscarried out are retained w*en t*e 2e!ease is u"raded. 0*is rocedure a!so enab!esBAPIs to be modi#ied in stes because #urt*er subordinate subtes o# a business objectcan be created.

Fo!!ow t*e Guide!ines #or 7odi#in" t*e SAP Standard Sstem w*en creatin" newde'e!oment objects in t*e conte;t o# modi#ications. A!so@ make sure t*at t*e re!e'antde'e!oment objects are assi"ned a name #rom t*e customer namesace. For #urt*erin#ormation see :amesaces.

Creating and Rede&ining (ut2pes

0o create a subteD

1. )*oose /ools → usiness $rame3ork  → AP- !evelopment → usiness 2b)ectuiler or enter t*e transaction code SWO1.

4

Page 48: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 48/51

. In t*e #ie!d 2b)ect type enter t*e name o# t*e subte ou want to create and s!eetCreate.

3. In t*e ne;t dia!o" bo;@ enter t*e re>uired detai!sD

  In t*e #ie!d "upertype enter t*e name o# t*e object te #or w*ic* ou want to

create a subte.

  In t*e #ie!d 2b)ect type enter t*e name o# t*e subte ou want to create

and enter aroriate 'a!ues in t*e remainin" #ie!ds.

0*en rede#ine t*e subte.

1. )*oose /ools → usiness $rame3ork  → AP- !evelopment → usiness 2b)ect

uiler or enter t*e transaction code SWO1.

. 5is!a t*e subte just created in t*e c*an"e mode.

3. P!ace t*e cursor on t*e BAPI ou want to modi# and c*oose Process → Reeine.

4. 5oub!ec!ick on t*e BAPI and se!ect t*e re"ister ABAP?4.

-. In t*e #ie!d Name, enter t*e name o# t*e modi#ied #unction modu!e.

6. Sa'e our entries.

'e&ining t/e 'elegation Relations/ip Between #$ect 12pe !(upert2pe"and (ut2pe

0o de#ine t*e de!e"ation re!ations*i between t*e suerte and subteD

1. )*oose /ools → usiness $rame3ork  → AP- !evelopment → usiness 2b)ect

uiler or enter t*e transaction code SWO1.

. )*oose "ettin%s → !ele%ate → "ystem(3ie. 

3. Switc* to t*e c*an"e mode and se!ect Ne3 entries. 

4. nter t*e name o# t*e ori"ina! object te $suerte% in t*e #ie!d 2b)ect type andt*e name o# t*e subobject te in t*e #ie!d !ele%ation type. 5eacti'ate t*e c*eckbo; G&-(speciic. 

-. Sa'e our entries.

For #urt*er in#ormation on creatin" business objects re#er to t*e documentation on SAPBusiness 8ork#!ow.

I# "!oba! data is de#ined or #orm routines are ca!!ed in t*e #unction "rouassociated wit* a BAPI #unction modu!e@ ou ma *a'e to a!so co t*esedata dec!arations and #orm routines to ensure our co o# t*e BAPI can bee;ecuted.

0*e BAPI Material.GetList  #or t*e Business Object Material  s*ou!d containadditiona! arameters. 0*e #unction modu!e associated wit* t*is BAPI isAP-;MA/ER-AL;GE/L-"/ .

)ustomers s*ou!d #irst create a subte <Material  o# t*e e;istin" businessobject Material  in t*e BO2. 0*e wi!! a!so note t*at met*od ca!!s o# t*e

4/

Page 49: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 49/51

business object <Material  #or t*e ori"ina! object te Material are to berocessed@ ro'ided t*at t*e associated met*od is im!emented t*ere . 0*is isdescribed as de!e"ation. $For a!! met*ods t*at are not im!emented #or t*esubte <material @ t*e met*od ca!! is e;ecuted #rom t*e suerordinatebusiness object@ Material.8 

)ustomers make t*e necessar c*an"es in t*e source code o# t*e #unctionmodu!e BAPI7A02IAEG0EIS0@ and makes c*an"es to t*e inter#ace bcreatin" new@ optional arameters. :e;t@ customers create t*e met*odGetList  #or t*e subte <Material  usin" t*e BO2?BAPI 8i+ard. 0*e met*od is!inked to t*e #unction modu!e BAPI7A02IAEG0EIS0@ w*ere t*e newarameters are inc!uded as art o# t*e met*od de#inition. I#@ on t*e ot*er *and@t*e inter#ace is en*anced wit* new@ mandator2 arameters@ a new #unctionmodu!e must be created and assi"ned to t*e met*od <Material.GetList. $)ustomers can a!so co t*e modu!e BAPI7A02IAEG0EIS0@ #ore;am!e@ to CBAPI7A02IAEG0EIS0@ and t*en edit t*is co.

 At runtime t*e #o!!owin" rocess takes !aceD

  8*en t*e BAPI Material.GetList @ t*e BAPI <Material.GetList  is t*e one

actua!! e;ecuted.

In t*e case o# a!! ot*er met*od ca!!s@ t*e met*ods o# t*e suerordinate

business object@ Material  are e;ecuted@ because t*ese are notim!emented #or t*e subte <Material .

Customer 'e%elopments

PurposeUsin" t*e in#ormation in t*ese BAPI Pro"rammin" "uide!ines ou can create new met*ods

#or business objects.

Process FlowI# ou are de'e!oin" a new BAPI@ we recommend t*at ou create subte o# t*e BAPI in>uestion and assi"n t*e new BAPI to t*is subte. For #urt*er in#ormation seen*ancements 0*rou"* 7odi#ication and in t*e documentation on SAP Business8ork#!ow.

In t*is wa t*e SAP Standard de!i'ered to customers is not c*an"ed and t*e newde'e!oments are retained w*en t*e 2e!ease is u"raded.

7ake sure t*at ou assi"n a name #rom t*e customer namesace to t*e new object andits met*od in t*e BO2 and to t*e #unction modu!e in t*e Function Bui!der $see

:amesaces%.

Fo!!ow t*e Guide!ines #or 7odi#in" t*e SAP Standard Sstem w*en creatin" ot*erre>uired de'e!oment objects.

Fo!!owin" on #rom t*e e;am!e in n*ancements 0*rou"* 7odi#ication@ anadditiona! met*od <Get!etail  s*ou!d be created #or t*e subte <Material  o#t*e business object te Material. 0*e #unction modu!e associated wit* t*isBAPI is <;AP-;MA/ER-AL;GE/!E/A-L.

)ustomers s*ou!d create t*e new met*od <Get!etail  o# t*e business object

<Material  usin" t*e BO2?BAPI 8i+ard. 0*is met*od is associated wit* t*e#unction modu!e <;AP-;MA/ER-AL;GE/!E/A-L.

4&

Page 50: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 50/51

 At runtime@ w*en t*e BAPI Material.<Get!etail  is ca!!ed@ t*e BAPI<Material.<Get!etail  is actua!! im!emented due to t*e de!e"ation ointer int*e business object Material.

3amespaces

'e&inition0*e namesace concet describes *ow customers and artners *a'e to name t*eirde'e!oment objects to a'oid o'er!ain" w*en SAP so#tware is u"raded. 

)ustomers and artners can create t*eir own de'e!oment objects@ #or e;am!e@ to

im!ement a new BAPI or to modi# an e;istin" BAPI. For #urt*er in#ormation see)ustomer 7odi#ications and 5e'e!oments.

In 2?3 2e!ease 3.1 t*e namesaces C and T were ro'ided #or customers@ and t*enamesace <QnumberR was reser'ed #or artners.

In 2?3 2e!ease 4.( a new namesace concet was introduced w*ic*@ to"et*er wit* t*e!on"er de'e!oment object names@ made it easier to assi"n names to objects de'e!oedb customers and artners.

0*e Business Object 2eositor $BO2% introduced be#ore 2?3 2e!ease 4.( sti!! uses t*eo!d namesace concet. For t*is reason t*e !imitations o# t*e o!d namesace concet sti!!a! to t*e namesaces #or BAPI de'e!oment objects.

Reser%ed 3amespaces &or t/e .arious Application Groups

User Pre&i6

Industria! Business Units$IBUs%

One o# t*e otions be!owD

• IS #6 @ w*ere  #6  can be an !etter.

• Use our own uni>ue namesace a#ter a"reein" it

wit* t*e centra! BO2 coordination.

•  A"ree t*e name wit* standard de'e!oment.

Ot*er de'e!oments wit*inSAP

For e;am!e@ M<P:N #or de'e!oments in t*e <aanesearea.

Partners?so#tware *ouses • < y6  $w*ere N is a sin"!e di"it a!!ocated

namesace% #or artners?so#tware *ouses w*osenamesaces were assi"ned e&ore 2e!ease 4.(.

• <<'Namespace*6  $w*ere QNamespaceR is t*e

re"istered namesace% #or artners?so#tware*ouses w*ose namesaces were assi"ned a&ter  2e!ease 4.(@ #or e;am!e@ <<AB).

)ustomers C and T@ #or #unction modu!es matc*in" C andT.

I# a customer or artner creates a new object te t*at is not a subte o# anot*er objectte@ t*e namin" con'ention #or t*is object te a!ies to a!! t*e subobjects. In rinci!e@

-(

Page 51: Apostila BAPI

8/20/2019 Apostila BAPI

http://slidepdf.com/reader/full/apostila-bapi 51/51

t*ere#ore@ SAP objects cannot o'er!a wit* eac* ot*er@ re"ard!ess o# t*e names o# t*emet*ods@ attributes and so on.

Subobject tes s!it t*e namesace #or met*ods@ attributes and so on wit* t*esuerordinate object te. Cou must #o!!ow t*e namin" con'entions #or t*e subobjects too.

3aming Con%entions &or BAPI 'e%elopment #$ects'e%elopment #$ect Created in888 3aming Con%ention

5omain ABAP 5ictionar Standard in t*e resecti'e 2?3 2e!ease

5ata !ement ABAP 5ictionar Standard in t*e resecti'e 2?3 2e!ease

Structure ABAP 5ictionar   'Prei#*AP-= 

Fie!d in structures ABAP 5ictionar

 Aend structure ABAP 5ictionar Standard in t*e resecti'e 2?3 2e!ease

Function "rou Function Bui!der Standard in t*e resecti'e 2?3 2e!ease

Function 7odu!e Function Bui!der     'Prei#*AP-  Q2b)ect RQMetho R

Function modu!earameter 

Function Bui!der    'Pr>i#*= @ e;cet #or arameters incustomers #unction modu!es

Object te BO2   'Prei#*= 

Object name BO2   'Prei#*= 

 Attribute name BO2   'Prei#*= 

7et*od BO2   'Prei#*@ e;cet #or modi#icationsusin" de!e"ation@ ot*erwise de!e"ationdoes not work.

7et*od arameters BO2 QFunction modu!e arameterR