Sie sind auf Seite 1von 4

1/8/2015 HowtoimplementdatalosspopupCRMSCNWiki

GettingStarted Newsletters Store

Welcome,Guest Login Register SearchtheCommunity


Products Services&Support AboutSCN Downloads

Industries Training&Education Partnership DeveloperCenter

LinesofBusiness UniversityAlliances Events&Webinars Innovation

CRM / / CRMWebClientUIFramework

Howtoimplementdatalosspopup
AddedbyGuest,lasteditedbyNicolasBussononJan07,2014

Summary
YouwillfindmanyblogsandwikisonSCNaboutthecreationofyourownWebUIcomponent...thisarticlewillshowyouhowtointegrateitfurtherintotheUIframeworkinordertodisplayadatalosspopup
eachtimeausergetsoutofyourcomponentwithoutsaving.

Step1:createmethodON_BEFORE_WA_CONTENT_CHANGE
Thismethodwillbecalledtodecidewetherornotthedatalosspopupshouldbedisplayedwhentheuserisexitingacomponent.Agoodandverysimplecodingexamplecanbefoundinmainwindowof
standardcomponentBP_HIER(BusinesPartnerhierarchy).SoyoumightwanttocopymethodCL_BP_HIER_MAINWINDOW_IMPL~ON_BEFORE_WA_CONTENT_CHANGEtoyourowncomponent
mainwindowandadaptitinorderto:

1)Checkifsaveisneeded
Samplecoding(inthefollowinglinesweassumethatlr_entityistherootentityofyourZcomponent):
lr_tx=lr_entity>get_transaction().
lv_save_needed=lr_tx>check_save_needed().

2)Delegatetodatalosshandlerincasethepopupshouldbedisplayed
Samplecoding:
data_loss_handler>set_save_handler(me).
data_loss_handler>set_revert_handler(me).
data_loss_handler>set_cancel_handler(me).
data_loss_handler>trigger_data_loss_handling().

http://wiki.scn.sap.com/wiki/display/CRM/Howto+implement+dataloss+popup 1/4
1/8/2015 HowtoimplementdatalosspopupCRMSCNWiki

3)Eventuallyreleaselockifnothingtosave
Samplecoding:
IFlr_entity>is_locked()EQabap_true.
lr_tx>revert(iv_suppress_buffer_sync=abap_true).
ENDIF.

Remark:payattentiontoON_BEFORE_WA_CONTENT_CHANGEdefinition...Thismethodshouldbemarkedaseventhandlerfor
CL_BSP_WD_VIEW_MANAGER~BEFORE_WORKAREA_CONTENT_CHANGE,otherwiseitwon'twork:

Step2:redefinemethodDO_VIEW_INIT_ON_ACTIVATION
AgainyouwillfindcodingexampleinmainwindowofcomponentBP_HIER.Hereisthelineweareinterestedin:
SETHANDLERon_before_wa_content_changeACTIVATIONabap_true.

Step3:implementmethodIF_BSP_WD_EVENT_HANDLER~HANDLE_EVENT

http://wiki.scn.sap.com/wiki/display/CRM/Howto+implement+dataloss+popup 2/4
1/8/2015 HowtoimplementdatalosspopupCRMSCNWiki

Lastthingtodo:addinterfaceIF_BSP_WD_EVENT_HANDLERtoyourcomponentmainwindow,andimplementmethodIF_BSP_WD_EVENT_HANDLER~HANDLE_EVENT.Thismethodwillbecalled
whentheuserclicksonabuttoninthedatalosspopup,soyoushouldimplementyourlogicforeachpossibleevent:

CASEiv_event_name.
WHENif_bsp_wd_data_loss_handler=>save_event.
...
WHENif_bsp_wd_data_loss_handler=>revert_event.
...
WHENif_bsp_wd_data_loss_handler=>cancel_event.
...
ENDCASE.

Conclusion
Youcanveryeasilyimplementthisdatalosspopupinyourowncomponentsassoonasyouimplementthose3methodsabove.Ididn'tmentionedalotofcodingonpurposebecauseeachimplementation
willbedifferent.Onthecontrary:Irecommendtohavealookatstandardcomponentsinstead(likeBP_HIERwhichisquitesimple).Ihopethiswikigaveyouenoughhintstoknowwheretolookandfind
yourway...

Remark:undersomecircumstancesyoumaywanttoswitchoffthedatalosspopup.Forexamplewhenthemainentityisdeleted:mostofthetimeyouwillnavigateautomaticallyoutsideofyourcomponent
afterthedeletion,andyoumaynotwanttoseeanydatalosspopup...SocreatemethodBEFORE_CONTENT_CHANGE_OFFinyourmainwindowcontrollerwiththefollowingcode:

SETHANDLERon_before_wa_content_changeACTIVATIONabap_false.

Andcallitafterthesuccessfuldeletionofyourentity.HencethemethodofyourDELETEbuttonintherelevantviewmaylooklikethis:

IFlr_entity>lock()EQ'X'.
lr_entity>delete().

"Switchoffdatalosspopup...
lr_window_controller?=me>view_manager>get_window_controller().
lr_window_controller>before_content_change_off().

"Navigate
op_tosearch().
ENDIF.

Relatedcontent
CRM7.0Howto5ACreateacustomcomponentwithasimpleview
CRM7.0Howto5BCreateanOverviewPagewithcontent
CRM7.0Howto5CEventHandlingandNavigation
http://wiki.scn.sap.com/wiki/display/CRM/Howto+implement+dataloss+popup 3/4
1/8/2015 HowtoimplementdatalosspopupCRMSCNWiki


crm webui dataloss popup component save on_before_wa_content_chang

ContactUs SAPHelpPortal
Privacy TermsofUse LegalDisclosure Copyright FollowSCN

http://wiki.scn.sap.com/wiki/display/CRM/Howto+implement+dataloss+popup 4/4

Das könnte Ihnen auch gefallen