Está en la página 1de 4

3/3/13

SAP Community Network Wiki - ABAP Development - Business Transaction Event - RWBAPI01 - For Accounting Document Interface
Welcome, Guest Login Register Getting Started Newsletters Store

Solutions Services & Support About SCN Downloads Industries Training & Education Partnership Developer Center Lines of Business University Alliances Events & Webinars Innovation

Business Transaction Event - RWBAPI01 - For Accounting Document Interface


Added by Vinod Kumar, edited by Moshe Naveh on Jul 22, 2010

You are viewing an old version of this page. View the current version.
Compare with Current | View Page History
<< Previous Version 8 Next >>

Business Transaction Event - RWBAPI01 - For Accounting Document Interface


Link to Content's target Space :
http://w iki.sdn.sap.com/w iki/display/ABAP/BTE+-+Business+Transaction+Event

Useful Inform ation Short quick summary to catch the reader's attention and of course the search engine

Applies to:
SAP 4.7x and above.

BTE, RWBAPI01, BAPI_ACC_DOCUMENT_POST, Business Transaction Events, FICO, FI

Summary
While Creating the Accounting document through BAPI - BAPI_ACC_DOCUMENT_POST posting keys are determined automatically based on the configuration. Since this BAPI doesn't have any structure field to pass the posting key, posting keys are picked up automatically based on the document type passed in BAPI header structure. This document narrates how to change the default posting key w hile creating the Accounting document using the above BAPI. This document also explains the steps involved in implementing a Business Transaction Event.

Author(s): Vinod Kumar T

Com pany: Created on:

NIIT Technologies Limited 20.07.2010

Author(s) Bio Vinod Kumar is an ABAP Consultant w orking w ith NIIT Technologies Limited.

Posting of Accounting Document Using BAPI - BAPI_ACC_Document Post


Scenario
Create the accounting document for Customer advance payment against Net-banking transaction. Document is to be created w ith the accounting document type (DZ-Customer Payment). Based on the Configuration, Customer line item is posted against the posting key 01(Invoice-Debit) and GL Account line item is posted against the posting key 50(GL-Credit). Since the FI documents of customer payment and Advance payment is to be separated, Customer line item of above entries are to be posted w ith posting key 04 (Other Receivables - Debit) and GL Account line item to be posted w ith posting key 50 (GL - Credit)

Additional Structure for BAPI


For passing the additional data related to posting keys, Structure EXTENSION1 is to be filled w ith the required data. Business Transaction Event used for changing the Posting key w ill be executed only w hen the record(s) are available in this structure. See the Call to BTE in line number 59 of BAPI.

Code for Creating Account document using BAPI

wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=195726664

1/4

3/3/13

Code for Creating Account document using BAPI


0 0 1 . 0 0 2 . 0 0 3 . 0 0 4 . 0 0 5 . 0 0 6 . 0 0 7 . 0 0 8 . 0 0 9 . 0 1 0 . 0 1 1 . 0 1 2 . 0 1 3 . 0 1 4 . 0 1 5 . 0 1 6 . 0 1 7 . 0 1 8 . 0 1 9 . 0 2 0 . 0 2 1 . 0 2 2 . 0 2 3 . 0 2 4 . 0 2 5 . 0 2 6 . 0 2 7 . 0 2 8 . 0 2 9 . 0 3 0 . 0 3 1 . 0 3 2 . 0 3 3 . 0 3 4 . 0 3 5 . 0 3 6 . 0 3 7 . 0 3 8 . 0 3 9 . 0 4 0 . 0 4 1 . 0 4 2 . 0 4 3 . 0 4 4 . 0 4 5 . 0 4 6 . 0 4 7 . 0 4 8 . 0 4 9 . 0 5 0 . 0 5 1 . 0 5 2 . 0 5 3 . 0 5 4 . 0 5 5 . 0 5 6 . 0 5 7 . 0 5 8 . 0 5 9 . 0 6 0 . 0 6 1 . 0 6 2 . 0 6 3 . 0 6 4 . 0 6 5 . 0 6 6 . 0 6 7 . 0 6 8 . 0 6 9 . 0 7 0 . 0 7 1 . 0 7 2 . 0 7 3 . 0 7 4 . 0 7 5 . 0 7 6 . 0 7 7 . 0 7 8 . 0 7 9 . 0 8 0 . 0 8 1 . 0 8 2 . 0 8 3 . 0 8 4 . 0 8 5 . 0 8 6 . 0 8 7 . 0 8 8 . 0 8 9 . 0 9 0 . 0 9 1 . 0 9 2 . 0 9 3 . 0 9 4 . 0 9 5 . 0 9 6 . 0 9 7 . 0 9 8 . 0 9 9 . 1 0 0 . 1 0 1 . 1 0 2 . 1 0 3 . 1 0 4 . 1 0 5 . 1 0 6 . 1 0 7 .

SAP Community Network Wiki - ABAP Development - Business Transaction Event - RWBAPI01 - For Accounting Document Interface

R E P O R T z a c c t e s t i n g . * *I n t e r n a lt a b l ea n dW o r ka r e ad e c l a r a t i o n s D A T A:w a _ d o c u m e n t h e a d e r T Y P Eb a p i a c h e 0 9 , i t _ a c c o u n t g l T Y P ES T A N D A R DT A B L EO Fb a p i a c g l 0 9 , w a _ a c c o u n t g l T Y P Eb a p i a c g l 0 9 , i t _ a c c o u n t r e c e i v a b l eT Y P ES T A N D A R DT A B L EO Fb a p i a c a r 0 9 , w a _ a c c o u n t r e c e i v a b l eT Y P Eb a p i a c a r 0 9 , i t _ c u r r e n c y a m o u n t T Y P ES T A N D A R DT A B L EO Fb a p i a c c r 0 9 , w a _ c u r r e n c y a m o u n t T Y P Eb a p i a c c r 0 9 , i t _ r e t u r n T Y P ES T A N D A R DT A B L EO Fb a p i r e t 2 , w a _ r e t u r n T Y P Eb a p i r e t 2 , i t _ e x t e n s i o n 1 T Y P ES T A N D A R DT A B L EO Fb a p i a c e x t c , w a _ e x t e n s i o n 1 T Y P Eb a p i a c e x t c . D A T A:d o c _ a m t _ c r d o c _ a m t _ d r D A T A : l v _ t y p e l v _ k e y l v _ s y s T Y P Eb a p i w r b t rV A L U E' 5 0 . 0 0 ' , T Y P Eb a p i w r b t rV A L U E' 5 0 . 0 0 ' . T Y P Eb a p i a c h e 0 9 o b j _ t y p e , T Y P Eb a p i a c h e 0 9 o b j _ k e y , T Y P Eb a p i a c h e 0 9 o b j _ s y s .

* *c l e a ri n t e r n a lt a b l e R E F R E S H: i t _ a c c o u n t g l , i t _ a c c o u n t r e c e i v a b l e , i t _ c u r r e n c y a m o u n t , i t _ r e t u r n , i t _ e x t e n s i o n 1 . * *F i l lh e a d e rd a t a . C L E A R:w a _ d o c u m e n t h e a d e r . M O V Es y u n a m e T Ow a _ d o c u m e n t h e a d e r u s e r n a m e . " U s e r n a m e " M O V E' T e s t ' T Ow a _ d o c u m e n t h e a d e r h e a d e r _ t x t . " H e a d e rT e x t " M O V E' 0 1 0 3 ' T Ow a _ d o c u m e n t h e a d e r c o m p _ c o d e ." C o m p a n yC o d e " M O V Es y d a t u m T Ow a _ d o c u m e n t h e a d e r d o c _ d a t e . " D o cD a t e " M O V Es y d a t u m T Ow a _ d o c u m e n t h e a d e r p s t n g _ d a t e . " P o s t i n gD a t e " M O V E' D Z ' T Ow a _ d o c u m e n t h e a d e r d o c _ t y p e . " D o cT y p e " M O V E' T e s t ' T Ow a _ d o c u m e n t h e a d e r r e f _ d o c _ n o . " R e f e r e n c e " M O V E' R F B U ' T Ow a _ d o c u m e n t h e a d e r b u s _ a c t . M O V E' B K P F F ' T Ow a _ d o c u m e n t h e a d e r o b j _ t y p e . " C o m m e n tf o r> =E C C 5 . 0 M O V E' $ ' T Ow a _ d o c u m e n t h e a d e r o b j _ k e y . " C o m m e n tf o r> =E C C 5 . 0 M O V Es y m a n d t T Ow a _ d o c u m e n t h e a d e r o b j _ s y s . " C o m m e n tf o r> =E C C 5 . 0 * * F i l lG LA c c o u n tL i n ei t e m . C L E A R:w a _ a c c o u n t g l ,w a _ c u r r e n c y a m o u n t . M O V E' 0 0 0 0 0 0 0 0 0 1 'T Ow a _ a c c o u n t g l i t e m n o _ a c c . " L i n eI t e mN o " M O V E' 0 0 1 4 0 0 0 0 4 1 'T Ow a _ a c c o u n t g l g l _ a c c o u n t . " G / LA c c o u n t " M O V E' I t e m T e s t ' T Ow a _ a c c o u n t g l i t e m _ t e x t . " I t e mT e x t " M O V E' 0 1 0 3 ' T Ow a _ a c c o u n t g l c o m p _ c o d e . " C o m p a n yC o d e " M O V E' 0 0 0 0 9 0 0 3 9 0 'T Ow a _ a c c o u n t g l p r o f i t _ c t r . " P r o f i tC e n t e r " M O V E' A s s i g n 1 ' T Ow a _ a c c o u n t g l a l l o c _ n m b r . " A s s i g n m e n t " A P P E N Dw a _ a c c o u n t g lT Oi t _ a c c o u n t g l . M O V E' 0 0 0 0 0 0 0 0 0 1 'T Ow a _ c u r r e n c y a m o u n t i t e m n o _ a c c . " L i n eI t e mN o " M O V E' 0 0 ' T Ow a _ c u r r e n c y a m o u n t c u r r _ t y p e . " C u r r e n c yT y p e " M O V E' I N R ' T Ow a _ c u r r e n c y a m o u n t c u r r e n c y . " C u r r e n c y " M O V Ed o c _ a m t _ c r T Ow a _ c u r r e n c y a m o u n t a m t _ d o c c u r ." A m o u n t " A P P E N Dw a _ c u r r e n c y a m o u n tT Oi t _ c u r r e n c y a m o u n t . * *F i l lC u s t o m e rL i n ei t e m C L E A R: w a _ a c c o u n t r e c e i v a b l e ,w a _ c u r r e n c y a m o u n t . M O V E' 0 0 0 0 0 0 0 0 0 2 'T Ow a _ a c c o u n t r e c e i v a b l e i t e m n o _ a c c ." I t e mN o " M O V E' 0 0 0 1 0 0 0 0 7 6 'T Ow a _ a c c o u n t r e c e i v a b l e c u s t o m e r . " C u s t o m e r " M O V E' I t e m T e s t ' T Ow a _ a c c o u n t r e c e i v a b l e i t e m _ t e x t . " I t e mT e x t " M O V E' 0 1 0 3 ' T Ow a _ a c c o u n t r e c e i v a b l e c o m p _ c o d e . " C o m p a n yC o d e " M O V E' A s s i g n 2 ' T Ow a _ a c c o u n t r e c e i v a b l e a l l o c _ n m b r ." A s s i g n m e n t . A P P E N Dw a _ a c c o u n t r e c e i v a b l eT Oi t _ a c c o u n t r e c e i v a b l e . M O V E' 0 0 0 0 0 0 0 0 0 2 'T Ow a _ c u r r e n c y a m o u n t i t e m n o _ a c c . " L i n eI t e mN o " M O V E' 0 0 ' T Ow a _ c u r r e n c y a m o u n t c u r r _ t y p e . " C u r r e n c yT y p e " M O V E' I N R ' T Ow a _ c u r r e n c y a m o u n t c u r r e n c y . " C u r r e n c y " M O V Ed o c _ a m t _ d r T Ow a _ c u r r e n c y a m o u n t a m t _ d o c c u r ." A m o u n t " A P P E N Dw a _ c u r r e n c y a m o u n tT Oi t _ c u r r e n c y a m o u n t . * * F i l lE x t e n s i o n 1S t r u c t u r eu s e db yB T E * * P o s t i n gk e yi st ob ec h a n g e df o ro n l yf o rC u s t o m e rl i n ei t e m( 0 0 0 0 0 0 0 0 0 2 ) * * R e c o r d si nt h i si n t e r n a lt a b l ew i l lb ec h e c k e di nB T E C L E A R:w a _ e x t e n s i o n 1 . M O V E' 0 0 0 0 0 0 0 0 0 2 0 4 'T Ow a _ e x t e n s i o n 1 f i e l d 1 . A P P E N Dw a _ e x t e n s i o n 1T Oi t _ e x t e n s i o n 1 . * *C a l lB a p i C A L LF U N C T I O N' B A P I _ A C C _ D O C U M E N T _ P O S T ' E X P O R T I N G d o c u m e n t h e a d e r =w a _ d o c u m e n t h e a d e r I M P O R T I N G " C o m m e n tf o r> = E C C 5 . 0 o b j _ t y p e =l v _ t y p e " C o m m e n tf o r> = E C C 5 . 0 o b j _ k e y =l v _ k e y " C o m m e n tf o r> = E C C 5 . 0 o b j _ s y s =l v _ s y s " C o m m e n tf o r> = E C C 5 . 0 T A B L E S a c c o u n t g l =i t _ a c c o u n t g l a c c o u n t r e c e i v a b l e=i t _ a c c o u n t r e c e i v a b l e c u r r e n c y a m o u n t =i t _ c u r r e n c y a m o u n t e x t e n s i o n 1 =i t _ e x t e n s i o n 1 r e t u r n =i t _ r e t u r n . * *C h e c kf o re r r o r s . C L E A R:w a _ r e t u r n . R E A DT A B L Ei t _ r e t u r nI N T Ow a _ r e t u r nW I T HK E Yt y p e=' E ' . I Fs y s u b r cN E0 . C A L LF U N C T I O N' B A P I _ T R A N S A C T I O N _ C O M M I T ' . E N D I F . * *d i s p l a yt h eo u t p u t L O O PA Ti t _ r e t u r nI N T Ow a _ r e t u r n . W R I T E: /w a _ r e t u r n t y p e , w a _ r e t u r n i d , w a _ r e t u r n n u m b e r , w a _ r e t u r n m e s s a g e . E N D L O O P .

wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=195726664

2/4

3/3/13

SAP Community Network Wiki - ABAP Development - Business Transaction Event - RWBAPI01 - For Accounting Document Interface

Implementing Business Transaction Event - RWBAPI01


Code for BTE Function Module
Step 1: Create a New function group using transaction code SE80 Step 2: Copy the standard function module of BTE "SAMPLE_INTERFACE_RWBAPI01" to a Z Function module, say "ZSAMPLE_INTERFACE_RWBAPI01" Step 3: Add Follow ing Code into the new function module and activate 0 1 . 0 2 . 0 3 . 0 4 . 0 5 . 0 6 . 0 7 . 0 8 . 0 9 . 1 0 . 1 1 . 1 2 . 1 3 . 1 4 . 1 5 . 1 6 . 1 7 . 1 8 . 1 9 . 2 0 . 2 1 . 2 2 . F U N C T I O Nz s a m p l e _ i n t e r f a c e _ r w b a p i 0 1 . * " * " * " L o c a lI n t e r f a c e : * " T A B L E S * " I T _ A C C I TS T R U C T U R E A C C I T * " I T _ A C C C RS T R U C T U R E A C C C R * " R E T U R NS T R U C T U R E B A P I R E T 2 * " E X T E N S I O NS T R U C T U R E B A P I A C E X T C * " I T _ A C C W TS T R U C T U R E A C C I T _ W T * " C H A N G I N G * " V A L U E ( D O C U M E N T _ H E A D E R )L I K E A C C H DS T R U C T U R E A C C H D * " D A T A:w a _ e x t e n s i o nT Y P Eb a p i a c e x t c . C L E A R :w a _ e x t e n s i o n . L O O PA Te x t e n s i o nI N T Ow a _ e x t e n s i o n . R E A DT A B L Ei t _ a c c i tW I T HK E Yp o s n r=w a _ e x t e n s i o n f i e l d 1 ( 1 0 ) . I Fs y s u b r cE Q0 . i t _ a c c i t b s c h l=w a _ e x t e n s i o n f i e l d 1 + 1 0 ( 2 ) . M O D I F Yi t _ a c c i tI N D E Xs y t a b i x . E N D I F . E N D L O O P . E N D F U N C T I O N .

Configuration
Step 1: Go To Transaction code FIBF Step 2: Add Customer Product. Use Menu Option : Settings -> Products -> ...of a Customer

Step 3: Save the Product. Step 4: Create a Link betw een BTE and Product created in Step2. Use the menu option : Settings -> Process Modules -> ... of a customer

Step 5: Save the Link.

Summary
When the BAPI is executed, Code w ritten in the BTE - function module w ill be executed and the posting key of related line item w ill be changed before posting the documents.

Related Content
https://forums.sme.sap.com/message.jspa?messageID=8284886 http://forums.sdn.sap.com/message.jspa?messageID=9288661 http://forums.sdn.sap.com/thread.jspa?threadID=999473

wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=195726664

3/4

3/3/13

SAP Community Network Wiki - ABAP Development - Business Transaction Event - RWBAPI01 - For Accounting Document Interface

Follow SCN Contact Us SAP Help Portal Privacy Terms of Use Legal Disclosure Copyright

wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=195726664

4/4

También podría gustarte