Você está na página 1de 12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

SAP CRM Technical Tutorials by Naval Bhatt.


SAP CRM tutorials for all : Please feel free to contact me on naval.k.bhatt@gmail.com. This blog is for helping those who are facing issues in CRM technical and functional . Not for career counselling , Please refrain from sending those questions . Please do some research before asking any question . Please don't copy and paste the requirements which you get from your client . YOUR URGENCY IS NOT MY PROBLEM :-) I will take my sweet time in replying . Home My Intro SAP Job Websites Document pdfs ... Middleware concepts ...

Basics of OOABAP... Interview Questions ....

Practical BOL programming ..

SAP CRM related links ...

Sunday, August 26, 2012

Search

Extend BOL Model BT with custom table type relationship

Followers:Join to get regular update


Join this site
w ith Google Friend Connect

Link to Content's target Space :


http://w iki.sdn.sap.com /w iki/display/CRM/CRM+Web+Client+UI+Fram ew ork

Members (82) More

Applies to:
SAP CRM 6.0/7.0

Summary
Extend the standard BOL m odel BT w ith a custom relationship to accom odate your z-table.

Intro

Already a member? Sign in There's been a few discussions in the forum s about finding a w ay to add a custom table to the standard BOL m odels. It's a bit tricky, but possible. In this WIKI, I w ill show

you how to enhance the BOl m odel BT w ith a new 1..n relationship. The advantages are obvious. Any change in your custom data w ill register in the BOl layer, you w ill be abl to capture the BOl Core Reset and Order Init(revert) events, use the BOL m odel node w izards etc., Enhancing a few standard classes are in order. So, know ing how to enhance the m ethods using the im plicit enhancem ent points is necessary.

My other blogs SAP BPM & Workflow tutorials My travel experiences Me & my pursuit of happiness Wandering hermit Photography

In this exam ple, w e w ill create the relationship under the adm inistration header(BTAdm inH). Actually, tw o relationships. One w ill be a read only relationship(sim iliar to BTItem s) that is linked and the other w ill be the 1..n relation that corresponds to your database. My custom database ZORD has the follow ing fields. CLIENT GUID REF_GUID NOTE type MANDT "Client

type CRMT_OBJECT_GUID "guid of table entry(key) type CRMT_OBJECT_GUID "guid of order object "end-user usable type CHAR120 "end-user usable

EXTERN_CASE_NO type CRMT_OBJECT_ID

A structure 'ZORD_STRUCT' that corresponds to the table structure and a table type 'ZORD_STRUCT_TAB' is available.

Step 1 : Studying the event handler model

Join me on my photography journey


Naval Bhatt Photography .. on Facebook

Maintain API Object Name


Blog Archive 2014 (2) 2013 (57) 2012 (155)
us to define our ow n transaction events.

In transaction CRMC_OBJECTS, m aintain the API object nam e of our custom object. In our case, the nam e is ZORD. This inform ation w ill be used further below . This w ill allo

Maintain Object dependency

December (2)as a sub-object of figure out if your scenario needs this or not. For exam ple, if you are extending only the opportunity transaction type, declare ZORD
Opportunity(BUS2000111). Maintain this inform ation in view m aintenance CRMV_OBJECT_ASSI

This step is to ensure that the transaction events w hich w e w ill be defining later on, w ill be called only w hen necessary. This step is optional and you should be able to

November (8) October (1) September (15)

Identify positions for defining custom events for transactions


http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

We w ill have to define three basic events in the transaction event m odel that w ill take care of our custom objects. These are

1/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship
We w ill have to define three basic events in the transaction event m odel that w ill take care of our custom objects. These are

August (14) Extend BOL Model BT with custom table type relatio...

1. Initialization -> When the order is being initialized say, during lock/revert scenarios, w e w ant our object to be initialized too. 2. Save -> When the order is being saved, save our data too. 3. Delete -> When the order is deleted, w e need to delete corresponding data from our custom table

For this, you m ust identify the correct places to insert our event callback function m odules. If not already done, set your user param eterCRM_EVENT_TRACE to "X". Next, do Extend BOL som ething say, create transactions, m odify it, save it and delete it. After each action, look at the events raised in transaction Study this data carefully Model CRMD_EVENT_TRACE. for BP and decide on the points in w hich to insert your event callback function m odules. For creating the FMs(the signature with part),Custom look at the standard FMs (they end w ith *_EC) defined for the sam e event in the trace data. Create em pty FMs for each of the three events m entioned and study theTable trace again. and We w ill be calling our custom API class' m ethods inside these FMs. We w ill cover this later. For now , create entries in the transaction event handler table andImpl... ensure that the FMs are getting called in the correct places for various scenarios.

How to use your Object for webclient wi...

custom BOL For exam ple, if I'm extending the Opportunity m odel, I w ill create these entries - In SPRO, go to CRM->Transactions->Basic Settings->Edit event handler table
1. Initialization
Choosing transaction category is opportunity w ill ensure that this FM w ill be called only for Opportunities Transaction Category Execution Tim e Priority Object Event Attribute Function 99 ZORD (Z Order Extension) INIT <*> ZORD_INIT_EC X blank BUS2000111 (Opportunity) 88 (Initialize Docum ent)

Difference between custom and component controller... Transaction launcher One order framework ABOUT ONECLICK ACTIONS. Post Processing Framework

Perform Function for Docum ent Header Perform Function for Docum ent Item Call Callback 2. Save

Do Not Process Function if Event Error Occurs blank Call Just Once Per Transaction

Unlike above, w e cannot choose transaction category as Opportunity here! This is because an opportunity save event w ill be raised only w hen you m ake changes in the opportunity relevant fields(eg OPPORT_H), even though you are editing an opportunity. For the below FM to trigger, w e w ill have to "rem ind" the system to do it w hen changes are m ade to our custom objects. So, you w ill not see this FM in the event trace right now till the coding part is com plete. We w ill cover this further dow n(Look ACTIONS further dow n at the last part of the coding part for the m ethod im plem entation for METHOD ZORD_RUN_BTIL->if_crm _runtim e_btil~m aintain_attributes). Transaction Category Execution Tim e Priority Object Event Attribute Function 99 ZORD (Z Order Extension) SAVE <*> ZORD_SAVE_EC X blank blank BUS20001 (CRM Bus Transactions) 80 (Save Docum ent)

BTE - Business Transaction Event

wande mataram .... : mother country .. Sales order scenario : CRM -ERP

Perform Function for Docum ent Header Perform Function for Docum ent Item Call Callback

Do Not Process Function if Event Error Occurs

Sales order Distribution: Required 3. Delete Customizing in For deletion also, only generic order delete event can be chosen. Inside this Fm , you should m ake sure that the scenario ... is right. For exam ple, m ake sure that the order
Call Just Once Per Transaction being deleted is an opportunity before m aking API calls! We w ill cover this below . Transaction Category Execution Tim e Priority Object Event Attribute Function 90 ORDER (General order processing) AFTER_DELETE <*> ZORD_DEL_EC X blank blank BUS20001 (CRM Bus Transactions) 1 (Im m ediately)

SAP CRM Sales : Creating a quotation directly in E... July (26) June (18) May (11) April (9) March (28) February (13)

Perform Function for Docum ent Header Perform Function for Docum ent Item Call Callback

Do Not Process Function if Event Error Occurs

Call Just Once Per Transaction

Step 2 : Customizing - Extend Model BT

January (10)

First, w e have som e custom izing w ork to do. Navigate to the node show n in the picture.Note that the node text m ay show up as 'Business Transactions' in your case. Or yo m ay go to SM30 and put 'CRMC_OBJ_BTIL' and choose custom izing. You m ust do each of the three activities show n.

Maintain Z-objects

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

2/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

pow ered by

Popular Posts CRM Tables and Transaction Codes TABLE NAME DESCRIPTION BUSINESS PARTNERS BUT000 BP: General data Contains Business Partner Number, Partner Category, Partne... Getter - Setter methods in Web UI Using Get and Setter methods you can retrieve data to field and set specific data to field. Using Get_I method you can make your field ... Important methods in CRM web UI Important methods in CRM web UI or component programming . View Impl class methods: DO_CONFIG_DETERMINATIO N : The method is for run tim... SAP CRM interview questions Q 1. What is the typical landscape for a CRM project? What is the maximum number of landscapes that you have worked on in a project. ... SAP CRM Most useful BADIs (Updating) . ORDER_SAVE BADI is used at the time of saving order. 1st called CHECK_BEFORE_SAVE Useful for check if the values are filled as expect... An introduction about IPC SAP CRM uses IPC to determine pricing information when creating a business transaction, such as a quotation, sales order, service proce... One order framework One Order Object Model The CRM One Order documents are created in transaction CRMD_ORDER. The Header table that is updated by the crea...

Maintain Z-Relations

Maintain handler classes for Z-objects

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

3/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship
Concepts of BOL programming : Get_current Get_current and get_iterator how does it works? The data you enter on the Web UI gets saved in the database tables via BOL Entities ... web UI In general there are 4 different Sources for error messages: Important Info Message BSP Framework messages UI Framework mes... Create a Tree view display in CRM web UI This blog gives the steps to create a Tree view display in CRM web UI. Below is a screen shot of the sample implementation. ...

Note:

If you are not w illing to im plem ent the classes, you m ay skip m aintaining the handler classes. You can even directly specify a single 1..n relationship directly under

How to use in CRM BTAdm inH. The relationships w ill be available, but not usable in the real sense. Then, you can follow this w iki to m ake do messages w ith value nodes.
http://w iki.sdn.sap.com /w iki/display/CRM/How +to+display+a+z-table+in+an+assignm ent+block Moving forw ard, here's a screenshot of the m odel w ith the new relationships expanded.

Total Pageviews

2 5 6 3 1 4
Follow by Email
Email address... Submit

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

4/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

Step 3: Implementing Handler classes


API Class for our custom Object
We w ill begin w ith the API class w hich w ill be responsible for all operations related to our table. ZL_ZORD_BTIL_API -> Super class: None Class Attributes GT_ZORD Static Attribute Private Type ZORD_STRUCT_TAB API Buffer GT_ZORD_DEL Static Attribute Private Type ZORD_STRUCT_TAB API Buffer for deleted entities Note: The GT_ZORD table w ill act as a unified buffer for read and change. GT_ZORD_DEL w ill hold entries to be deleted on save. Due to this unified buffer nature, it is very im portant to refresh this table on Order INIT events. Methods:

ZORD_CREATE Static Method Public Create ZORD_MODIFY Static Method Public Modify API data ZORD_DELETE Static Method Public Delete from API data ZORD_SAVE Static Method Public Save to DB ZORD_READ Static Method Public Initial relations reading ZORD_READ_SINGLE Static Method Public Read single entry ZORD_INIT Static Method Public Reset buffers ZORD_DELETE_WITH_ORDER Static Method Public Delete from DB w hen order is deleted

Method Signatures: *"* public com ponents of class ZL_ZORD_BTIL_API *"* do not include other source files here!!! public section. class-m ethods ZORD_CREATE im porting !IS_KEY type CRMT_OBJECT_GUID !IS_ATTRIBUTES type ZORD_STRUCT . class-m ethods ZORD_MODIFY im porting !IS_KEY type CRMT_OBJECT_GUID !IV_HEADER_GUID type CRMT_OBJECT_GUID !IS_ATTRIBUTES type ZORD_STRUCT !IT_CHANGED_FIELDS type CRMT_ATTR_NAME_TAB exporting !ET_RETURN type BAPIRET2_T !ET_CHANGED_OBJECTS type CRMT_GENIL_OBJ_INSTANCE_TAB . class-m ethods ZORD_DELETE im porting !IS_KEY type CRMT_OBJECT_GUID !IV_HEADER_GUID type CRMT_OBJECT_GUID exporting !ET_RETURN type BAPIRET2_T !ET_CHANGED_OBJECTS type CRMT_GENIL_OBJ_INSTANCE_TAB . class-m ethods ZORD_SAVE im porting !IV_HEADER_GUID type CRMT_OBJECT_GUID . class-m ethods ZORD_READ im porting !IV_HEADER_GUID type CRMT_OBJECT_GUID exporting !ET_ZORD type ZORD_STRUCT_TAB . class-m ethods ZORD_READ_SINGLE im porting !IV_GUID type CRMT_OBJECT_GUID exporting !ET_ZORD type ZORD_STRUCT_TAB . class-m ethods ZORD_INIT im porting !IV_HEADER_GUID type CRMT_OBJECT_GUID optional . class-m ethods ZORD_DELETE_WITH_ORDER im porting !IV_HEADER_GUID type CRMT_OBJECT_GUID optional .

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

5/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship
Method Implementations
M E T H O Dz o r d _ c r e a t e . D A T A :l s _ z o r dT Y P Ez o r d _ s t r u c t . l s _ z o r d=i s _ a t t r i b u t e s . l s _ z o r d g u i d=i s _ k e y . I N S E R Tl s _ z o r dI N T OT A B L Eg t _ z o r d . E N D M E T H O D . M E T H O Dz o r d _ m o d i f y . F I E L D S Y M B O L S :< f s _ z o r d >L I K EL I N EO Fg t _ z o r d , < o l d > T Y P Es i m p l e , < n e w > T Y P Es i m p l e , < n a m e >T Y P En a m e _ k o m p . R E A DT A B L Eg t _ z o r dW I T HK E Yg u i d=i s _ k e yA S S I G N I N G< f s _ z o r d > . I Fs y s u b r cE Q0 . L O O PA Ti t _ c h a n g e d _ f i e l d sA S S I G N I N G< n a m e > . A S S I G NC O M P O N E N T< n a m e >O FS T R U C T U R E< f s _ z o r d >T O< o l d > . C H E C Ks y s u b r c=0 . A S S I G NC O M P O N E N T< n a m e >O FS T R U C T U R Ei s _ a t t r i b u t e sT O< n e w > . C H E C Ks y s u b r c=0 . < o l d >=< n e w > . E N D L O O P . E N D I F . E N D M E T H O D . M E T H O Dz o r d _ d e l e t e . D A T A :l s _ z o r dL I K EL I N EO Fg t _ z o r d . R E A DT A B L Eg t _ z o r dW I T HK E Yg u i d=i s _ k e yI N T Ol s _ z o r d . I Fs y s u b r cE Q0 . I N S E R Tl s _ z o r dI N T OT A B L Eg t _ z o r d _ d e l . D E L E T Eg t _ z o r dW H E R Eg u i d=i s _ k e y . E N D I F . E N D M E T H O D . M E T H O Dz o r d _ s a v e . D A T A :l t _ z o r dT Y P Ez o r d _ s t r u c t _ t a b , l s _ z o r dL I K EL I N EO Fl t _ z o r d . L O O PA Tg t _ z o r d I N T Ol s _ z o r dW H E R Er e f _ g u i d=i v _ h e a d e r _ g u i d . I N S E R Tl s _ z o r dI N T OT A B L El t _ z o r d . E N D L O O P . I Fl t _ z o r d [ ]I SN O TI N I T I A L . M O D I F Yz o r dF R O MT A B L El t _ z o r d . E N D I F . R E F R E S Hl t _ z o r d . L O O PA Tg t _ z o r d _ d e l I N T Ol s _ z o r dW H E R Er e f _ g u i d=i v _ h e a d e r _ g u i d . I N S E R Tl s _ z o r dI N T OT A B L El t _ z o r d . E N D L O O P . I Fl t _ z o r d [ ]I SN O TI N I T I A L . D E L E T Ez o r dF R O MT A B L El t _ z o r d . E N D I F . E N D M E T H O D . M E T H O Dz o r d _ r e a d . D A T A :l t _ z o r dT Y P Ez o r d _ s t r u c t _ t a b , l s _ z o r dL I K EL I N EO Fl t _ z o r d . * C h e c kb u f f e rf i r s t * I fe n t r i e sa r ef o u n di nb u f f e r ,n on e e dt oc h e c kD Ba sw h o l eb u f f e ri su s e d . * n os p e c i a lp r o v i s i o n sf o rd e l e t e di t e m s R E A DT A B L Eg t _ z o r dW I T HK E Yr e f _ g u i d=i v _ h e a d e r _ g u i dT R A N S P O R T I N GN OF I E L D S . I Fs y s u b r cE Q0 . e t _ z o r d [ ]=g t _ z o r d [ ] . D E L E T Ee t _ z o r dW H E R Er e f _ g u i dN Ei v _ h e a d e r _ g u i d . E L S E . R E A DT A B L Eg t _ z o r d _ d e lW I T HK E Yr e f _ g u i d=i v _ h e a d e r _ g u i dT R A N S P O R T I N GN OF I E L D S . I Fs y s u b r cE Q0 . * d e l e t e de n t r i e se x i s ti nb u f f e r ! != >T a b l eh a sa l r e a d yb e e nb u f f e r e d= >N oD BR e a d E X I T . E L S E . R E F R E S He t _ z o r d . S E L E C T*F R O Mz o r dI N T OT A B L Ee t _ z o r dW H E R Er e f _ g u i d=i v _ h e a d e r _ g u i d . I N S E R TL I N E SO Fe t _ z o r dI N T OT A B L Eg t _ z o r d . E N D I F . E N D I F . E N D M E T H O D . M E T H O Dz o r d _ r e a d _ s i n g l e . D A T A :l t _ z o r dT Y P Ez o r d _ s t r u c t _ t a b , l s _ z o r dL I K EL I N EO Fl t _ z o r d . * C h e c kb u f f e rf i r s t * I fe n t r i e sa r ef o u n di nb u f f e r ,n on e e dt oc h e c kD Ba sw h o l eb u f f e ri su s e d . * n os p e c i a lp r o v i s i o n sf o rd e l e t e di t e m s R E A DT A B L Eg t _ z o r dW I T HK E Yg u i d=i v _ g u i dI N T Ol s _ z o r d . I Fs y s u b r cE Q0 . I N S E R Tl s _ z o r dI N T Ot a b l ee t _ z o r d . E L S E . S E L E C T*F R O Mz o r dI N T OT A B L Ee t _ z o r dW H E R Eg u i d=i v _ g u i d . I N S E R TL I N E SO Fe t _ z o r dI N T OT A B L Eg t _ z o r d . E N D I F . E N D M E T H O D . M E T H O Dz o r d _ i n i t . D A T A :l t _ z o r dT Y P Ez o r d _ s t r u c t _ t a b , l s _ z o r dL I K EL I N EO Fl t _ z o r d .

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

6/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship
l s _ z o r dL I K EL I N EO Fl t _ z o r d . I Fi v _ h e a d e r _ g u i dI SN O TI N I T I A L . D E L E T Eg t _ z o r dW H E R Er e f _ g u i d=i v _ h e a d e r _ g u i d . D E L E T Eg t _ z o r d _ d e lW H E R Er e f _ g u i d=i v _ h e a d e r _ g u i d . E L S E . R E F R E S Hg t _ z o r d . R E F R E S Hg t _ z o r d _ d e l . E N D I F . E N D M E T H O D . M E T H O DZ O R D _ D E L E T E _ W I T H _ O R D E R . D E L E T EF R O Mz o r dW H E R Er e f _ g u i d=i v _ h e a d e r _ g u i d . E N D M E T H O D .

Handler classes for our objects


The nam es of the classes w ill be derived at runtim e follow ing som e conventions. Essentially a _RUN_BTIL and a _DESIGN_BTIL is appended to w hat you have specified in custom izing. So, go ahead and create the classes. ZORD_SET_DESIGN_BTIL -> Super class: CL_CRM_DESIGNTIME_BTIL ZORD_DESIGN_BTIL -> Super class: CL_CRM_DESIGNTIME_BTIL For the design classes, no further changes are required. You m ay w ant to redefine the constructor if you w ish to validate the object nam e. ZORD_SET_RUN_BTIL -> Super class: CL_CRM_RUNTIME_BTIL ZORD_RUN_BTIL -> Super class: CL_CRM_RUNTIME_BTIL

ZORD_SET_RUN_BTIL - Redefined Methods

M E T H O Di f _ c r m _ r u n t i m e _ b t i l ~ r e a d _ a t t r i b u t e s . D A T A :l s _ g u i dT Y P Ec r m s t _ g u i d _ b t i l . * T h i si sas t a t i cr e a d o n l yr e l a t i o n . * I n h e r i tG U I Df r o mo r d e r T R Y . i r _ c o n t _ o b j > s e t _ k e y (i v _ r e f _ g u i d) . C A T C Hc x _ c r m _ c i c _ d u p l i c a t e _ e n t r y . E N D T R Y . I Fi r _ c o n t _ o b j > c h e c k _ a t t r _ r e q u e s t e d ()E Qt r u e . l s _ g u i d c r m _ g u i d=i v _ r e f _ g u i d . m e > s e t _ a t t r i b u t e s (i r _ c o n t _ o b j =i r _ c o n t _ o b j i s _ a t t r i b u t e s=l s _ g u i d i v _ r e f _ k i n d =i v _ r e f _ k i n d i v _ l o g _ k e y =i v _ r e f _ g u i d) . E N D I F . * R e a du n d e r l y i n gr e l a t i o n s I Fi r _ c o n t _ o b j > c h e c k _ r e l s _ r e q u e s t e d ()E Qt r u e . m e > a c c e s s _ c h i l d r e n (i r _ c o n t _ o b j=i r _ c o n t _ o b j i r _ d a t a =i r _ a p i _ d a t a i v _ r e f _ g u i d=i v _ r e f _ g u i d i v _ r e f _ k i n d=i v _ r e f _ k i n d) . E N D I F . * E N D M E T H O D .

M E T H O DI F _ C R M _ R U N T I M E _ B T I L ~ M A I N T A I N _ A T T R I B U T E S . D A T A :l v _ d e l t aT Y P Ec r m t _ d e l t a . * * * * T h i si sar e a d o n l yr e l a t i o n ,n o t h i n gm u c ht od oh e r ee x c e p ti n h e r i tG U I Df r o mO r d e ro b j e c t l v _ d e l t a=i r _ c o n t _ o b j > g e t _ d e l t a _ f l a g () . I Fl v _ d e l t aE Qi r _ c o n t _ o b j > d e l t a _ c r e a t e d . T R Y . i r _ c o n t _ o b j > s e t _ k e y (i v _ r e f _ g u i d) . C A T C Hc x _ c r m _ c i c _ d u p l i c a t e _ e n t r y . E N D T R Y . E N D I F . * T a k ec a r eo fu n d e r l y i n gr e l a t i o n s m e > m o d i f y _ c h i l d r e n (i r _ c o n t _ o b j =i r _ c o n t _ o b j i r _ d a t a =i r _ a p i _ d a t a i r _ i n p u t _ f i e l d s=i r _ i n p u t _ f i e l d s i v _ r e f _ k i n d =i v _ r e f _ k i n d i v _ r e f _ g u i d =i v _ r e f _ g u i d) . E N D M E T H O D . M E T H O DM O D I F Y _ C H I L D R E N. * D on o tr e d e f i n et h i sm e t h o d !S u p e rc l a s sw i l lt a k ec a r eo ft h i s E N D M E T H O D .

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

7/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

ZORD_RUN_BTIL - Redefined methods

M E T H O Df i e l d c h e c k . * r e d e f i n e dt op r e v e n ts y s t e ml o o k i n gf o ru n i m p l e m e n t e dF M * e m p t y ,c r e a t ey o u ro w ni m p l e m e n t a t i o n e n d m e t h o d .

M E T H O Di f _ c r m _ r u n t i m e _ b t i l ~ r e a d _ a t t r i b u t e s . D A T A :l r _ r o o t _ c o n t a i n e rT Y P ER E FT Oi f _ g e n i l _ c o n t a i n e r _ o b j e c t , l v _ g u i dT Y P Ec r m t _ o b j e c t _ g u i d , l v _ f i r s tT Y P Ec r m t _ b o o l e a nV A L U Et r u e , l v _ r e l a t i o n T Y P Ec r m t _ r e l a t i o n _ n a m e . D A T A :l r _ z o r d _ iT Y P ER E FT Oz o r d _ s t r u c t _ t a b , l t _ z o r d _ iT Y P Ez o r d _ s t r u c t _ t a b , l r _ a t t r _ p r o p sT Y P ER E FT Oi f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s , l r _ c o n t _ o b jT Y P ER E FT Oi f _ g e n i l _ c o n t a i n e r _ o b j e c t . F I E L D S Y M B O L S :< l s _ z o r d _ i >T Y P Ez o r d _ s t r u c t , < l s _ a p i _ d a t a > T Y P Ec r m t _ i n t l a y _ g e t , < l t _ a p i _ d a t a > T Y P Ec r m t _ i n t l a y _ g e t _ t a b . * * * C A L LM E T H O Dz l _ z o r d _ b t i l _ a p i = > z o r d _ r e a d E X P O R T I N G i v _ h e a d e r _ g u i d=i v _ r e f _ g u i d" O r d e rG U I D I M P O R T I N G e t _ z o r d =l t _ z o r d _ i . C A L LM E T H O Di r _ c o n t _ o b j > g e t _ p a r e n t _ r e l a t i o n I M P O R T I N G e v _ r e l a t i o n _ n a m e=l v _ r e l a t i o n .

L O O PA Tl t _ z o r d _ iA S S I G N I N G< l s _ z o r d _ i > . T R Y . I Fl v _ f i r s tE Qt r u e . l v _ f i r s t=f a l s e . l r _ c o n t _ o b j=i r _ c o n t _ o b j . l r _ c o n t _ o b j > s e t _ k e y (< l s _ z o r d _ i > g u i d) . E L S E . l r _ c o n t _ o b j=i r _ c o n t _ o b j > c o p y _ s e l f _ w i t h _ s t r u c t u r e ( i s _ o b j e c t _ k e y =< l s _ z o r d _ i > g u i d i v _ r e l a t i o n _ n a m e=l v _ r e l a t i o n) . C H E C Kl r _ c o n t _ o b jI SB O U N D . E N D I F . C A T C Hc x _ c r m _ c i c _ d u p l i c a t e _ e n t r y . T R Y . l r _ c o n t _ o b j=m e > t u r n _ p a t h (i r _ c o n t _ o b j =i r _ c o n t _ o b j i v _ r e l a t i o n _ n a m e=l v _ r e l a t i o n i s _ k e y =< l s _ z o r d _ i > g u i d) . C A T C Hc x _ c r m _ g e n i l _ g e n e r a l _ e r r o r . C O N T I N U E . E N D T R Y . C A T C Hc x _ c r m _ g e n i l _ m o d e l _ e r r o r . C O N T I N U E . E N D T R Y . I Fl r _ c o n t _ o b j > c h e c k _ a t t r _ r e q u e s t e d ()E Qt r u e . m e > s e t _ a t t r i b u t e s (i r _ c o n t _ o b j =l r _ c o n t _ o b j i s _ a t t r i b u t e s=< l s _ z o r d _ i > i v _ r e f _ k i n d =i v _ r e f _ k i n d i v _ l o g _ k e y =< l s _ z o r d _ i > g u i d) . l r _ a t t r _ p r o p s=l r _ c o n t _ o b j > g e t _ a t t r _ p r o p s _ o b j () . l r _ a t t r _ p r o p s > s e t _ a l l _ p r o p e r t i e s (i f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s = > c h a n g e a b l e) . l r _ a t t r _ p r o p s > s e t _ p r o p e r t y _ b y _ i d x (i v _ i n d e x =1 i v _ v a l u e=i f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s = > r e a d _ o n l y) ." C l i e n t l r _ a t t r _ p r o p s > s e t _ p r o p e r t y _ b y _ i d x (i v _ i n d e x =2 i v _ v a l u e=i f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s = > t e c h n i c a l) ." G U I D l r _ a t t r _ p r o p s > s e t _ p r o p e r t y _ b y _ i d x (i v _ i n d e x =3 i v _ v a l u e=i f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s = > t e c h n i c a l) ." R E F _ G U I D E N D I F . I Fl r _ c o n t _ o b j > c h e c k _ r e l s _ r e q u e s t e d ()E Qt r u e . m e > g e t _ f o r e i g n _ i d (i r _ c o n t _ o b j=l r _ c o n t _ o b j i s _ d a t a =< l s _ z o r d _ i >) . E N D I F . E N D L O O P . E N D M E T H O D . *

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

8/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship
M E T H O Di f _ c r m _ r u n t i m e _ b t i l ~ m a i n t a i n _ a t t r i b u t e s . I N C L U D Ec r m _ m o d e _ c o n . D A T A :l v _ d e l t a T Y P Ec r m t _ d e l t a . D A T A :l s _ c h a n g e d _ o b j e c tT Y P Ec r m t _ g e n i l _ o b j _ i n s t a n c e . D A T A :l t _ n a m e sT Y P Ec r m t _ a t t r _ n a m e _ t a b . D A T A :l r _ a t t r _ p r o p sT Y P ER E FT Oi f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s . F I E L D S Y M B O L S :< l s _ a p i _ d a t a >T Y P Ec r m s t _ o r d e r _ m a i n t a i n , < l v _ n a m e > T Y P En a m e _ k o m p . * * * D A T A :l v _ p r o p s _ o b j T Y P ER E FT Oi f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s , l t _ c h a n g e d _ a t t rT Y P Ec r m t _ a t t r _ n a m e _ t a b , l s _ a t t r i b u t e s T Y P Ez o r d _ s t r u c t , l v _ g u i d T Y P Ec r m t _ o b j e c t _ g u i d , * l t _ r e t u r n T Y P Eb a p i r e t 2 _ t , * l v _ m s g _ c o n t T Y P ER E FT Oc l _ c r m _ g e n i l _ b a p i _ m e s s _ c o n t , l s _ o b j _ i n s t T Y P Ec r m t _ g e n i l _ o b j _ i n s t a n c e , l v _ h e a d e r T Y P ER E FT Oi f _ g e n i l _ c o n t a i n e r _ o b j e c t , l v _ h e a d e r _ g u i d T Y P Ec r m t _ g e n i l _ o b j e c t _ g u i d , l s _ h e a d e r _ a t t r T Y P Ec r m s t _ g u i d _ b t i l . C H E C Ki r _ c o n t _ o b j > g e t _ n a m e ()=' Z O R D ' . l s _ o b j _ i n s t o b j e c t _ n a m e=' Z O R D ' . " # E CN O T E X T *r e t r i e v et h eG U I Do ft h eh e a d e r l v _ h e a d e r=i r _ c o n t _ o b j > g e t _ p a r e n t () . C A L LM E T H O Dl v _ h e a d e r > g e t _ k e y I M P O R T I N G e s _ k e y=l v _ h e a d e r _ g u i d . C A L LM E T H O Dl v _ h e a d e r > g e t _ a t t r i b u t e s I M P O R T I N G e s _ a t t r i b u t e s=l s _ h e a d e r _ a t t r . *r e t r i e v et h ed e l t af l a g l v _ d e l t a=i r _ c o n t _ o b j > g e t _ d e l t a _ f l a g () . *b r a n c ha c c o r d i n gt ot h ed e l t af l a g .D e p e n d e n to b j e c t sm a yb ec r e a t e d ,m o d i f i e d ,o rd e l e t e d . C A S El v _ d e l t a . W H E Ni f _ g e n i l _ c o n t _ s i m p l e _ o b j e c t = > d e l t a _ c h a n g e d . * r e t r i e v et h ea t t r i b u t ep r o p e r t yo b j e c tt og e tt h em o d i f yd e t a i l s l v _ p r o p s _ o b j=i r _ c o n t _ o b j > g e t _ a t t r _ p r o p s _ o b j () . * w h i c ha t t r i b u t e sw e r em o d i f i e d ? C A L LM E T H O Dl v _ p r o p s _ o b j > g e t _ n a m e _ t a b _ 4 _ p r o p e r t y E X P O R T I N G i v _ p r o p e r t y=i f _ g e n i l _ o b j _ a t t r _ p r o p e r t i e s = > m o d i f i e d I M P O R T I N G e t _ n a m e s =l t _ c h a n g e d _ a t t r . C A L LM E T H O Di r _ c o n t _ o b j > g e t _ k e y I M P O R T I N G e s _ k e y=l v _ g u i d . C A L LM E T H O Di r _ c o n t _ o b j > g e t _ a t t r i b u t e s I M P O R T I N G e s _ a t t r i b u t e s=l s _ a t t r i b u t e s . * c a l lt h eA P I C A L LM E T H O Dz l _ z o r d _ b t i l _ a p i = > z o r d _ m o d i f y E X P O R T I N G i s _ k e y =l v _ g u i d i v _ h e a d e r _ g u i d =l v _ h e a d e r _ g u i d i s _ a t t r i b u t e s =l s _ a t t r i b u t e s i t _ c h a n g e d _ f i e l d s=l t _ c h a n g e d _ a t t r . I M P O R T I N G e t _ r e t u r n =l t _ r e t u r n e t _ c h a n g e d _ o b j e c t s=l t _ c h a n g e d _ o b j e c t s . l s _ o b j _ i n s t o b j e c t _ i d=c l _ c r m _ g e n i l _ c o n t a i n e r _ t o o l s = > b u i l d _ o b j e c t _ i d (l v _ g u i d) . a d do b j e c tt ot h ec h a n g e do b j e c t sl i s t I N S E R Tl s _ o b j _ i n s tI N T OT A B L Eg r _ i n t l a y > g t _ c h a n g e d _ o b j e c t s .

* * * *

W H E Ni f _ g e n i l _ c o n t _ s i m p l e _ o b j e c t = > d e l t a _ c r e a t e d . g e tt h ea t t r i b u t es t r u c t u r e C A L LM E T H O Di r _ c o n t _ o b j > g e t _ a t t r i b u t e s I M P O R T I N G e s _ a t t r i b u t e s=l s _ a t t r i b u t e s . * * b u i l dt h ek e y * C A L LF U N C T I O N' G U I D _ C R E A T E ' * I M P O R T I N G * e v _ g u i d _ 1 6=l v _ g u i d . i r _ c o n t _ o b j > g e t _ k e y (I M P O R T I N Ge s _ k e y=l v _ g u i d) . l s _ a t t r i b u t e s r e f _ g u i d=l v _ h e a d e r _ g u i d . * c a l lt h eA P I C A L LM E T H O Dz l _ z o r d _ b t i l _ a p i = > z o r d _ c r e a t e E X P O R T I N G i s _ k e y =l v _ g u i d i s _ a t t r i b u t e s=l s _ a t t r i b u t e s . * I M P O R T I N G * e t _ r e t u r n =l t _ r e t u r n . l s _ a t t r i b u t e s g u i d=l v _ g u i d . i r _ c o n t _ o b j > s e t _ a t t r i b u t e s (l s _ a t t r i b u t e s) . * * s e tn e wk e y T R Y . i r _ c o n t _ o b j > s e t _ k e y (l v _ g u i d) . C A T C Hc x _ c r m _ g e n i l _ d u p l i c a t e _ k e y . E N D T R Y . l s _ o b j _ i n s t o b j e c t _ i d=c l _ c r m _ g e n i l _ c o n t a i n e r _ t o o l s = > b u i l d _ o b j e c t _ i d (l v _ g u i d) .

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

9/12

3/21/2014

l s _ o b j _ i n s t o b j e c t _ i d=c l _ c r m _ g e n i l _ c o n t a i n e r _ t o o l s = > b u i l d _ o b j e c t _ i d (l v _ g u i d) . I N S E R Tl s _ o b j _ i n s tI N T OT A B L Eg r _ i n t l a y > g t _ c h a n g e d _ o b j e c t s . W H E Ni f _ g e n i l _ c o n t _ s i m p l e _ o b j e c t = > d e l t a _ d e l e t e d . g e to b j e c tk e y C A L LM E T H O Di r _ c o n t _ o b j > g e t _ k e y I M P O R T I N G e s _ k e y=l v _ g u i d . * c a l lt h eA P I C A L LM E T H O Dz l _ z o r d _ b t i l _ a p i = > z o r d _ d e l e t e E X P O R T I N G i s _ k e y =l v _ g u i d i v _ h e a d e r _ g u i d=l v _ h e a d e r _ g u i d . * I M P O R T I N G * e t _ r e t u r n =l t _ r e t u r n * e t _ c h a n g e d _ o b j e c t s=l t _ c h a n g e d _ o b j e c t s . l s _ o b j _ i n s t o b j e c t _ i d=c l _ c r m _ g e n i l _ c o n t a i n e r _ t o o l s = > b u i l d _ o b j e c t _ i d (l v _ g u i d) . I N S E R Tl s _ o b j _ i n s tI N T OT A B L Eg r _ i n t l a y > g t _ c h a n g e d _ o b j e c t s . E N D C A S E . *

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

* T e l lt h eO r d e rA P It h a tac h a n g eh a sh a p p e n e d * T h i sw i l lr e g i s t e ro u ro b j e c tf o rs a v e( T h eF Mw er e g i s t e r e df o rS A V Ee v e n ti ne v e n th a n d l e rt a b l e ) C A L LF U N C T I O N' C R M _ E V E N T _ P U B L I S H _ O W ' E X P O R T I N G i v _ o b j _ n a m e=' Z O R D ' i v _ g u i d _ h i =l v _ h e a d e r _ g u i d i v _ k i n d _ h i =g c _ o b j e c t _ k i n d o r d e r a d m _ h i v _ e v e n t =g c _ e v e n t a f t e r _ c h a n g e . E N D M E T H O D .

Step 4 - Implement Event callback Function Modules


Rem em ber the three event callback function m odules that w e registered in the transaction event handler table? Call the correct API m ethods inside each FM. 1. Initialization

F U N C T I O Nz o r d _ i n i t _ e c . * " * " * " L o c a lI n t e r f a c e : * " I M P O R T I N G * " R E F E R E N C E ( I V _ H E A D E R _ G U I D )T Y P E C R M T _ O B J E C T _ G U I DO P T I O N A L * " I Fi v _ h e a d e r _ g u i dI SN O TI N I T I A L . C A L LM E T H O DZ L _ Z O R D _ B T I L _ A P I = > Z O R D _ I N I T E X P O R T I N G i v _ h e a d e r _ g u i d=i v _ h e a d e r _ g u i d . E N D I F . E N D F U N C T I O N .

2. Save

F U N C T I O Nz o r d _ s a v e _ e c . * " * " * " L o c a lI n t e r f a c e : * " I M P O R T I N G * " R E F E R E N C E ( I V _ O B J E C T _ N A M E )T Y P E C R M T _ O B J E C T _ N A M E * " R E F E R E N C E ( I V _ E V E N T _ E X E T I M E )T Y P E C R M T _ E V E N T _ E X E T I M E * " R E F E R E N C E ( I V _ E V E N T )T Y P E C R M T _ E V E N T * " R E F E R E N C E ( I T _ H E A D E R _ G U I D )T Y P E C R M T _ O B J E C T _ G U I D _ T A B * " D a t a :l v _ h e a d e r _ g u i dt y p ec r m t _ o b j e c t _ g u i d . l o o pa ti t _ h e a d e r _ g u i di n t ol v _ h e a d e r _ g u i d . C A L LM E T H O DZ L _ Z O R D _ B T I L _ A P I = > Z O R D _ S A V E E X P O R T I N G i v _ h e a d e r _ g u i d=l v _ h e a d e r _ g u i d . e n d l o o p . E N D F U N C T I O N .

3. Delete

F U N C T I O Nz o r d _ d e l _ e c . * " * " * " L o c a lI n t e r f a c e :

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

10/12

3/21/2014

* " * " L o c a lI n t e r f a c e : * " I M P O R T I N G * " R E F E R E N C E ( I V _ O B J E C T _ N A M E )T Y P E C R M T _ O B J E C T _ N A M E * " R E F E R E N C E ( I V _ E V E N T _ E X E T I M E )T Y P E C R M T _ E V E N T _ E X E T I M E * " R E F E R E N C E ( I V _ E V E N T )T Y P E C R M T _ E V E N T * " R E F E R E N C E ( I V _ H E A D E R _ G U I D )T Y P E C R M T _ O B J E C T _ G U I DO P T I O N A L * " -

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

* U s eF M" C R M _ O R D E R A D M _ H _ R E A D _ O B "w i t hi n c l u d e _ d e l e t e d _ h e a d e ro p t i o nt oe n s u r et h a to b j e c ti sr e l e v a n tt ou s *-b e f o r ec a l l i n gA P Im e t h o d I Fi v _ h e a d e r _ g u i dI SN O TI N I T I A L . * D e l e t ef r o mo b j e c tb u f f e r C A L LM E T H O DZ L _ Z O R D _ B T I L _ A P I = > Z O R D _ I N I T E X P O R T I N G i v _ h e a d e r _ g u i d=i v _ h e a d e r _ g u i d . * D e l e t ef r o md a t a b a s e C A L LM E T H O DZ L _ Z O R D _ B T I L _ A P I = > Z O R D _ D E L E T E _ W I T H _ O R D E R E X P O R T I N G i v _ h e a d e r _ g u i d=i v _ h e a d e r _ g u i d . E N D I F . E N D F U N C T I O N .

Results:
Here are a few screens show ing the results

Here's the table view after deleting line4 and save.

Posted by Naval Bhatt at 9:01 AM Labels: Extend BOL Model BT with custom table type relationship, sap crm tutorial, SAP CRM tutorials

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

11/12

3/21/2014

SAP CRM Technical Tutorials by Naval Bhatt.: Extend BOL Model BT with custom table type relationship

No comments: Post a Comment


Enter your comment...

Comment as:

Google Account

Publish

Preview

Newer Post

Home
Subscribe to: Post Comments (Atom)

Older Post

Naval bhatt 2012. Awesome Inc. template. Powered by Blogger.

http://sapcrmtutorial.blogspot.in/2012/08/extend-bol-model-bt-with-custom-table.html

12/12

Você também pode gostar