You are on page 1of 5

3/22/2017 ProgrammaticallyClosingyourABAPWebDynproApplication|SAPBlogs

GetStarted

Solutions Support Training Community Developer Partner About

Community / Blogs

ProgrammaticallyClosingyourABAPWebDynpro
Application
March8,2013 | 28Views |
PhilipJohnston
morebythisauthor

UIWebDynproABAP
abapwebdynpro | dynpro | tutorial | WebDynpro | webdynproabap | webdynproabap

share
0 share
0 tweet share
0

Follow

https://blogs.sap.com/2013/03/08/programmaticallyclosingyourabapwebdynproapplication/ 1/5
3/22/2017 ProgrammaticallyClosingyourABAPWebDynproApplication|SAPBlogs

ClosinganABAPWebDynproapplicationautomaticallycansometimesbeusefulifyoudonot
wantanyfurtherprocessingtotakeplaceaftertheuserhascompletedatransactionflow.Note
thatwithEHP6,thebrowserwindowcloseswithoutnotificationtotheuser.PriortoEHP6,the
userreceivedthetypicalIEpopupwithinformationthatthebrowserisgoingtobeclosed.For
thatreason,youmaywanttoincludeapopupmessagepriortocallingtheexitlogicifyouwishto
warntheuser.Ofcourse,thisonlyappliesifyouareatEHP6orlater.

Forthisexample,IcreatedasimpleWebDynproasfollows:

OntheMainWindow,CreateanExitPlugasfollows:

https://blogs.sap.com/2013/03/08/programmaticallyclosingyourabapwebdynproapplication/ 2/5
3/22/2017 ProgrammaticallyClosingyourABAPWebDynproApplication|SAPBlogs

IntheCOMPONENTCONTROLLERr,createthefollowingattribute:

IntheCOMPONENTCONTROLLER,createthefollowingmethod:

methodexit.

datal_win_cntrtypereftoif_wd_window_controller.
datal_windowtypereftoif_wd_window.
datal_parameter_listtypewdr_event_parameter_list.
datal_parametertypewdr_event_parameter.
datal_valtypereftodata.

fieldsymbols<fs>typeany.
l_parametername=CLOSE_WINDOW.
createdatal_valtypec.
assignl_val>*to<fs>.
<fs>=X.
l_parametervalue=l_val.
insertl_parameterintotablel_parameter_list.
wd_this>main_win_controller>if_wd_view_controller~fire_plug(exportingplug_name=EXIT_PLUG
parameters=l_parameter_list) .

endmethod.

IntheMainView,addthefollowingcodetotheWDDOINITMethod:

methodwddoinit.

datal_view_cntrtypereftoif_wd_view_controller.

l_view_cntr=wd_this>wd_get_api() .
wd_comp_controller>main_win_controller?=l_view_cntr>get_embedding_window_ctlr() .

https://blogs.sap.com/2013/03/08/programmaticallyclosingyourabapwebdynproapplication/ 3/5
3/22/2017 ProgrammaticallyClosingyourABAPWebDynproApplication|SAPBlogs

endmethod.

Addabuttontothisview(oranyotherviewembeddedwithinthemainview)thatwillbewherewe
calltheexitcommand.AddamethodtotheOnActioneventofthebuttonandinsertthefollowing
codetocallyourexitcommandonthecomponentcontroller.

methodonactionexit.

datalo_componentcontrollertypereftoig_componentcontroller.
lo_componentcontroller=wd_this>get_componentcontroller_ctr() .
lo_componentcontroller>exit() .

endmethod.

Activate,Save,andcreateanapplicationsoyoucanexecuteandtest.Youwillseethatwhen
youhittheexitbuttononyourview,thebrowserwindowclosesautomatically.ThereasonI
structuredthecodesuchthattheactualexitcodeisonthecomponentcontroller,issoyoucan
haveasmanyembeddedviewsunderyourmainviewandcalltheexitfromanywhere.Oryou
mightevenpassareferencetothecontrollertoanotherreferencedclasswhichhandlestheexit
decisions.

AlertModerator

Bethefirsttoleaveacomment
YoumustbeLoggedontocommentorreplytoapost.

https://blogs.sap.com/2013/03/08/programmaticallyclosingyourabapwebdynproapplication/ 4/5
3/22/2017 ProgrammaticallyClosingyourABAPWebDynproApplication|SAPBlogs

Share & Follow Privacy TermsofUse LegalDisclosure Copyright Trademark Sitemap Newsletter

https://blogs.sap.com/2013/03/08/programmaticallyclosingyourabapwebdynproapplication/ 5/5

You might also like