I had to do some digging to figure this one out. I have to give all of the credit to the link I found below. This is geared toward a Non-Portal application, Like my Rapier application. It gives some great pointers on dynamically setting the theme within a web dynpro application.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/7015b1f9-535c-2910-c8b7-e681fe75aaf8?QuickLink=index&overridelayout=true&8053063684070
Here’s the quick details.
1. In your application, add a parameter RUN. You can use Type String, C or whatever you want. This is just a flag. I also added the WDFORCEEXTERNALSTYLESHEET = X. I’ll be honest, I’m not sure if I need this or not. From what I’ve read, this is required if you’re using the portal. I’m not using the portal, but it works if I set this parameter, so I left it.
2. Now, go to your main window.
3. Add an outbound plug of type EXIT. Be sure to give it a parameter of URL. If you read my or used my post on the logoff button, you already have this =)
4. Add an inbound plug (or use the default plug). You need a startup plug is the only key here. Now double click on it to go into the code.
5. Once in the code, add the parameter of Run here. and add the following code (or a variation of it).
CALL METHOD CL_WD_UTILITIES=>CONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ‘XXX’ “Your web dynpro applicaiton name
IMPORTING
OUT_ABSOLUTE_URL = lv_e_url.
if run is INITIAL.
CONCATENATE lv_e_url
‘?sap-ep-themeroot=/SAP/PUBLIC/BC/UR/NW5/THEMES/SAP_HIGHCONT’
‘&run=N’ INTO lv_e_url.
wd_this->fire_logoff_exit_plg( url = lv_e_url ).
endif.
Here’s what happens. The first time you log into the application, it works like normal, but run is initial. so it leaves the current application, and re-runs it with the additional parameters of you set above.
Now I did run into some strange behavior. I kept getting a dump because of parameter run. I implemented OSS Note: 946490, still no luck. I finally just entered a value into the RUN parameter in the application, and then blanked it out. Then it finally worked. Not sure what the deal was, but hope it helps you out.
Thanks for reading and I hope this helps…
As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,Mike
Hi,
If you set to: sap-ep-themeroot=/SAP/PUBLIC/BC/UR/NW5/THEMES/SAP_HIGHCONT, then this theme will be set. Can I derive the theme in runtime based on calling or origin application?
Absolutely. In fact, in my application, I leave the theme as a variable and bring in the value from a table. The concept is just building the URL. You can do this within a method, typically within your main window.
Thanks,
Mike