Você está na página 1de 27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

SAP CRM Technical Tutorials by Naval Bhatt.


SAP CRM tutorials for all : Please feel free to contact me on naval.k.bhatt@gmail.com. Sunday, August 26, 2012 Search This Blog
Search

Extend BOL Model BT with custom table type relationship

Followers:Join to get regular update


Link to Content's target Space :
http://w iki.sdn.sap.com /w iki/display/CRM/CRM+Web+Client+UI+Fram ew ork

babudeep junjuri
Options

Applies to:
SAP CRM 6.0/7.0

Members (11)

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

Intro
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 able My other blogs 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.

SAP BPM & Workflow tutorials My travel experiences

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

Me & my pursuit of happiness Wandering hermit Photography

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.

Join me on my photography journey

Step 1 : Studying the event handler model

Maintain API Object Name


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 allow us to define our ow n transaction events.

Maintain Object dependency


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

Identify positions for defining custom events for transactions


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. 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 som ething say, create transactions, m odify it, save it and delete it. After each action, look at the events raised in transaction CRMD_EVENT_TRACE. Study this data carefully and decide on the points in w hich to insert your event callback function m odules. For creating the FMs(the signature part), 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 the trace again. 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 and ensure that the FMs are getting called in the correct

sapcrmtutorial.blogspot.in

1/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.


places for various scenarios. 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 .. on Facebook

Naval Bhatt Photography


Like

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)

Naval Bhatt Photography .. added a new photo.

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

August 10 at 8:11pm

Show More 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 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
Naval Bhatt Photography .. on Facebook

BUS20001 (CRM Bus Transactions) 80 (Save Docum ent)

460 people like Naval Bhatt Photography ..

P ratik

P eey ush

Dearest

Deepak

Perform Function for Docum ent Header Perform Function for Docum ent Item Call Callback 3. Delete

blank

S hankar

Tarun

S hahril

N ur

Do Not Process Function if Event Error Occurs

Call Just Once Per Transaction

Blog Archive 2012 (129)

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 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)

August (14) Extend BOL Model BT with custom table type relatio... Extend BOL Model for BP with Custom Table and Impl... How to use your custom BOL Object for webclient wi... Difference between custom and component controller... Transaction launcher

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

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 you 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.

One order framework ABOUT ONE-CLICK ACTIONS. Post Processing Framework ACTIONS BTE - Business Transaction Event wande mataram .... : mother country ..

Maintain Z-objects

Sales order scenario : CRM -ERP Sales order Distribution: Required Customizing in ... SAP CRM Sales : Creating a quotation directly in E... sapcrmtutorial.blogspot.in 2/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt. July (26) June (18) May (11) April (9) March (28) February (13) January (10)

Video Bar

pow ered by

Popular Posts 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 ... 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 ... 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. ...

Maintain Z-Relations

Maintain handler classes for Z-objects

Scope of the design layer Scope of the design layer In the UIU framework some UI/Design relevant settings can be made. These settings have to be made per view... CRM Tables and Transaction Codes TABLE NAME DESCRIPTION BUSINESS PARTNERS BUT000 BP: General data Contains Business Partner Number, Partner Category, Partne...

sapcrmtutorial.blogspot.in

3/27

8/31/12
Note:

SAP CRM Technical Tutorials by Naval Bhatt. Do_prepare_output and DO_PREPARE_OUTPUT method is triggered each time the view is prepared after each event. Normally we redefine this meth... SAP CRM Cross-application Authorization Objects OBJECT CLASS Definition /GC1/AUTH AAAB Authorization for Garbage Collector /SAPCND/CC AAAB Condition Technique: Authorizatio... Sample code for DO_CONFIG_DETERMINATION method This example is to set the visibility of a screen field based on another field ... METHOD do_config_determination. DATA: lr_btadmin... How to create POP-UP window in UI Open the component and then view where the pop up is to be raised. You must be raising the popup on some event... You will need to crea... Important abap function modules Useful ABAP Function Modules This page is intended to maintain documentation of useful function modules. This is needed because inde...

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 On_new_focus 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 w ith value nodes. DO_PREPARE_OUTPUT 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 4 6 4 2
Follow by Email
Email address... Submit

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

sapcrmtutorial.blogspot.in

4/27

8/31/12
Method Signatures:

SAP CRM Technical Tutorials by Naval Bhatt.

*"* 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 .

Method Implementations
MTO zr_rae EHD odcet. DT:l_odTP zr_tut AA szr YE odsrc. l_od=i_trbts szr satiue. l_odgi =i_e. szr-ud sky ISR l_odIT TBEg_od NET szr NO AL tzr. EDEHD NMTO. MTO zr_oiy EHD odmdf. FEDSMOS <szr>LK LN O g_od IL-YBL: f_od IE IE F tzr, <l> TP sml, od YE ipe <e> TP sml, nw YE ipe <ae TP nm_op nm> YE aekm. RA TBEg_odWT KYgi =i_e ASGIG<szr> ED AL tzr IH E ud sky SINN f_od. I s-ur E 0 F ysbc Q . LO A i_hne_ilsASGIG<ae. OP T tcagdfed SINN nm> ASG CMOET<ae O SRCUE<szr>T <l> SIN OPNN nm> F TUTR f_od O od. CEKs-ur =0 HC ysbc . ASG CMOET<ae O SRCUEi_trbtsT <e> SIN OPNN nm> F TUTR satiue O nw. CEKs-ur =0 HC ysbc . <l>=<e> od nw. EDOP NLO. EDF NI. EDEHD NMTO. MTO zr_eee EHD oddlt. DT:l_odLK LN O g_od AA szr IE IE F tzr. RA TBEg_odWT KYgi =i_e IT l_od ED AL tzr IH E ud sky NO szr. I s-ur E 0 F ysbc Q . ISR l_odIT TBEg_oddl NET szr NO AL tzr_e. DLT g_odWEEgi =i_e. EEE tzr HR ud sky EDF NI. EDEHD NMTO. MTO zr_ae EHD odsv.

sapcrmtutorial.blogspot.in

5/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.


DT:l_odTP zr_tuttb AA tzr YE odsrc_a, l_odLK LN O l_od szr IE IE F tzr. LO A g_od IT l_odWEErfgi =i_edrgi. OP T tzr NO szr HR e_ud vhae_ud ISR l_odIT TBEl_od NET szr NO AL tzr. EDOP NLO. I l_od]I NTIIIL F tzr[ S O NTA. MDF zr FO TBEl_od OIY od RM AL tzr. EDF NI. RFEHl_od ERS tzr. LO A g_oddl IT l_odWEErfgi =i_edrgi. OP T tzr_e NO szr HR e_ud vhae_ud ISR l_odIT TBEl_od NET szr NO AL tzr. EDOP NLO. I l_od]I NTIIIL F tzr[ S O NTA. DLT zr FO TBEl_od EEE od RM AL tzr. EDF NI. EDEHD NMTO. MTO zr_ed EHD odra. DT:l_odTP zr_tuttb AA tzr YE odsrc_a, l_odLK LN O l_od szr IE IE F tzr. *hc bfe frt Cek ufr is *fetisaefudi bfe,n ne t cekD a woebfe i ue. I nre r on n ufr o ed o hc B s hl ufr s sd *oseilpoiin frdltdies n pca rvsos o eee tm RA TBEg_odWT KYrfgi =i_edrgi TASOTN N FED. ED AL tzr IH E e_ud vhae_ud RNPRIG O ILS I s-ur E 0 F ysbc Q . e_od]=g_od] tzr[ tzr[. DLT e_odWEErfgi N i_edrgi. EEE tzr HR e_ud E vhae_ud ES. LE RA TBEg_oddlWT KYrfgi =i_edrgi TASOTN N FED. ED AL tzr_e IH E e_ud vhae_ud RNPRIG O ILS I s-ur E 0 F ysbc Q . *eee etiseiti bfe! = Tbehsaraybe bfee = N D Ra dltd nre xs n ufr! > al a led en ufrd > o B ed EI. XT ES. LE RFEHe_od ERS tzr. SLC *FO zr IT TBEe_odWEErfgi =i_edrgi. EET RM od NO AL tzr HR e_ud vhae_ud ISR LNSO e_odIT TBEg_od NET IE F tzr NO AL tzr. EDF NI. EDF NI. EDEHD NMTO. MTO zr_edsnl. EHD odra_ige DT:l_odTP zr_tuttb AA tzr YE odsrc_a, l_odLK LN O l_od szr IE IE F tzr. *hc bfe frt Cek ufr is *fetisaefudi bfe,n ne t cekD a woebfe i ue. I nre r on n ufr o ed o hc B s hl ufr s sd *oseilpoiin frdltdies n pca rvsos o eee tm RA TBEg_odWT KYgi =i_udIT l_od ED AL tzr IH E ud vgi NO szr. I s-ur E 0 F ysbc Q . ISR l_odIT tbee_od NET szr NO al tzr. ES. LE SLC *FO zr IT TBEe_odWEEgi =i_ud EET RM od NO AL tzr HR ud vgi. ISR LNSO e_odIT TBEg_od NET IE F tzr NO AL tzr. EDF NI. EDEHD NMTO. MTO zr_nt EHD odii. DT:l_odTP zr_tuttb AA tzr YE odsrc_a, l_odLK LN O l_od szr IE IE F tzr. I i_edrgi I NTIIIL F vhae_ud S O NTA. DLT g_odWEErfgi =i_edrgi. EEE tzr HR e_ud vhae_ud DLT g_oddlWEErfgi =i_edrgi. EEE tzr_e HR e_ud vhae_ud ES. LE RFEHg_od ERS tzr. RFEHg_oddl ERS tzr_e. EDF NI. EDEHD NMTO. MTO ZR_EEEWT_RE. EHD ODDLT_IHODR DLT FO zr WEErfgi =i_edrgi. EEE RM od HR e_ud vhae_ud EDEHD NMTO.

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

sapcrmtutorial.blogspot.in

6/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.


MTO i_r_utm_tlra_trbts EHD fcmrniebi~edatiue. DT:l_udTP cmtgi_tl AA sgi YE rs_udbi. *hsi asai ra-nyrlto. Ti s ttc edol eain *nei GI fo odr Ihrt UD rm re TY R. i_otoj>e_e(i_e_ud) rcn_b-stky vrfgi . CTHc_r_i_ulct_nr. AC xcmccdpiaeety EDR. NTY I i_otoj>hc_trrqetd )E tu. F rcn_b-cekat_euse( Q re l_udcmgi =i_e_ud sgi-r_ud vrfgi. m-statiue(i_otoj e>e_trbts rcn_b =i_otoj rcn_b i_trbts=l_ud satiue sgi i_e_id vrfkn =i_e_id vrfkn i_o_e vlgky =i_e_ud) vrfgi . EDF NI. *edudryn rltos Ra nelig eain I i_otoj>hc_esrqetd )E tu. F rcn_b-cekrl_euse( Q re m-acs_hlrn i_otoj=i_otoj e>cescide( rcn_b rcn_b i_aa rdt =i_p_aa raidt i_e_ud=i_e_ud vrfgi vrfgi i_e_id=i_e_id) vrfkn vrfkn . EDF NI. * EDEHD NMTO.

MTO I_R_UTM_TLMITI_TRBTS EHD FCMRNIEBI~ANANATIUE. DT:l_et TP cm_et. AA vdla YE rtdla ** * *hsi ara-nyrlto,ntigmc t d hr ecp ihrtGI fo Odrojc Ti s edol eain ohn uh o o ee xet nei UD rm re bet l_et =i_otoj>e_et_lg ) vdla rcn_b-gtdlafa( . I l_et E i_otoj>et_rae. F vdla Q rcn_b-dlacetd TY R. i_otoj>e_e(i_e_ud) rcn_b-stky vrfgi . CTHc_r_i_ulct_nr. AC xcmccdpiaeety EDR. NTY EDF NI. *aecr o udryn rltos Tk ae f nelig eain m-mdf_hlrn i_otoj e>oiycide( rcn_b =i_otoj rcn_b i_aa rdt =i_p_aa raidt i_nu_ils=i_nu_ils riptfed riptfed i_e_id vrfkn =i_e_id vrfkn i_e_ud vrfgi =i_e_ud) vrfgi . EDEHD NMTO. MTO MDF_HLRN. EHD OIYCIDE *ontrdfn ti mto!Sprcaswl tk cr o ti D o eeie hs ehd ue ls il ae ae f hs EDEHD NMTO.

ZORD_RUN_BTIL - Redefined methods

MTO fedhc. EHD ilcek *eeie t peetsse loigfruipeetdF rdfnd o rvn ytm okn o nmlmne M *mt,cet yu onipeetto epy rae or w mlmnain edehd nmto.

MTO i_r_utm_tlra_trbts EHD fcmrniebi~edatiue. DT:l_otcnanrTP RFT i_ei_otie_bet AA rro_otie YE E O fgnlcnanrojc, l_udTP cm_betgi, vgi YE rtojc_ud l_is TP cm_ola VLEtu, vfrt YE rtboen AU re l_eain TP cm_eainnm. vrlto YE rtrlto_ae DT:l_odiTP RFT zr_tuttb AA rzr_ YE E O odsrc_a, l_odiTP zr_tuttb tzr_ YE odsrc_a, l_trposTP RFT i_ei_b_trpoete, rat_rp YE E O fgnlojat_rpris l_otojTP RFT i_ei_otie_bet rcn_b YE E O fgnlcnanrojc. FEDSMOS <szr_>TP zr_tut IL-YBL: l_odi YE odsrc, <saidt> l_p_aa TP cm_nlygt YE rtita_e, <taidt> l_p_aa TP cm_nlygttb YE rtita_e_a. ** * CL MTO z_odbi_p=zr_ed AL EHD lzr_tlai>odra

sapcrmtutorial.blogspot.in

7/27

8/31/12

CL MTO z_odbi_p=zr_ed AL EHD lzr_tlai>odra EPRIG XOTN i_edrgi =i_e_ud"re GI vhae_ud vrfgi Odr UD IPRIG MOTN e_od tzr =l_odi tzr_. CL MTO i_otoj>e_aetrlto AL EHD rcn_b-gtprn_eain IPRIG MOTN e_eainnm =l_eain vrlto_ae vrlto.

SAP CRM Technical Tutorials by Naval Bhatt.

LO A l_odiASGIG<szr_> OP T tzr_ SINN l_odi. TY R. I l_is E tu. F vfrt Q re l_is =fle vfrt as. l_otoj=i_otoj rcn_b rcn_b. l_otoj>e_e(<szr_>gi ) rcn_b-stky l_odi-ud . ES. LE l_otoj=i_otoj>oysl_ihsrcue rcn_b rcn_b-cp_efwt_tutr( i_betky sojc_e =<szr_>gi l_odi-ud i_eainnm =l_eain) vrlto_ae vrlto . CEKl_otojI BUD HC rcn_b S ON. EDF NI. CTHc_r_i_ulct_nr. AC xcmccdpiaeety TY R. l_otoj=m-tr_ah i_otoj rcn_b e>unpt( rcn_b =i_otoj rcn_b i_eainnm =l_eain vrlto_ae vrlto i_e sky =<szr_>gi ) l_odi-ud . CTHc_r_ei_eea_ro. AC xcmgnlgnrlerr CNIU. OTNE EDR. NTY CTHc_r_ei_oe_ro. AC xcmgnlmdlerr CNIU. OTNE EDR. NTY I l_otoj>hc_trrqetd )E tu. F rcn_b-cekat_euse( Q re m-statiue(i_otoj e>e_trbts rcn_b =l_otoj rcn_b i_trbts=<szr_> satiue l_odi i_e_id vrfkn =i_e_id vrfkn i_o_e vlgky =<szr_>gi ) l_odi-ud . l_trpos=l_otoj>e_trposoj ) rat_rp rcn_b-gtat_rp_b( . l_trpos>e_l_rpris i_ei_b_trpoete=cagal ) rat_rp-stalpoete( fgnlojat_rpris>hnebe . l_trpos>e_rpryb_d(i_ne rat_rp-stpoet_yix vidx =1 i_au =i_ei_b_trpoete=ra_ny) "let vvle fgnlojat_rpris>edol . Cin l_trpos>e_rpryb_d(i_ne rat_rp-stpoet_yix vidx =2 i_au =i_ei_b_trpoete=tcncl) "UD vvle fgnlojat_rpris>ehia . GI l_trpos>e_rpryb_d(i_ne rat_rp-stpoet_yix vidx =3 i_au =i_ei_b_trpoete=tcncl) "E_UD vvle fgnlojat_rpris>ehia . RFGI EDF NI. I l_otoj>hc_esrqetd )E tu. F rcn_b-cekrl_euse( Q re m-gtfrini(i_otoj=l_otoj e>e_oeg_d rcn_b rcn_b i_aa sdt =<szr_>) l_odi . EDF NI. EDOP NLO. EDEHD NMTO. *

MTO i_r_utm_tlmiti_trbts EHD fcmrniebi~ananatiue. ICUEcmmd_o. NLD r_oecn DT:l_et AA vdla TP cm_et. YE rtdla DT:l_hne_betTP cm_ei_b_ntne AA scagdojc YE rtgnlojisac. DT:l_ae TP cm_trnm_a. AA tnms YE rtat_aetb DT:l_trposTP RFT i_ei_b_trpoete. AA rat_rp YE E O fgnlojat_rpris FEDSMOS <saidt>TP cmtodrmiti, IL-YBL: l_p_aa YE rs_re_anan <vnm> l_ae TP nm_op YE aekm. ** * DT:l_rp_b AA vposoj TP RFT i_ei_b_trpoete, YE E O fgnlojat_rpris l_hne_trTP cm_trnm_a, tcagdat YE rtat_aetb l_trbts satiue TP zr_tut YE odsrc, l_ud vgi TP cm_betgi, YE rtojc_ud * l_eun trtr TP bprt_, YE aie2t * l_s_ot vmgcn TP RFT c_r_ei_aims_ot YE E O lcmgnlbp_escn, l_b_nt sojis TP cm_ei_b_ntne YE rtgnlojisac, l_edr vhae TP RFT i_ei_otie_bet YE E O fgnlcnanrojc, l_edrgi vhae_ud TP cm_ei_betgi, YE rtgnlojc_ud l_edrat shae_tr TP cmtgi_tl YE rs_udbi. CEKi_otoj>e_ae )='OD. HC rcn_b-gtnm( ZR' l_b_ntojc_ae='OD. sojis-betnm ZR' "E NTX #C OET *rtiv teGI o tehae eree h UD f h edr l_edr=i_otoj>e_aet ) vhae rcn_b-gtprn( . CL MTO l_edr>e_e AL EHD vhae-gtky IPRIG MOTN e_e =l_edrgi. sky vhae_ud CL MTO l_edr>e_trbts AL EHD vhae-gtatiue IPRIG MOTN e_trbts=l_edrat. satiue shae_tr *rtiv tedlafa eree h et lg l_et =i_otoj>e_et_lg ) vdla rcn_b-gtdlafa( . *bac acrigt tedlafa.Dpnetojcsmyb cetd mdfe,o dltd rnh codn o h et lg eedn bet a e rae, oiid r eee.

sapcrmtutorial.blogspot.in

8/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.


CS l_et. AE vdla WE i_ei_otsml_bet>et_hne. HN fgnlcn_ipeojc=dlacagd * rtiv teatiuepoet ojc t gttemdf dtis eree h trbt rpry bet o e h oiy eal l_rp_b =i_otoj>e_trposoj ) vposoj rcn_b-gtat_rp_b( . * wihatiue wr mdfe? hc trbts ee oiid CL MTO l_rp_b-gtnm_a__rpry AL EHD vposoj>e_aetb4poet EPRIG XOTN i_rpry=i_ei_b_trpoete=mdfe vpoet fgnlojat_rpris>oiid IPRIG MOTN e_ae tnms =l_hne_tr tcagdat. CL MTO i_otoj>e_e AL EHD rcn_b-gtky IPRIG MOTN e_e =l_ud sky vgi. CL MTO i_otoj>e_trbts AL EHD rcn_b-gtatiue IPRIG MOTN e_trbts=l_trbts satiue satiue. * cl teAI al h P CL MTO z_odbi_p=zr_oiy AL EHD lzr_tlai>odmdf EPRIG XOTN i_e sky =l_ud vgi i_edrgi vhae_ud =l_edrgi vhae_ud i_trbts satiue =l_trbts satiue i_hne_ils=l_hne_tr tcagdfed tcagdat. IPRIG MOTN e_eun trtr =l_eun trtr e_hne_bet =l_hne_bet. tcagdojcs tcagdojcs l_b_ntojc_d=c_r_ei_otie_ol=bidojc_d l_ud) sojis-beti lcmgnlcnanrtos>ul_beti( vgi . adojc t tecagdojcsls d bet o h hne bet it ISR l_b_ntIT TBEg_nly>tcagdojcs NET sojis NO AL rita-g_hne_bet.

* * * *

WE i_ei_otsml_bet>et_rae. HN fgnlcn_ipeojc=dlacetd gtteatiuesrcue e h trbt tutr CL MTO i_otoj>e_trbts AL EHD rcn_b-gtatiue IPRIG MOTN e_trbts=l_trbts satiue satiue. * * bidteky ul h e * CL FNTO 'UDCET' AL UCIN GI_RAE * IPRIG MOTN * e_ud1 =l_ud vgi_6 vgi. i_otoj>e_e(IPRIGe_e =l_ud) rcn_b-gtky MOTN sky vgi . l_trbtsrfgi =l_edrgi. satiue-e_ud vhae_ud * cl teAI al h P CL MTO z_odbi_p=zr_rae AL EHD lzr_tlai>odcet EPRIG XOTN i_e sky =l_ud vgi i_trbts=l_trbts satiue satiue. * IPRIG MOTN * e_eun trtr =l_eun trtr. l_trbtsgi =l_ud satiue-ud vgi. i_otoj>e_trbts l_trbts) rcn_b-statiue( satiue . * * stnwky e e e TY R. i_otoj>e_e(l_ud) rcn_b-stky vgi . CTHc_r_ei_ulct_e. AC xcmgnldpiaeky EDR. NTY l_b_ntojc_d=c_r_ei_otie_ol=bidojc_d l_ud) sojis-beti lcmgnlcnanrtos>ul_beti( vgi . ISR l_b_ntIT TBEg_nly>tcagdojcs NET sojis NO AL rita-g_hne_bet.

WE i_ei_otsml_bet>et_eee. HN fgnlcn_ipeojc=dladltd gtojc ky e bet e CL MTO i_otoj>e_e AL EHD rcn_b-gtky IPRIG MOTN e_e =l_ud sky vgi. * cl teAI al h P CL MTO z_odbi_p=zr_eee AL EHD lzr_tlai>oddlt EPRIG XOTN i_e sky =l_ud vgi i_edrgi =l_edrgi. vhae_ud vhae_ud * IPRIG MOTN * e_eun trtr =l_eun trtr * e_hne_bet =l_hne_bet. tcagdojcs tcagdojcs l_b_ntojc_d=c_r_ei_otie_ol=bidojc_d l_ud) sojis-beti lcmgnlcnanrtos>ul_beti( vgi . ISR l_b_ntIT TBEg_nly>tcagdojcs NET sojis NO AL rita-g_hne_bet. EDAE NCS. * *elteOdrAIta acag hshpee Tl h re P ht hne a apnd *hswl rgse orojc frsv (h F w rgsee frSV eeti eethnlrtbe Ti il eitr u bet o ae Te M e eitrd o AE vn n vn ade al) CL FNTO 'R_VN_ULS_W AL UCIN CMEETPBIHO' EPRIG XOTN i_b_ae='OD vojnm ZR' i_udh vgi_i =l_edrgi vhae_ud i_idh vkn_i =g_betkn-reamh cojc_idodrd_ i_vn veet =g_vn-fe_hne ceetatrcag. EDEHD NMTO.

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.

sapcrmtutorial.blogspot.in

9/27

8/31/12
1. Initialization

SAP CRM Technical Tutorials by Naval Bhatt.

FNTO zr_nte. UCIN odii_c *----------------------------------"----------------------------------**LclItrae ""oa nefc: * " IPRIG MOTN * " RFRNEI_EDRGI)TP EEEC(VHAE_UD YE CM_BETGI OTOA RTOJC_UD PINL *----------------------------------"----------------------------------I i_edrgi I NTIIIL F vhae_ud S O NTA. CL MTO Z_ODBI_P=ZR_NT AL EHD LZR_TLAI>ODII EPRIG XOTN i_edrgi =i_edrgi. vhae_ud vhae_ud EDF NI. EDUCIN NFNTO.

2. Save

FNTO zr_aee. UCIN odsv_c *----------------------------------"----------------------------------**LclItrae ""oa nefc: * " IPRIG MOTN * " RFRNEI_BETNM)TP EEEC(VOJC_AE YE CM_BETNM RTOJC_AE * " RFRNEI_VN_XTM)TP EEEC(VEETEEIE YE CM_VN_XTM RTEETEEIE * " RFRNEI_VN)TP EEEC(VEET YE CM_VN RTEET * " RFRNEI_EDRGI)TP EEEC(THAE_UD YE CM_BETGI_A RTOJC_UDTB *----------------------------------"----------------------------------Dt:l_edrgi tp cm_betgi. aa vhae_ud ye rtojc_ud lo a i_edrgi it l_edrgi. op t thae_ud no vhae_ud CL MTO Z_ODBI_P=ZR_AE AL EHD LZR_TLAI>ODSV EPRIG XOTN i_edrgi =l_edrgi. vhae_ud vhae_ud edop nlo. EDUCIN NFNTO.

3. Delete

FNTO zr_e_c UCIN oddle. *----------------------------------"----------------------------------**LclItrae ""oa nefc: * " IPRIG MOTN * " RFRNEI_BETNM)TP EEEC(VOJC_AE YE CM_BETNM RTOJC_AE * " RFRNEI_VN_XTM)TP EEEC(VEETEEIE YE CM_VN_XTM RTEETEEIE * " RFRNEI_VN)TP EEEC(VEET YE CM_VN RTEET * " RFRNEI_EDRGI)TP EEEC(VHAE_UD YE CM_BETGI OTOA RTOJC_UD PINL *----------------------------------"----------------------------------*s F "R_REAMHRA_B wt icuedltdhae oto t esr ta ojc i rlvn t u Ue M CMODRD__EDO" ih nld_eee_edr pin o nue ht bet s eeat o s *-bfr cligAImto eoe aln P ehd I i_edrgi I NTIIIL F vhae_ud S O NTA. *eeefo ojc bfe Dlt rm bet ufr CL MTO Z_ODBI_P=ZR_NT AL EHD LZR_TLAI>ODII EPRIG XOTN i_edrgi =i_edrgi. vhae_ud vhae_ud *eeefo dtbs Dlt rm aaae CL MTO Z_ODBI_P=ZR_EEEWT_RE AL EHD LZR_TLAI>ODDLT_IHODR EPRIG XOTN i_edrgi =i_edrgi. vhae_ud vhae_ud EDF NI. EDUCIN NFNTO.

sapcrmtutorial.blogspot.in

10/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

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

No comments:

+2 Recommend this on Google

Labels: Extend BOL Model BT with custom table type relationship, sap crm tutorial, SAP CRM

sapcrmtutorial.blogspot.in

11/27

8/31/12
tutorials

SAP CRM Technical Tutorials by Naval Bhatt.

Friday, August 24, 2012

Extend BOL Model for BP with Custom Table and Implement GenIL Class
Details of how to Extend BOL Model for BP with Custom Table and Implement GenIL Class are in the below PDF link . http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/4048d161-9ac1-2e10-3bbfbaef73d78109?QuickLink=index&overridelayout=true

Posted by Naval Bhatt at 10:04 PM

No comments:

+2 Recommend this on Google

Labels: Extend BOL Model for BP with Custom Table and Implement GenIL Class, GENIL class, SAP CRM tutorials, sap crm BOL programming, sap crm tutorial

Tuesday, August 21, 2012

How to use your custom BOL Object for webclient within assignment block.
How to use your custom BOL Object for webclient within assignment block.
We created the BOL object in one of our old blog http://sapcrmtutorial.blogspot.sg/2012/02/create-z-bol-object.html that meet your personal requirements. Now that w e have our BOL Object w e might w ant to use it for our purposes. Let's say that w e w ant to add several fields to assignment block and display them on the screen, for instance w e take the fields from our Z table that w e use in the creation of our BOL Object. We also w ant to keep the connection for the original transaction context . The steps for doing that are : 1) We need to add a field to our Z table BP_GUID w hich w ill keep us connected to the main transaction context . 2) Perform the adjustment for the Z Table. 3) Search for the right BP_GUID that fit to our user account. 4) create new record that contain the details that w e w ant to display for the specific account. See the follow ing screen shot.

Now w e need to perform some adjustment for our table . choose the Database Utility from the menu . See the follow ing screen shot.

sapcrmtutorial.blogspot.in

12/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

once you choose this option you'll get the next screen :

In our case w e w ill choose the Delete data option becuse w e w ant to create a new record, you also have to know that if you choose the Save data option there's no 100 percent guarantee that your data in the table w ill be saved , so you should consider the use of Database Utility very careful. After w e perform the adjustment and activated the table w e can step forw ard to the next step w hich is the creation of a new record w ith the details that w e w ant to display on the screen . First to the record creation w e should find the key w hich is the BP_GUID that w ill connect us to the account context . To find the right BP_GUID enter transaction GENIL_BOL_BROWSER and insert the BP_APPL_COND in the component set field. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

13/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

w hen you enter to the component set choose the predefined search named BuilEm pSearch See the follow ing screen shot.

Now w e can look for any partner , in my case i'll choose to search my user and i'll get the compatible BP_GUID w hich is : DF21EBC73A26F8F1A2B0001F29644FC0 See the follow ing screen shot.

Now let's create a new record in the DataBase table ZUSR_BOL_TB w ith user name, BP_GUID , First and last names. See the follow ing screen shot.

For now w e finish w ith the database side and w e w iil go to perform some improvement in our BOL object to support the

sapcrmtutorial.blogspot.in

14/27

8/31/12
different searching options.

SAP CRM Technical Tutorials by Naval Bhatt.

So let's go to transaction SE24 and put ZCL_OWN_BOL in the input filed. click on Local Types button and put the lines inside : *------------------------------------------------------------TYPES: BEGIN OF ty_general_rng , sign TYPE bapisign, option TYPE bapioption, low TYPE string , high TYPE string , END OF ty_general_rng . TYPES: tt_general_rng TYPE STANDARD TABLE OF ty_general_rng . See the follow ing screen shot:

Now go back to the method list and edit the method :IF_GENIL_APPL_INTLAY~GET_DYNAMIC_QUERY_RESULT replace the exisiting code w ith the bellow lines: *------------------------------------------------------------------------------------------METHOD if_genil_appl_intlay~get_dynamic_query_result. DATA: lr_object TYPE REF TO if_genil_cont_root_object, lt_result TYPE TABLE OF zusr_bol_st, lv_dyn_w here TYPE string, lv_len TYPE i , ls_range TYPE ty_general_rng. DATA: lt_bp_guid TYPE tt_general_rng, lt_bname_range TYPE tt_general_rng, lt_name_first TYPE tt_general_rng, lt_name_last TYPE tt_general_rng. FIELD-SYMBOLS: <lfs_result> TYPE zusr_bol_st, <lfs_selection_range> TYPE genilt_selection_parameter. decomposition of selection parameters and build a dynamic w here condition LOOP AT it_selection_parameters[] ASSIGNING <lfs_selection_range>. MOVE: <lfs_selection_range>-sign TO ls_range-sign , <lfs_selection_range>-option TO ls_range-option , <lfs_selection_range>-low TO ls_range-low , <lfs_selection_range>-high TO ls_range-high. CASE <lfs_selection_range>-attr_name. WHEN 'BNAME'. APPEND ls_range TO lt_bname_range[]. CONCATENATE lv_dyn_w here 'bname in lt_bname_range[] and' INTO lv_dyn_w here SEPARATED BY space . WHEN 'BP_GUID'. APPEND ls_range TO lt_bp_guid[]. CONCATENATE lv_dyn_w here 'bp_guid in lt_bp_guid[] and' INTO lv_dyn_w here SEPARATED BY space . WHEN 'NAME_FIRST'. APPEND ls_range TO lt_name_first[]. CONCATENATE lv_dyn_w here 'name_first in lt_name_first[] and' INTO lv_dyn_w here SEPARATED BY space .

sapcrmtutorial.blogspot.in

15/27

8/31/12
WHEN 'NAME_LAST'.

SAP CRM Technical Tutorials by Naval Bhatt.


APPEND ls_range TO lt_name_last[]. CONCATENATE lv_dyn_w here 'name_last in lt_name_last[] and' INTO lv_dyn_w here SEPARATED BY space . ENDCASE. ENDLOOP. TRANSLATE lv_dyn_w here TO UPPER CASE. lv_len = STRLEN( lv_dyn_w here ) - 4 . "remove the last 'AND' in the condition lv_dyn_w here = lv_dyn_w here(lv_len) . CHECK STRLEN( lv_dyn_w here ) > 0. SELECT * FROM zusr_bol_tb INTO TABLE lt_result[] WHERE (lv_dyn_w here). CHECK LINES( lt_result[] ) > 0. LOOP AT lt_result[] ASSIGNING <lfs_result>. lr_object = iv_root_list->add_object( iv_object_name = 'Root' is_object_key = <lfs_result>-bname ). CHECK lr_object IS BOUND. lr_object->set_query_root( abap_true ). ENDLOOP. ENDMETHOD. *-------------------------------------------------------------------------------------------------------------------Save and activate your code. We might w ant to add the BNAME ,NAME_LAST,NAME_FIRST fields to a view that w e w ill create Personally I choose the BP_HEAD component but you can choose any component that you may use. OK. So let's get in and execute transaction BSP_WD_CMPWB_NEW and choose BP_HEAD component w ith our enhancement set w hich is specifically in my case called ZENH_CRM and hit the display button and go to Runtime Repository Editor, open the MODELS folder to see w ith w hich BOL component set the BP_HEAD component use. See the follow ing screen shot.

We can see now that the component BP_HEAD use the Model BP_APPL_COND and w e w ant that our BOL object w ill appear in the repository of the BP_HEAD component so that w e can use it for our purpose. To do that w e need to go to the component set definition. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

16/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

Now choose the appropriate component set w hich is in our case BP_APPL_COND. See the follow ing screen shot.

Now click on component assignment make new entry and add our BOL object named ZBOLOB. See the follow ing screen shot.

Don't forget to save the new entry. After you saved it successfully enter again to BSP_WD_CMPWB_NEW transaction w ith BP_HEAD component and click on the BOL Model Brow ser tab, w e w ant to check here that w e can see our BOL entity ready for use. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

17/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

Now w e can see that our BOL entity Root that w e created is ready for use in the enhancement of BP_HEAD component. We w ill go to Component Structure Brow ser tab and create our view . See the follow ing screen shot.

We'll choose a name for our view . See the follow ing screen shot.

sapcrmtutorial.blogspot.in

18/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

After w e named the view w e need to add 2 model nodes, one for BuilHeader and one For our Root BOL object. The first one is for getting the relevant BP_GUID from the custom controller and get the appropriate first name last name and user name according to our table . See the follow ing screen shot.

The next step is to add the fields that w e might use in our view to context w hich w e w orking on. We start w ith the BuilHeader fields. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

19/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

We use also attributes from the Root BOL object . See the follow ing screen shot.

We got the w hole attributes as show n bellow . See the follow ing screen shot.

We move to the next step. Here w e need to define the view type and its properties.

sapcrmtutorial.blogspot.in

20/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.


The view type w e choose form view w ithout buttons and in the properties w e make it configurable and that for keep to our self the option to Add/Remove Attributes from the view . See the follow ing screen shot.

Now w e finish the view addition w ith the w izard w e w ill see that our view is listed w ith the other view s in the component. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

21/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

After w e added the view w e should create a binding to the custom controller context node BUILHEADER. So w e put the mouse curser on the context node BUILHEADER pressing the right mouse Click and create the binding. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

22/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

We w ill create the binding for our context node to the same context node in the custom controller. See the follow ing screen shot.

After w e create the appropriate binding w e need to add the attributes to the view . So w e move to the configuration tab w hen w e w orking on the view and then w e sw itch to edit mode. We see that w e have the 2 BOL objects that w e added w hen w e w orking w ith the w izard in time of the view creation. In our case w e w ill add the attributes from the Root BOL object. See the follow ing screen shot.

After w e add the attributes to our view w e need to add our view as an assignment block. First w e need to add our view to the BPHEADOverview view set , to do this w e w ill go to the Runtime Repository Editor and w e w ill add our view to the Overview Page of BPHEADOverview view set . See the follow ing screen shot.

sapcrmtutorial.blogspot.in

23/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

After w e added the view to the BPHEADOverview view set w e w ill go to the configuration tab of BPHEADOverview view set and sw itch to edit mode and add our view TestBOLroot to the list of view s that appears as an assignment blocks in the BPHEADOverview view set by click on the arrow button and moving it from the left side to the right side . See the follow ing screen shot.

After w e handle the addition of adding our view as an assignment block w e need to handle some code addtions for the right treatment in the attributes in our view . First w e w ill go to the ROOT context node w ithin our view and redefine the method IF_BSP_MODEL~INIT. See the follow ing screen shot.

sapcrmtutorial.blogspot.in

24/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

Put the next ilnes into the method save and aactivate the method. *------------------------------------------------------------------------------------------method IF_BSP_MODEL~INIT. TYPES: BEGIN OF ltype_attr_struct, mandt TYPE mandt, bp_guid TYPE bu_partner_guid, bname TYPE xubname, name_last TYPE bu_namep_l, name_first TYPE bu_namep_f, END OF ltype_attr_struct. DATA: lrf_data_struct TYPE REF TO ltype_attr_struct, lrf_value_node TYPE REF TO cl_bsp_w d_value_node, lrf_bol_collection TYPE REF TO if_bol_bo_col. super->if_bsp_model~init( id = id ow ner = ow ner ). CREATE DATA lrf_data_struct. CREATE OBJECT lrf_value_node EXPORTING iv_data_ref = lrf_data_struct. CREATE OBJECT lrf_bol_collection TYPE cl_crm_bol_bo_col. lrf_bol_collection->add( lrf_value_node ). me->set_collection( lrf_bol_collection ). endmethod. *------------------------------------------------------------------------------------------After w e add the above lines to the method w e w ill go to the implementation class of our view , w hich is in our case is ZL_ZBP_HEAD_TESTBOLROOT_IMPL. w e w ill double click on the class name and w e w ill move to display mode of the class in a w ay that all the method could be show n. The first thing to do is to w rite our ow n method for performing the right query w hen w e need to display the attributes on the screen . After that w e w ill redefine the method DO_PREPARE_OUTPUT. so let's create a new method named root_query w hich is an Instance Method , and the visibility of it is Private. put the next lines to the method . *-----------------------------------------------------------------------------------------METHOD root_query. DATA: lrf_advanced_query TYPE REF TO cl_crm_bol_dquery_service, lrf_root_result_collection TYPE REF TO if_bol_entity_col, lrf_root_result_bol_entity TYPE REF TO cl_crm_bol_entity, lrf_current_root TYPE REF TO if_bol_bo_property_access, lrf_current_builheader TYPE REF TO if_bol_bo_property_access, lt_params TYPE crmt_name_value_pair_tab, ls_params TYPE crmt_name_value_pair, ls_builheader_properties TYPE crmst_header_object_buil, lv_low _value TYPE string , ls_root_properties TYPE zusr_bol_st. ls_params-name = 'MAX_HITS' . ls_params-value = '1'. "w e don't need in this case more the single record for result

sapcrmtutorial.blogspot.in

25/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.


APPEND ls_params TO lt_params. lrf_current_root ?= me->typed_context->root->collection_w rapper->get_current( ). CHECK lrf_current_root IS BOUND . lrf_current_root->get_properties( IMPORTING es_attributes = ls_root_properties ). CHECK ls_root_properties IS INITIAL . " means that w e don't have any values in our "fields and therfore w i'll excute the query lrf_current_builheader ?= me->typed_context->builheader->collection_w rapper->get_current( ). CHECK lrf_current_builheader IS BOUND . lrf_current_builheader->get_properties( IMPORTING es_attributes = ls_builheader_properties ). CHECK ls_builheader_properties-bp_guid IS NOT INITIAL . lv_low _value = ls_builheader_properties-bp_guid. lrf_advanced_query = cl_crm_bol_dquery_service=>get_instance( 'Search' ). lrf_advanced_query->set_query_parameters( it_parameters = lt_params ). lrf_advanced_query->add_selection_param( iv_attr_name = 'BP_GUID' iv_sign = 'I' iv_option = 'EQ' iv_low = lv_low _value iv_high = '' ). lrf_root_result_collection = lrf_advanced_query->get_query_result( ). IF lrf_root_result_collection IS BOUND . "if w e found something that match our selection lrf_root_result_bol_entity = lrf_root_result_collection->get_first( ). lrf_root_result_bol_entity->get_properties( IMPORTING es_attributes = ls_root_properties ). lrf_current_root->set_properties( is_attributes = ls_root_properties ). ENDIF. ENDMETHOD. *---------------------------------------------------------------------------------------Save and activate your code . the next step is to redefine the method DO_PREPARE_OUTPUT. put the next lines into the method . *---------------------------------------------------------------------------------------method DO_PREPARE_OUTPUT. CALL METHOD SUPER->DO_PREPARE_OUTPUT EXPORTING iv_first_time = iv_first_time. me->ROOT_QUERY( ). endmethod. *---------------------------------------------------------------------------------------save and activate your code . Now all job is done our BOL object is w roking like a Rolls-Royce and it's time to derive pleasure from . We w ill go to the w ebclient , choose our account and display it . w e can see that w e have our attributes show n on the screen . See the follow ing screen shot.

sapcrmtutorial.blogspot.in

26/27

8/31/12

SAP CRM Technical Tutorials by Naval Bhatt.

Posted by Naval Bhatt at 8:08 AM

No comments:

+2 Recommend this on Google

Labels: How to use your custom BOL Object for webclient within assignment block. custom bol in assignment block, SAP CRM tutorials, sap crm BOL programming

Home
Subscribe to: Posts (Atom)

Older Posts

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

sapcrmtutorial.blogspot.in

27/27

Você também pode gostar