Download - Web Dynpro Abap _ Scn5
Getting Started Newsletters Store
Products Services amp Support About SCN Downloads
Industries Training amp Education Partnership Developer Center
Lines of Business University Alliances Events amp Webinars Innovation
Login RegisterWelcome Guest Search the Community
Activity Communications Actions
Brow se
Web Dynpro ABAP 116 Posts 1 hellip 3 4 5 6 7 8
PreviousNext
Direct Mapping Reverse Mapping
Please refer to picture 626 Please refer to picture 628
Component Component
Y_EM_CONTEXT Y_EM_CONTEXT_RM
1 get records from Database 1 get records from Database
2 doesnt contain any view 2 a view to embed interface view
3 define a node STUDENT with attribute 3 define usage of component Y_EM_LAYOUT_RM
Interface Node Yes (can access by other component) 4 define a InterfaceController_usage mapping Student to that of
Y_EM_LAYOUT_RM
Input Element NO (cant Input by other comp ) 5 In WDDOINIT append some records to Node STUDENT
4 In WDDOINIT append some records to Node STUDENT Y_EM_LAYOUT_RM
Y_EM_LAYOUT 1 show records in a table
1 show records in a table 2 define a node STUDENT with attribute
2 define usage of component Y_EM_CONTEXT Interface Node Yes (can access by other component)
3 mapping the two STUDENT from Y_EM_CONTEXT and
Y_EM_LAYOUT in tab context
Input Element Yes ( Input by Y_EM_CONTEXT_RM)
372 View s 0 Comments Tags w eb_dynpro mapping direct reverse
Direct and Reverse mapping
Posted by he longyang Apr 10 2013
Below are the highlights of the new SAP Corbu theme for Web Dynpro ABAP
Corbu Theme for WebDynpro ABAP
Posted by Tarun Telang Apr 8 2013
Highlights of the new SAP Corbu theme for Web Dynpro ABAP
A new modern simple looking theme with improved overall look
Neutral design with light panes and flat surfaces
Reduced contrasts amp gradients create a light and clear user interface
Color Reduced use of neutral and dimmed colors increases the compatibility with other SAP designss
Structure Less structuring and separating elements to support a flat and lightweight appearance
Correct Prioritization Visual focus is on the content instead of on navigation and functions
Tables amp Containers Reduced colors and line contrast creates a less block-like appearance
Increased font sizes to improve readability
Readability Enlarged and easier to read typography for example larger font
Enhanced look for specific controls
new panel stack visualizations
new calendar design
Large set of new icons and pictograms that are modernized with new theme without affecting existing icons in
older themes -
new icon style with 16 x16 pixel size icons
All icons referenced as ~Icon are automatically replaced based on the used theme
Icons from the old icon library referenced as ICON_ or nn are not automatically replaced
Prerequisite
SAP Corbu theme is available for the following support packs
NW 731 SP02
the new theme is delivered with further optimizations in NW 731 SP03 and SP04
How To Apply Corbu Theme to Web Dynpro for ABAP application
To apply or activate the newly-delivered SAP CORBU theme you have to simply append the URL parameter
ampsap-theme=sap_corbu to your application
(otherwise by default Wedynpro for ABAP applications use the SAP Tradeshow Plus theme )
Development Effort Required
the Corbu theme works for all WD ABAP applications out of the box with no additional development effort
Please perform visual verification of UIs to ensure no truncation of texts or misalignment occurs due to increased font
sizes and line height
3806 View s 17 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Hi
can any one provide clarity on these plz
Thanks
Aashish
146 View s 0 Comments Tags w eb_dynpro
Difference among component configurationapplication configration and controller configuration
Posted by SAP WD Mar 13 2013
Please find the list of step need to perform to achieve the handling of event from source view to target view
Raising the event from one view and handling thesame event in another view
Posted by Om Awasthi Feb 1 2013
Step 1 Identify the source view from where the event will be triggered
Step 2 Identify the target view where the event should be handled
Step 3 Register the listener name handle name controller and event name in the targeted view
middot Listener name ndash name of the view where even will be handled
middot Handler name ndash the method in the target view which will handle the event raised in source view
middot Controller name ndash Name of the component controller used
middot Event name ndash Name of the event which is raised
Sample code for target view written in DOINIT method
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller
lo_api_componentcontroller TYPE REF TO if_wd_component
lo_api_componentcontroller-gtadd_event_handler(
listener_name = V_MAIN
handler_name = OK_HANDLE_MAIN
controller_name = COMPONENTCONTROLLER
event_name = OK_CLICKED_MAIN )
Step 4 you want the target view to handle the source view event just raise the event which is declared in component
controller like below
wd_comp_controller-gtfire_ok_clicked_main_evt( )
Resultant Now once the ok_clicked_main event is raised from source view the same event can be handled in the
target view method OK_HANDLE_MAIN You can perform any actionpopulation in this method
1075 View s 0 Comments Tags w eb_dynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
We have published a survey ( link) to check with Web Dynpro ABAP community if they want a more modern and
productive development environment for Web Dynpro ABAP applications development
The results were quite positive and ABAP in Eclipse is going in the direction to provide support for Web Dynpro
ABAP applications development
ABAP in Eclipse 20 is just out as trial Refer to blog to check how to download it SCN Trial ABAP Development
Tools 20
ABAP in Eclipse doesnt come bundled with Theme editorTheme editor is available as standalone delivery which you
can use to edit Web Dynpro Themes
What about having Theme Editor installed within ABAP in Eclipse IDE
One of the main objectives of ABAP in Eclipse was to bring all development scenarios into one IDE Using eclipse as
a base it is enabled automatically
Execute following steps to install Theme Editor in ABAP in Eclipse
1 Open the link Theme Editor download link
2 Download Eclipse PlugIn from the list of available downloads
3 Install ABAP in Eclipse Follow the blog to check exact steps Enabling ABAP in Eclipse
4 Open ABAP in Eclipse
5 Go to Help-gtInstal New Software and choose Add option
6 Choose Archive option and select the zip file downloaded from step 2
7 Follow the wizard ABAP in Eclipse will be restarted
And you have Theme editor installed in ABAP in Eclipse Now you can do your ABAP development and also edit Web
Dynpro ABAP themes using same IDE
Refer to the document (Link) to know more about theme editor
1211 View s 1 Comments Tags abap abap_in_eclipse w eb_dynpro_abap
Edit Web Dynpro ABAP themes in ABAP in Eclipse
Posted by Ashwani Kumar Sharma Jan 31 2013
Steps of calling of different component from select option F4 and using the value which are selected in different
component
1 Create a component ZTEST This component will have our select option Also make component usage of
WDR_SELECT_OPTIONS in the used components In our example we have made GC_SELECT1
2 Go to main view Make a components add the component usage from step 1 ( which is created in component
controller )
3 Create a viewContainer UI element in your MAIN view
4 Add the WND_SELECTION_SCREEN view in the viewContainer UI element Go to MAIN window expand the
window and in the viewContainer UI element right click and embed
5 Code in DOINIT method of view to create select option with a m_value_help_id = lsquoGC_SELECT1 which is created
as a used component
6 Go to WDR_SELECT_OPTIONS component Click on enhancement add the component which you wants to add
which should be called at the click of select option
7 Once added when you click on select option F4 the component added in WDR_SELECT_OPTIONS is
called
8 What ever value are entered can be passed back to the select option from where it is called
Calling of different component from select option F4and using the value which are selected in differentcomponent
Posted by Om Awasthi Jan 25 2013
254 View s 0 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Step to read the selected data from the table in webdynpro abap
1 Create a method for the table in the property onselect ( like get_data ) Please find the screen shot below
2 Declare the internal table and work area for the attribute to fetch which is selected
3 Give the reference to the table which you want to have use method get_selected_elements for the node
which is declared above to fetch the data
4 Loop the selected elements and extrat the exact data which is present in the selected instance
Sample code
DATA lt_sel_elem TYPE wdr_context_element_set
FIELD-SYMBOLS ltls_sel_elemgt TYPE REF TO if_wd_context_element
DATA lo_nd_n_result TYPE REF TO if_wd_context_node
DATA ls_n_result TYPE wd_this-gtelement_n_result
DATA lt_n_result TYPE wd_this-gtelements_n_result
navigate from ltCONTEXTgt to ltN_RESULTgt via lead selection
lo_nd_n_result = wd_context-gtget_child_node( name = wd_this-gtwdctx_n_result )
TODO handle non existant child
IF lo_nd_n_result IS INITIAL
ENDIF
CALL METHOD lo_nd_n_result-gtget_selected_elements
RECEIVING
set = lt_sel_elem
fetching selected entries
LOOP AT lt_sel_elem ASSIGNING ltls_sel_elemgt
CALL METHOD ltls_sel_elemgt-gtget_static_attributes
IMPORTING
static_attributes = ls_n_result
APPEND ls_n_result TO lt_n_result
ENDLOOP
1172 View s 0 Comments
Tags abap w eb_dynpro w eb_dynpro_abap w ebdynpro_abap w ebdynproabap w ebdynpro_for_abap
Read selected values from table in webdynpro ABAP
Posted by Om Awasthi Jan 25 2013
Method invocation queue
Posted by Uwe Kunath Jan 24 2013
Popups in Webdynpro for ABAP are annoying
Recently I had the pleasure to show one of these Are you sure popups in the UI The issue with popups in
webdynpro is due to the web based architecture the fact that there is no real synchronous program flow as we were
used to in SAP GUI
Instead of stopping the program flow when a popup is shown the Webdynpro runtime continues in order to fulfill the
HTTP web request
This means instead of receiving the result of the users decision right after the popup call we usually need to
implement callback methods which are called when the user presses either Ok No and so on
In the sample this would be the views method ONACTIONAPPLY_CONFIRM
Did you recognize line 29 - 34 Actually what is done here is the preparation of the backend call which is to be
executed depending on the users decision The method parameters are already stored in some attributes and read
for later purpose
In the callback method the backend invocation might look like the code below
Every parameter that will conditionally passed to the backend will have to be stored somewhere
You do this kind of work one time maybe two times or three times and you are going to be annoyed at it
Couldnt this behaviour be achieved easier and more conventiently
What is a method invocation queue
A method invocation queue records method calls for later execution Instead of storing parameters for later usage
you will store the objects and their method calls including parameters for later usage As ABAP still lacks function
pointers we will need to implement it manually
Compare the above shown coding starting at line 29 with this one
Looks more complicated at the beginning But the big advantage of this concept is that you will now only have to keep
track of the method invocation queue not method parameters No further attributes are required
Actually using the fluent API you could write lines 6 to 8 in just one single line
The popups callback method now looks like this
01 DATA lo_comp_api TYPE REF TO if_wd_component
02 DATA lo_controller_api TYPE REF TO if_wd_controller
03 DATA ls_config TYPE wdr_popup_to_confirm
04 DATA lt_text_table TYPE string_table
05 lv_text_table TYPE string
06 lv_title TYPE string
07 ls_config-button_cancel-enabled = abap_false
08 lo_controller_api = wd_this-gtwd_get_api( )
09 lo_comp_api = wd_comp_controller-gtwd_get_api( )
10 lv_title = Are you sure
11 lv_text_table = Really
12 APPEND lv_text_table TO lt_text_table
13 TRY
14 CALL METHOD cl_wd_popup_factory=gtpopup_to_confirm
15 EXPORTING
16 component = lo_comp_api
17 text = lt_text_table
18 window_title = lv_title
19 configuration = ls_config
20 RECEIVING
21 popup_to_confirm = wd_this-gtmo_popup
22 wd_this-gtmo_popup-gtsubscribe_to_events(
23 controller = lo_controller_api
24 handler_name = ONACTIONAPPLY_CONFIRM )
25 retrieve backend call parameters
26 DATA lv_p1 TYPE i
27 DATA lv_p2 TYPE string
28 retrieve parameters
29 store backend call parameters in the views attributes
30 wd_this-gtmv_p1 = lv_p1
31 wd_this-gtmv_p2 = lv_p2
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_some_weird_backend-gtperform_some_weird_operation( iv_p1 = wd_this-gtmv_p1 iv_p2 = wd_this-gtmv_p2 )
04 ENDMETHOD
01 retrieve backend call parameters and record backend calls
02 DATA lv_p1 TYPE i
03 DATA lv_p2 TYPE string
04 retrieve parameters
05 wd_this-gtmo_method_queue = zcl_method_queue=gtnew_method_invocation( )
06 wd_this-gtmo_method_queue-gtwith( wd_this-gtmo_some_weird_backend )-gton( perform_some_weird_operation )
07 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p1 iv_value = lv_p1 )
08 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p2 iv_value = lv_p2 )
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_method_queue-gtflush( )
04 ENDMETHOD
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Highlights of the new SAP Corbu theme for Web Dynpro ABAP
A new modern simple looking theme with improved overall look
Neutral design with light panes and flat surfaces
Reduced contrasts amp gradients create a light and clear user interface
Color Reduced use of neutral and dimmed colors increases the compatibility with other SAP designss
Structure Less structuring and separating elements to support a flat and lightweight appearance
Correct Prioritization Visual focus is on the content instead of on navigation and functions
Tables amp Containers Reduced colors and line contrast creates a less block-like appearance
Increased font sizes to improve readability
Readability Enlarged and easier to read typography for example larger font
Enhanced look for specific controls
new panel stack visualizations
new calendar design
Large set of new icons and pictograms that are modernized with new theme without affecting existing icons in
older themes -
new icon style with 16 x16 pixel size icons
All icons referenced as ~Icon are automatically replaced based on the used theme
Icons from the old icon library referenced as ICON_ or nn are not automatically replaced
Prerequisite
SAP Corbu theme is available for the following support packs
NW 731 SP02
the new theme is delivered with further optimizations in NW 731 SP03 and SP04
How To Apply Corbu Theme to Web Dynpro for ABAP application
To apply or activate the newly-delivered SAP CORBU theme you have to simply append the URL parameter
ampsap-theme=sap_corbu to your application
(otherwise by default Wedynpro for ABAP applications use the SAP Tradeshow Plus theme )
Development Effort Required
the Corbu theme works for all WD ABAP applications out of the box with no additional development effort
Please perform visual verification of UIs to ensure no truncation of texts or misalignment occurs due to increased font
sizes and line height
3806 View s 17 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Hi
can any one provide clarity on these plz
Thanks
Aashish
146 View s 0 Comments Tags w eb_dynpro
Difference among component configurationapplication configration and controller configuration
Posted by SAP WD Mar 13 2013
Please find the list of step need to perform to achieve the handling of event from source view to target view
Raising the event from one view and handling thesame event in another view
Posted by Om Awasthi Feb 1 2013
Step 1 Identify the source view from where the event will be triggered
Step 2 Identify the target view where the event should be handled
Step 3 Register the listener name handle name controller and event name in the targeted view
middot Listener name ndash name of the view where even will be handled
middot Handler name ndash the method in the target view which will handle the event raised in source view
middot Controller name ndash Name of the component controller used
middot Event name ndash Name of the event which is raised
Sample code for target view written in DOINIT method
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller
lo_api_componentcontroller TYPE REF TO if_wd_component
lo_api_componentcontroller-gtadd_event_handler(
listener_name = V_MAIN
handler_name = OK_HANDLE_MAIN
controller_name = COMPONENTCONTROLLER
event_name = OK_CLICKED_MAIN )
Step 4 you want the target view to handle the source view event just raise the event which is declared in component
controller like below
wd_comp_controller-gtfire_ok_clicked_main_evt( )
Resultant Now once the ok_clicked_main event is raised from source view the same event can be handled in the
target view method OK_HANDLE_MAIN You can perform any actionpopulation in this method
1075 View s 0 Comments Tags w eb_dynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
We have published a survey ( link) to check with Web Dynpro ABAP community if they want a more modern and
productive development environment for Web Dynpro ABAP applications development
The results were quite positive and ABAP in Eclipse is going in the direction to provide support for Web Dynpro
ABAP applications development
ABAP in Eclipse 20 is just out as trial Refer to blog to check how to download it SCN Trial ABAP Development
Tools 20
ABAP in Eclipse doesnt come bundled with Theme editorTheme editor is available as standalone delivery which you
can use to edit Web Dynpro Themes
What about having Theme Editor installed within ABAP in Eclipse IDE
One of the main objectives of ABAP in Eclipse was to bring all development scenarios into one IDE Using eclipse as
a base it is enabled automatically
Execute following steps to install Theme Editor in ABAP in Eclipse
1 Open the link Theme Editor download link
2 Download Eclipse PlugIn from the list of available downloads
3 Install ABAP in Eclipse Follow the blog to check exact steps Enabling ABAP in Eclipse
4 Open ABAP in Eclipse
5 Go to Help-gtInstal New Software and choose Add option
6 Choose Archive option and select the zip file downloaded from step 2
7 Follow the wizard ABAP in Eclipse will be restarted
And you have Theme editor installed in ABAP in Eclipse Now you can do your ABAP development and also edit Web
Dynpro ABAP themes using same IDE
Refer to the document (Link) to know more about theme editor
1211 View s 1 Comments Tags abap abap_in_eclipse w eb_dynpro_abap
Edit Web Dynpro ABAP themes in ABAP in Eclipse
Posted by Ashwani Kumar Sharma Jan 31 2013
Steps of calling of different component from select option F4 and using the value which are selected in different
component
1 Create a component ZTEST This component will have our select option Also make component usage of
WDR_SELECT_OPTIONS in the used components In our example we have made GC_SELECT1
2 Go to main view Make a components add the component usage from step 1 ( which is created in component
controller )
3 Create a viewContainer UI element in your MAIN view
4 Add the WND_SELECTION_SCREEN view in the viewContainer UI element Go to MAIN window expand the
window and in the viewContainer UI element right click and embed
5 Code in DOINIT method of view to create select option with a m_value_help_id = lsquoGC_SELECT1 which is created
as a used component
6 Go to WDR_SELECT_OPTIONS component Click on enhancement add the component which you wants to add
which should be called at the click of select option
7 Once added when you click on select option F4 the component added in WDR_SELECT_OPTIONS is
called
8 What ever value are entered can be passed back to the select option from where it is called
Calling of different component from select option F4and using the value which are selected in differentcomponent
Posted by Om Awasthi Jan 25 2013
254 View s 0 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Step to read the selected data from the table in webdynpro abap
1 Create a method for the table in the property onselect ( like get_data ) Please find the screen shot below
2 Declare the internal table and work area for the attribute to fetch which is selected
3 Give the reference to the table which you want to have use method get_selected_elements for the node
which is declared above to fetch the data
4 Loop the selected elements and extrat the exact data which is present in the selected instance
Sample code
DATA lt_sel_elem TYPE wdr_context_element_set
FIELD-SYMBOLS ltls_sel_elemgt TYPE REF TO if_wd_context_element
DATA lo_nd_n_result TYPE REF TO if_wd_context_node
DATA ls_n_result TYPE wd_this-gtelement_n_result
DATA lt_n_result TYPE wd_this-gtelements_n_result
navigate from ltCONTEXTgt to ltN_RESULTgt via lead selection
lo_nd_n_result = wd_context-gtget_child_node( name = wd_this-gtwdctx_n_result )
TODO handle non existant child
IF lo_nd_n_result IS INITIAL
ENDIF
CALL METHOD lo_nd_n_result-gtget_selected_elements
RECEIVING
set = lt_sel_elem
fetching selected entries
LOOP AT lt_sel_elem ASSIGNING ltls_sel_elemgt
CALL METHOD ltls_sel_elemgt-gtget_static_attributes
IMPORTING
static_attributes = ls_n_result
APPEND ls_n_result TO lt_n_result
ENDLOOP
1172 View s 0 Comments
Tags abap w eb_dynpro w eb_dynpro_abap w ebdynpro_abap w ebdynproabap w ebdynpro_for_abap
Read selected values from table in webdynpro ABAP
Posted by Om Awasthi Jan 25 2013
Method invocation queue
Posted by Uwe Kunath Jan 24 2013
Popups in Webdynpro for ABAP are annoying
Recently I had the pleasure to show one of these Are you sure popups in the UI The issue with popups in
webdynpro is due to the web based architecture the fact that there is no real synchronous program flow as we were
used to in SAP GUI
Instead of stopping the program flow when a popup is shown the Webdynpro runtime continues in order to fulfill the
HTTP web request
This means instead of receiving the result of the users decision right after the popup call we usually need to
implement callback methods which are called when the user presses either Ok No and so on
In the sample this would be the views method ONACTIONAPPLY_CONFIRM
Did you recognize line 29 - 34 Actually what is done here is the preparation of the backend call which is to be
executed depending on the users decision The method parameters are already stored in some attributes and read
for later purpose
In the callback method the backend invocation might look like the code below
Every parameter that will conditionally passed to the backend will have to be stored somewhere
You do this kind of work one time maybe two times or three times and you are going to be annoyed at it
Couldnt this behaviour be achieved easier and more conventiently
What is a method invocation queue
A method invocation queue records method calls for later execution Instead of storing parameters for later usage
you will store the objects and their method calls including parameters for later usage As ABAP still lacks function
pointers we will need to implement it manually
Compare the above shown coding starting at line 29 with this one
Looks more complicated at the beginning But the big advantage of this concept is that you will now only have to keep
track of the method invocation queue not method parameters No further attributes are required
Actually using the fluent API you could write lines 6 to 8 in just one single line
The popups callback method now looks like this
01 DATA lo_comp_api TYPE REF TO if_wd_component
02 DATA lo_controller_api TYPE REF TO if_wd_controller
03 DATA ls_config TYPE wdr_popup_to_confirm
04 DATA lt_text_table TYPE string_table
05 lv_text_table TYPE string
06 lv_title TYPE string
07 ls_config-button_cancel-enabled = abap_false
08 lo_controller_api = wd_this-gtwd_get_api( )
09 lo_comp_api = wd_comp_controller-gtwd_get_api( )
10 lv_title = Are you sure
11 lv_text_table = Really
12 APPEND lv_text_table TO lt_text_table
13 TRY
14 CALL METHOD cl_wd_popup_factory=gtpopup_to_confirm
15 EXPORTING
16 component = lo_comp_api
17 text = lt_text_table
18 window_title = lv_title
19 configuration = ls_config
20 RECEIVING
21 popup_to_confirm = wd_this-gtmo_popup
22 wd_this-gtmo_popup-gtsubscribe_to_events(
23 controller = lo_controller_api
24 handler_name = ONACTIONAPPLY_CONFIRM )
25 retrieve backend call parameters
26 DATA lv_p1 TYPE i
27 DATA lv_p2 TYPE string
28 retrieve parameters
29 store backend call parameters in the views attributes
30 wd_this-gtmv_p1 = lv_p1
31 wd_this-gtmv_p2 = lv_p2
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_some_weird_backend-gtperform_some_weird_operation( iv_p1 = wd_this-gtmv_p1 iv_p2 = wd_this-gtmv_p2 )
04 ENDMETHOD
01 retrieve backend call parameters and record backend calls
02 DATA lv_p1 TYPE i
03 DATA lv_p2 TYPE string
04 retrieve parameters
05 wd_this-gtmo_method_queue = zcl_method_queue=gtnew_method_invocation( )
06 wd_this-gtmo_method_queue-gtwith( wd_this-gtmo_some_weird_backend )-gton( perform_some_weird_operation )
07 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p1 iv_value = lv_p1 )
08 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p2 iv_value = lv_p2 )
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_method_queue-gtflush( )
04 ENDMETHOD
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Step 1 Identify the source view from where the event will be triggered
Step 2 Identify the target view where the event should be handled
Step 3 Register the listener name handle name controller and event name in the targeted view
middot Listener name ndash name of the view where even will be handled
middot Handler name ndash the method in the target view which will handle the event raised in source view
middot Controller name ndash Name of the component controller used
middot Event name ndash Name of the event which is raised
Sample code for target view written in DOINIT method
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller
lo_api_componentcontroller TYPE REF TO if_wd_component
lo_api_componentcontroller-gtadd_event_handler(
listener_name = V_MAIN
handler_name = OK_HANDLE_MAIN
controller_name = COMPONENTCONTROLLER
event_name = OK_CLICKED_MAIN )
Step 4 you want the target view to handle the source view event just raise the event which is declared in component
controller like below
wd_comp_controller-gtfire_ok_clicked_main_evt( )
Resultant Now once the ok_clicked_main event is raised from source view the same event can be handled in the
target view method OK_HANDLE_MAIN You can perform any actionpopulation in this method
1075 View s 0 Comments Tags w eb_dynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
We have published a survey ( link) to check with Web Dynpro ABAP community if they want a more modern and
productive development environment for Web Dynpro ABAP applications development
The results were quite positive and ABAP in Eclipse is going in the direction to provide support for Web Dynpro
ABAP applications development
ABAP in Eclipse 20 is just out as trial Refer to blog to check how to download it SCN Trial ABAP Development
Tools 20
ABAP in Eclipse doesnt come bundled with Theme editorTheme editor is available as standalone delivery which you
can use to edit Web Dynpro Themes
What about having Theme Editor installed within ABAP in Eclipse IDE
One of the main objectives of ABAP in Eclipse was to bring all development scenarios into one IDE Using eclipse as
a base it is enabled automatically
Execute following steps to install Theme Editor in ABAP in Eclipse
1 Open the link Theme Editor download link
2 Download Eclipse PlugIn from the list of available downloads
3 Install ABAP in Eclipse Follow the blog to check exact steps Enabling ABAP in Eclipse
4 Open ABAP in Eclipse
5 Go to Help-gtInstal New Software and choose Add option
6 Choose Archive option and select the zip file downloaded from step 2
7 Follow the wizard ABAP in Eclipse will be restarted
And you have Theme editor installed in ABAP in Eclipse Now you can do your ABAP development and also edit Web
Dynpro ABAP themes using same IDE
Refer to the document (Link) to know more about theme editor
1211 View s 1 Comments Tags abap abap_in_eclipse w eb_dynpro_abap
Edit Web Dynpro ABAP themes in ABAP in Eclipse
Posted by Ashwani Kumar Sharma Jan 31 2013
Steps of calling of different component from select option F4 and using the value which are selected in different
component
1 Create a component ZTEST This component will have our select option Also make component usage of
WDR_SELECT_OPTIONS in the used components In our example we have made GC_SELECT1
2 Go to main view Make a components add the component usage from step 1 ( which is created in component
controller )
3 Create a viewContainer UI element in your MAIN view
4 Add the WND_SELECTION_SCREEN view in the viewContainer UI element Go to MAIN window expand the
window and in the viewContainer UI element right click and embed
5 Code in DOINIT method of view to create select option with a m_value_help_id = lsquoGC_SELECT1 which is created
as a used component
6 Go to WDR_SELECT_OPTIONS component Click on enhancement add the component which you wants to add
which should be called at the click of select option
7 Once added when you click on select option F4 the component added in WDR_SELECT_OPTIONS is
called
8 What ever value are entered can be passed back to the select option from where it is called
Calling of different component from select option F4and using the value which are selected in differentcomponent
Posted by Om Awasthi Jan 25 2013
254 View s 0 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Step to read the selected data from the table in webdynpro abap
1 Create a method for the table in the property onselect ( like get_data ) Please find the screen shot below
2 Declare the internal table and work area for the attribute to fetch which is selected
3 Give the reference to the table which you want to have use method get_selected_elements for the node
which is declared above to fetch the data
4 Loop the selected elements and extrat the exact data which is present in the selected instance
Sample code
DATA lt_sel_elem TYPE wdr_context_element_set
FIELD-SYMBOLS ltls_sel_elemgt TYPE REF TO if_wd_context_element
DATA lo_nd_n_result TYPE REF TO if_wd_context_node
DATA ls_n_result TYPE wd_this-gtelement_n_result
DATA lt_n_result TYPE wd_this-gtelements_n_result
navigate from ltCONTEXTgt to ltN_RESULTgt via lead selection
lo_nd_n_result = wd_context-gtget_child_node( name = wd_this-gtwdctx_n_result )
TODO handle non existant child
IF lo_nd_n_result IS INITIAL
ENDIF
CALL METHOD lo_nd_n_result-gtget_selected_elements
RECEIVING
set = lt_sel_elem
fetching selected entries
LOOP AT lt_sel_elem ASSIGNING ltls_sel_elemgt
CALL METHOD ltls_sel_elemgt-gtget_static_attributes
IMPORTING
static_attributes = ls_n_result
APPEND ls_n_result TO lt_n_result
ENDLOOP
1172 View s 0 Comments
Tags abap w eb_dynpro w eb_dynpro_abap w ebdynpro_abap w ebdynproabap w ebdynpro_for_abap
Read selected values from table in webdynpro ABAP
Posted by Om Awasthi Jan 25 2013
Method invocation queue
Posted by Uwe Kunath Jan 24 2013
Popups in Webdynpro for ABAP are annoying
Recently I had the pleasure to show one of these Are you sure popups in the UI The issue with popups in
webdynpro is due to the web based architecture the fact that there is no real synchronous program flow as we were
used to in SAP GUI
Instead of stopping the program flow when a popup is shown the Webdynpro runtime continues in order to fulfill the
HTTP web request
This means instead of receiving the result of the users decision right after the popup call we usually need to
implement callback methods which are called when the user presses either Ok No and so on
In the sample this would be the views method ONACTIONAPPLY_CONFIRM
Did you recognize line 29 - 34 Actually what is done here is the preparation of the backend call which is to be
executed depending on the users decision The method parameters are already stored in some attributes and read
for later purpose
In the callback method the backend invocation might look like the code below
Every parameter that will conditionally passed to the backend will have to be stored somewhere
You do this kind of work one time maybe two times or three times and you are going to be annoyed at it
Couldnt this behaviour be achieved easier and more conventiently
What is a method invocation queue
A method invocation queue records method calls for later execution Instead of storing parameters for later usage
you will store the objects and their method calls including parameters for later usage As ABAP still lacks function
pointers we will need to implement it manually
Compare the above shown coding starting at line 29 with this one
Looks more complicated at the beginning But the big advantage of this concept is that you will now only have to keep
track of the method invocation queue not method parameters No further attributes are required
Actually using the fluent API you could write lines 6 to 8 in just one single line
The popups callback method now looks like this
01 DATA lo_comp_api TYPE REF TO if_wd_component
02 DATA lo_controller_api TYPE REF TO if_wd_controller
03 DATA ls_config TYPE wdr_popup_to_confirm
04 DATA lt_text_table TYPE string_table
05 lv_text_table TYPE string
06 lv_title TYPE string
07 ls_config-button_cancel-enabled = abap_false
08 lo_controller_api = wd_this-gtwd_get_api( )
09 lo_comp_api = wd_comp_controller-gtwd_get_api( )
10 lv_title = Are you sure
11 lv_text_table = Really
12 APPEND lv_text_table TO lt_text_table
13 TRY
14 CALL METHOD cl_wd_popup_factory=gtpopup_to_confirm
15 EXPORTING
16 component = lo_comp_api
17 text = lt_text_table
18 window_title = lv_title
19 configuration = ls_config
20 RECEIVING
21 popup_to_confirm = wd_this-gtmo_popup
22 wd_this-gtmo_popup-gtsubscribe_to_events(
23 controller = lo_controller_api
24 handler_name = ONACTIONAPPLY_CONFIRM )
25 retrieve backend call parameters
26 DATA lv_p1 TYPE i
27 DATA lv_p2 TYPE string
28 retrieve parameters
29 store backend call parameters in the views attributes
30 wd_this-gtmv_p1 = lv_p1
31 wd_this-gtmv_p2 = lv_p2
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_some_weird_backend-gtperform_some_weird_operation( iv_p1 = wd_this-gtmv_p1 iv_p2 = wd_this-gtmv_p2 )
04 ENDMETHOD
01 retrieve backend call parameters and record backend calls
02 DATA lv_p1 TYPE i
03 DATA lv_p2 TYPE string
04 retrieve parameters
05 wd_this-gtmo_method_queue = zcl_method_queue=gtnew_method_invocation( )
06 wd_this-gtmo_method_queue-gtwith( wd_this-gtmo_some_weird_backend )-gton( perform_some_weird_operation )
07 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p1 iv_value = lv_p1 )
08 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p2 iv_value = lv_p2 )
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_method_queue-gtflush( )
04 ENDMETHOD
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Steps of calling of different component from select option F4 and using the value which are selected in different
component
1 Create a component ZTEST This component will have our select option Also make component usage of
WDR_SELECT_OPTIONS in the used components In our example we have made GC_SELECT1
2 Go to main view Make a components add the component usage from step 1 ( which is created in component
controller )
3 Create a viewContainer UI element in your MAIN view
4 Add the WND_SELECTION_SCREEN view in the viewContainer UI element Go to MAIN window expand the
window and in the viewContainer UI element right click and embed
5 Code in DOINIT method of view to create select option with a m_value_help_id = lsquoGC_SELECT1 which is created
as a used component
6 Go to WDR_SELECT_OPTIONS component Click on enhancement add the component which you wants to add
which should be called at the click of select option
7 Once added when you click on select option F4 the component added in WDR_SELECT_OPTIONS is
called
8 What ever value are entered can be passed back to the select option from where it is called
Calling of different component from select option F4and using the value which are selected in differentcomponent
Posted by Om Awasthi Jan 25 2013
254 View s 0 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Step to read the selected data from the table in webdynpro abap
1 Create a method for the table in the property onselect ( like get_data ) Please find the screen shot below
2 Declare the internal table and work area for the attribute to fetch which is selected
3 Give the reference to the table which you want to have use method get_selected_elements for the node
which is declared above to fetch the data
4 Loop the selected elements and extrat the exact data which is present in the selected instance
Sample code
DATA lt_sel_elem TYPE wdr_context_element_set
FIELD-SYMBOLS ltls_sel_elemgt TYPE REF TO if_wd_context_element
DATA lo_nd_n_result TYPE REF TO if_wd_context_node
DATA ls_n_result TYPE wd_this-gtelement_n_result
DATA lt_n_result TYPE wd_this-gtelements_n_result
navigate from ltCONTEXTgt to ltN_RESULTgt via lead selection
lo_nd_n_result = wd_context-gtget_child_node( name = wd_this-gtwdctx_n_result )
TODO handle non existant child
IF lo_nd_n_result IS INITIAL
ENDIF
CALL METHOD lo_nd_n_result-gtget_selected_elements
RECEIVING
set = lt_sel_elem
fetching selected entries
LOOP AT lt_sel_elem ASSIGNING ltls_sel_elemgt
CALL METHOD ltls_sel_elemgt-gtget_static_attributes
IMPORTING
static_attributes = ls_n_result
APPEND ls_n_result TO lt_n_result
ENDLOOP
1172 View s 0 Comments
Tags abap w eb_dynpro w eb_dynpro_abap w ebdynpro_abap w ebdynproabap w ebdynpro_for_abap
Read selected values from table in webdynpro ABAP
Posted by Om Awasthi Jan 25 2013
Method invocation queue
Posted by Uwe Kunath Jan 24 2013
Popups in Webdynpro for ABAP are annoying
Recently I had the pleasure to show one of these Are you sure popups in the UI The issue with popups in
webdynpro is due to the web based architecture the fact that there is no real synchronous program flow as we were
used to in SAP GUI
Instead of stopping the program flow when a popup is shown the Webdynpro runtime continues in order to fulfill the
HTTP web request
This means instead of receiving the result of the users decision right after the popup call we usually need to
implement callback methods which are called when the user presses either Ok No and so on
In the sample this would be the views method ONACTIONAPPLY_CONFIRM
Did you recognize line 29 - 34 Actually what is done here is the preparation of the backend call which is to be
executed depending on the users decision The method parameters are already stored in some attributes and read
for later purpose
In the callback method the backend invocation might look like the code below
Every parameter that will conditionally passed to the backend will have to be stored somewhere
You do this kind of work one time maybe two times or three times and you are going to be annoyed at it
Couldnt this behaviour be achieved easier and more conventiently
What is a method invocation queue
A method invocation queue records method calls for later execution Instead of storing parameters for later usage
you will store the objects and their method calls including parameters for later usage As ABAP still lacks function
pointers we will need to implement it manually
Compare the above shown coding starting at line 29 with this one
Looks more complicated at the beginning But the big advantage of this concept is that you will now only have to keep
track of the method invocation queue not method parameters No further attributes are required
Actually using the fluent API you could write lines 6 to 8 in just one single line
The popups callback method now looks like this
01 DATA lo_comp_api TYPE REF TO if_wd_component
02 DATA lo_controller_api TYPE REF TO if_wd_controller
03 DATA ls_config TYPE wdr_popup_to_confirm
04 DATA lt_text_table TYPE string_table
05 lv_text_table TYPE string
06 lv_title TYPE string
07 ls_config-button_cancel-enabled = abap_false
08 lo_controller_api = wd_this-gtwd_get_api( )
09 lo_comp_api = wd_comp_controller-gtwd_get_api( )
10 lv_title = Are you sure
11 lv_text_table = Really
12 APPEND lv_text_table TO lt_text_table
13 TRY
14 CALL METHOD cl_wd_popup_factory=gtpopup_to_confirm
15 EXPORTING
16 component = lo_comp_api
17 text = lt_text_table
18 window_title = lv_title
19 configuration = ls_config
20 RECEIVING
21 popup_to_confirm = wd_this-gtmo_popup
22 wd_this-gtmo_popup-gtsubscribe_to_events(
23 controller = lo_controller_api
24 handler_name = ONACTIONAPPLY_CONFIRM )
25 retrieve backend call parameters
26 DATA lv_p1 TYPE i
27 DATA lv_p2 TYPE string
28 retrieve parameters
29 store backend call parameters in the views attributes
30 wd_this-gtmv_p1 = lv_p1
31 wd_this-gtmv_p2 = lv_p2
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_some_weird_backend-gtperform_some_weird_operation( iv_p1 = wd_this-gtmv_p1 iv_p2 = wd_this-gtmv_p2 )
04 ENDMETHOD
01 retrieve backend call parameters and record backend calls
02 DATA lv_p1 TYPE i
03 DATA lv_p2 TYPE string
04 retrieve parameters
05 wd_this-gtmo_method_queue = zcl_method_queue=gtnew_method_invocation( )
06 wd_this-gtmo_method_queue-gtwith( wd_this-gtmo_some_weird_backend )-gton( perform_some_weird_operation )
07 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p1 iv_value = lv_p1 )
08 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p2 iv_value = lv_p2 )
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_method_queue-gtflush( )
04 ENDMETHOD
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
254 View s 0 Comments Tags w eb_dynpro w ebdynpro w eb_dynpro_abap w ebdynpro_abap abap_w d
Step to read the selected data from the table in webdynpro abap
1 Create a method for the table in the property onselect ( like get_data ) Please find the screen shot below
2 Declare the internal table and work area for the attribute to fetch which is selected
3 Give the reference to the table which you want to have use method get_selected_elements for the node
which is declared above to fetch the data
4 Loop the selected elements and extrat the exact data which is present in the selected instance
Sample code
DATA lt_sel_elem TYPE wdr_context_element_set
FIELD-SYMBOLS ltls_sel_elemgt TYPE REF TO if_wd_context_element
DATA lo_nd_n_result TYPE REF TO if_wd_context_node
DATA ls_n_result TYPE wd_this-gtelement_n_result
DATA lt_n_result TYPE wd_this-gtelements_n_result
navigate from ltCONTEXTgt to ltN_RESULTgt via lead selection
lo_nd_n_result = wd_context-gtget_child_node( name = wd_this-gtwdctx_n_result )
TODO handle non existant child
IF lo_nd_n_result IS INITIAL
ENDIF
CALL METHOD lo_nd_n_result-gtget_selected_elements
RECEIVING
set = lt_sel_elem
fetching selected entries
LOOP AT lt_sel_elem ASSIGNING ltls_sel_elemgt
CALL METHOD ltls_sel_elemgt-gtget_static_attributes
IMPORTING
static_attributes = ls_n_result
APPEND ls_n_result TO lt_n_result
ENDLOOP
1172 View s 0 Comments
Tags abap w eb_dynpro w eb_dynpro_abap w ebdynpro_abap w ebdynproabap w ebdynpro_for_abap
Read selected values from table in webdynpro ABAP
Posted by Om Awasthi Jan 25 2013
Method invocation queue
Posted by Uwe Kunath Jan 24 2013
Popups in Webdynpro for ABAP are annoying
Recently I had the pleasure to show one of these Are you sure popups in the UI The issue with popups in
webdynpro is due to the web based architecture the fact that there is no real synchronous program flow as we were
used to in SAP GUI
Instead of stopping the program flow when a popup is shown the Webdynpro runtime continues in order to fulfill the
HTTP web request
This means instead of receiving the result of the users decision right after the popup call we usually need to
implement callback methods which are called when the user presses either Ok No and so on
In the sample this would be the views method ONACTIONAPPLY_CONFIRM
Did you recognize line 29 - 34 Actually what is done here is the preparation of the backend call which is to be
executed depending on the users decision The method parameters are already stored in some attributes and read
for later purpose
In the callback method the backend invocation might look like the code below
Every parameter that will conditionally passed to the backend will have to be stored somewhere
You do this kind of work one time maybe two times or three times and you are going to be annoyed at it
Couldnt this behaviour be achieved easier and more conventiently
What is a method invocation queue
A method invocation queue records method calls for later execution Instead of storing parameters for later usage
you will store the objects and their method calls including parameters for later usage As ABAP still lacks function
pointers we will need to implement it manually
Compare the above shown coding starting at line 29 with this one
Looks more complicated at the beginning But the big advantage of this concept is that you will now only have to keep
track of the method invocation queue not method parameters No further attributes are required
Actually using the fluent API you could write lines 6 to 8 in just one single line
The popups callback method now looks like this
01 DATA lo_comp_api TYPE REF TO if_wd_component
02 DATA lo_controller_api TYPE REF TO if_wd_controller
03 DATA ls_config TYPE wdr_popup_to_confirm
04 DATA lt_text_table TYPE string_table
05 lv_text_table TYPE string
06 lv_title TYPE string
07 ls_config-button_cancel-enabled = abap_false
08 lo_controller_api = wd_this-gtwd_get_api( )
09 lo_comp_api = wd_comp_controller-gtwd_get_api( )
10 lv_title = Are you sure
11 lv_text_table = Really
12 APPEND lv_text_table TO lt_text_table
13 TRY
14 CALL METHOD cl_wd_popup_factory=gtpopup_to_confirm
15 EXPORTING
16 component = lo_comp_api
17 text = lt_text_table
18 window_title = lv_title
19 configuration = ls_config
20 RECEIVING
21 popup_to_confirm = wd_this-gtmo_popup
22 wd_this-gtmo_popup-gtsubscribe_to_events(
23 controller = lo_controller_api
24 handler_name = ONACTIONAPPLY_CONFIRM )
25 retrieve backend call parameters
26 DATA lv_p1 TYPE i
27 DATA lv_p2 TYPE string
28 retrieve parameters
29 store backend call parameters in the views attributes
30 wd_this-gtmv_p1 = lv_p1
31 wd_this-gtmv_p2 = lv_p2
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_some_weird_backend-gtperform_some_weird_operation( iv_p1 = wd_this-gtmv_p1 iv_p2 = wd_this-gtmv_p2 )
04 ENDMETHOD
01 retrieve backend call parameters and record backend calls
02 DATA lv_p1 TYPE i
03 DATA lv_p2 TYPE string
04 retrieve parameters
05 wd_this-gtmo_method_queue = zcl_method_queue=gtnew_method_invocation( )
06 wd_this-gtmo_method_queue-gtwith( wd_this-gtmo_some_weird_backend )-gton( perform_some_weird_operation )
07 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p1 iv_value = lv_p1 )
08 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p2 iv_value = lv_p2 )
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_method_queue-gtflush( )
04 ENDMETHOD
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Popups in Webdynpro for ABAP are annoying
Recently I had the pleasure to show one of these Are you sure popups in the UI The issue with popups in
webdynpro is due to the web based architecture the fact that there is no real synchronous program flow as we were
used to in SAP GUI
Instead of stopping the program flow when a popup is shown the Webdynpro runtime continues in order to fulfill the
HTTP web request
This means instead of receiving the result of the users decision right after the popup call we usually need to
implement callback methods which are called when the user presses either Ok No and so on
In the sample this would be the views method ONACTIONAPPLY_CONFIRM
Did you recognize line 29 - 34 Actually what is done here is the preparation of the backend call which is to be
executed depending on the users decision The method parameters are already stored in some attributes and read
for later purpose
In the callback method the backend invocation might look like the code below
Every parameter that will conditionally passed to the backend will have to be stored somewhere
You do this kind of work one time maybe two times or three times and you are going to be annoyed at it
Couldnt this behaviour be achieved easier and more conventiently
What is a method invocation queue
A method invocation queue records method calls for later execution Instead of storing parameters for later usage
you will store the objects and their method calls including parameters for later usage As ABAP still lacks function
pointers we will need to implement it manually
Compare the above shown coding starting at line 29 with this one
Looks more complicated at the beginning But the big advantage of this concept is that you will now only have to keep
track of the method invocation queue not method parameters No further attributes are required
Actually using the fluent API you could write lines 6 to 8 in just one single line
The popups callback method now looks like this
01 DATA lo_comp_api TYPE REF TO if_wd_component
02 DATA lo_controller_api TYPE REF TO if_wd_controller
03 DATA ls_config TYPE wdr_popup_to_confirm
04 DATA lt_text_table TYPE string_table
05 lv_text_table TYPE string
06 lv_title TYPE string
07 ls_config-button_cancel-enabled = abap_false
08 lo_controller_api = wd_this-gtwd_get_api( )
09 lo_comp_api = wd_comp_controller-gtwd_get_api( )
10 lv_title = Are you sure
11 lv_text_table = Really
12 APPEND lv_text_table TO lt_text_table
13 TRY
14 CALL METHOD cl_wd_popup_factory=gtpopup_to_confirm
15 EXPORTING
16 component = lo_comp_api
17 text = lt_text_table
18 window_title = lv_title
19 configuration = ls_config
20 RECEIVING
21 popup_to_confirm = wd_this-gtmo_popup
22 wd_this-gtmo_popup-gtsubscribe_to_events(
23 controller = lo_controller_api
24 handler_name = ONACTIONAPPLY_CONFIRM )
25 retrieve backend call parameters
26 DATA lv_p1 TYPE i
27 DATA lv_p2 TYPE string
28 retrieve parameters
29 store backend call parameters in the views attributes
30 wd_this-gtmv_p1 = lv_p1
31 wd_this-gtmv_p2 = lv_p2
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_some_weird_backend-gtperform_some_weird_operation( iv_p1 = wd_this-gtmv_p1 iv_p2 = wd_this-gtmv_p2 )
04 ENDMETHOD
01 retrieve backend call parameters and record backend calls
02 DATA lv_p1 TYPE i
03 DATA lv_p2 TYPE string
04 retrieve parameters
05 wd_this-gtmo_method_queue = zcl_method_queue=gtnew_method_invocation( )
06 wd_this-gtmo_method_queue-gtwith( wd_this-gtmo_some_weird_backend )-gton( perform_some_weird_operation )
07 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p1 iv_value = lv_p1 )
08 wd_this-gtmo_method_queue-gtadd_parameter( iv_name = iv_p2 iv_value = lv_p2 )
01 METHOD ONACTIONAPPLY_CONFIRM
02 CHECK wd_this-gtmo_popup-gtanswer = if_wd_popup_to_confirm=gtco_button_1_pressed
03 wd_this-gtmo_method_queue-gtflush( )
04 ENDMETHOD
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Interested
So here is the coding Please be aware this is just experimental and not meant for productive usage
This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception
handling However you may consider to enhance it and write about what you found out -)
01 CLASS zcl_method_queue DEFINITION
02 PUBLIC
03 FINAL
04 CREATE PROTECTED
05 PUBLIC SECTION
06 TYPE-POOLS abap
07 CLASS-METHODS new_method_invocation
08 RETURNING
09 value(ro_method_queue) TYPE REF TO zcl_method_queue
10 METHODS with
11 IMPORTING
12 io_caller TYPE REF TO object
13 RETURNING
14 value(ro_method_queue) TYPE REF TO zcl_method_queue
15 METHODS on
16 IMPORTING
17 iv_method TYPE seocpdname
18 RETURNING
19 value(ro_method_queue) TYPE REF TO zcl_method_queue
20 METHODS add_parameter
21 IMPORTING
22 iv_name TYPE abap_parmname
23 value(iv_value) TYPE any
24 RETURNING
25 value(ro_method_queue) TYPE REF TO zcl_method_queue
26 METHODS finalize
27 METHODS flush
28 RAISING
29 zcx_method_queue
30 PROTECTED SECTION
31 TYPES
32 BEGIN OF ty_s_method_invocation
33 caller TYPE REF TO object
34 method TYPE seocpdname
35 parameters TYPE abap_parmbind_tab
36 END OF ty_s_method_invocation
37 DATA ms_method_invocation TYPE ty_s_method_invocation
38 DATA
39 mt_method_invocations TYPE TABLE OF ty_s_method_invocation
40 METHODS copy_value
41 IMPORTING
42 ir_ref TYPE REF TO data
43 RETURNING
44 value(rr_ref) TYPE REF TO data
45 METHODS constructor
46 PRIVATE SECTION
47 ENDCLASS
48 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION
49 METHOD add_parameter
50 ro_method_queue = me
51 DATA ls_parameter TYPE abap_parmbind
52 DATA lr_value TYPE REF TO data
53 ls_parameter-name = iv_name
54 TRANSLATE ls_parameter-name TO UPPER CASE
55 ls_parameter-kind = cl_abap_objectdescr=gtexporting
56 GET REFERENCE OF iv_value INTO lr_value
57 ls_parameter-value = copy_value( lr_value )
58 INSERT ls_parameter INTO TABLE ms_method_invocation-parameters
59 ENDMETHOD add_parameter
60 METHOD constructor
61 ENDMETHOD CONSTRUCTOR
62 METHOD copy_value
63 FIELD-SYMBOLS ltlv_ingt TYPE any
64 FIELD-SYMBOLS ltlv_outgt TYPE any
65 ASSIGN ir_ref-gt TO ltlv_ingt
66 CREATE DATA rr_ref LIKE ltlv_ingt
67 ASSIGN rr_ref-gt TO ltlv_outgt
68 ltlv_outgt = ltlv_ingt
69 ENDMETHOD
70 METHOD finalize
71 CHECK ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
72 APPEND ms_method_invocation TO mt_method_invocations
73 CLEAR ms_method_invocation
74 ENDMETHOD
75 METHOD flush
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Drawbacks of this approach
However theres no such thing as a free lunch
If you decide to use such a method invocation queue you lose the where-used-list support of your backends
methods
Also you can only access real backend methods and not component controller methods as they are accesssible for
their views or windows but not for any other objects unless these methods are declared public
So stay careful be watchful and enjoy
557 View s 0 Comments Tags abap w eb_dynpro w ebdynpro popup popup_w indow method_queue
76 FIELD-SYMBOLS ltls_callgt TYPE ty_s_method_invocation
77 DATA lo_cx_root TYPE REF TO cx_root
78 DATA lo_objectdescr TYPE REF TO cl_abap_classdescr
79 DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method
80 DATA ls_method TYPE abap_methdescr
81 DATA lv_has_method_been_called TYPE abap_bool
82 DATA lv_count TYPE i
83 DATA lt_method_parts TYPE string_table
84 DATA lv_method_name TYPE string
85 finalize( )
86 LOOP AT mt_method_invocations ASSIGNING ltls_callgt
87 TRY
88 CALL METHOD ltls_callgt-caller-gt(ltls_callgt-method) PARAMETER-TABLE ltls_callgt-parameters
89 CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth
90 no such method - try to call named method in any interface that the current object might implement
91 lv_has_method_been_called = abap_false
92 lo_objectdescr = cl_abap_classdescr=gtdescribe_by_object_ref( ltls_callgt-caller )
93 LOOP AT lo_objectdescr-gtmethods INTO ls_method
94 TRY
95 lv_method_name = ls_method-name
96 SPLIT lv_method_name AT ~ INTO TABLE lt_method_parts
97 FIND ltls_callgt-method IN TABLE lt_method_parts MATCH COUNT lv_count
98 IF lv_count gt 0
99 CALL METHOD ltls_callgt-caller-gt(ls_method-name) PARAMETER-TABLE ltls_callgt-parameters
100 lv_has_method_been_called = abap_true
101 EXIT
102 ENDIF
103 CATCH cx_root INTO lo_cx_root
104 CONTINUE
105 ENDTRY
106 ENDLOOP
107 has method been found
108 IF lv_has_method_been_called = abap_false
109 RAISE EXCEPTION TYPE zcx_method_queue
110 EXPORTING
111 previous = lo_cx_root
112 method = ltls_callgt-method
113 ENDIF
114 CATCH cx_root INTO lo_cx_root
115 RAISE EXCEPTION TYPE zcx_method_queue
116 EXPORTING
117 previous = lo_cx_root
118 method = ltls_callgt-method
119 ENDTRY
120 ENDLOOP
121 ENDMETHOD flush
122 METHOD new_method_invocation
123 CREATE OBJECT ro_method_queue
124 ENDMETHOD new_method_invocation
125 METHOD on
126 ro_method_queue = me
127 ms_method_invocation-method = iv_method
128 TRANSLATE ms_method_invocation-method TO UPPER CASE
129 ENDMETHOD on
130 METHOD with
131 ro_method_queue = me
132 IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL
133 finalize( )
134 ENDIF
135 ms_method_invocation-caller = io_caller
136 ENDMETHOD with
137 ENDCLASS
How to display GOS PDF document from Webdynpro
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Dear All
One of the way to display the GOS PDF document via Webdynpro hope this will help
Step1 Select the list of attachments from the business document using function module
BDS_ALL_CONNECTIONS_GET for this you need the following inputs Classname Classtype and objkey
Step2 Convert the file ID (loio_id from the above function module) to xstring using the method
ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo
Data
lv_aid type bds_docid
lv_fcon type string
lv_fchex type xstring
lv_mftyp type string
lv_ret type bapiret2
attachment_get_detail
(exporting
attachment_id = lv_aid
attachment_type = pdf
importing
file_content = lv_fcon
file_content_hex = lv_fchex
mime_file_type = lv_mftyp
s_return = lv_ret )
Step3 Display the document in new browser using the method attach_file_to_response from class
cl_wd_runtime_services
data
l_file type string
l_mime type string
pdf_data type xstring
l_mime = applicationpdf
l_file = titlepdf
call method
cl_wd_runtime_services=gtattach_file_to_response
exporting
i_filename = l_file
i_content = lv_fchex
i_mime_type = l_mime
698 View s 0 Comments Tags w eb_dynpro
Posted by Prabhu Rajesh Jan 16 2013
So you want to adaptchange your SAP standard Web Dynpro ABAP (WDA) application but yoursquod like to avoid using
code enhancements if possible One way to achive this is Administrator Personalization and in this blog Ill explain
and give examples of this There are other ways to achieve the same which are not covered by this blog The other
methods to achieve code free changes to WDA applications are called Component Customization and code free
Enhancements which I might cover in a future blog
The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based
on SAP recommendations
1 Admin Personalization (Application Customization)
If you want to perform small changes like hiding an input field changing a label rearranging a table column or field
then this is the way to go If you come from a Web Dynpro Java background the options at your hand using this
technique are very similar to the old ctrl+right click technique
To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84
Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a
clean SAP version I would recommend taking a copy but up to you and your companies policies If you chose to
customize directly on the standard application your changes will not be lost during an upgrade and you can always go
Admin Personalization of your SAP Standard WDAapplication ndash How To
Posted by Jan Thomas Nygaard Jan 14 2013
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
back and check which elements where changed and reset the changes (I will show that towards the bottom of this
blog)
You now need to execute the application using shift+F8 or Web dynpro application-gtTest-gt In browser - admin
mode
You can also do the same from your development portal by executing the iview in preview mode (but I have not tested
this out in the portal so cant say if you get prompts for transports etc)
Then locate the UI object you wish to change right click it and chose Settings for current configuration Below Ive
given a couple of examples and hints
If you clicked on a table column you will be able to rearrange it and AddRemove columns
If you click on an input field you can change text make it invisble add a tooltip and even mark it as mandatory
using the state property
NOTE If you mark a field as mandatory it simply gives you a indicator on the field and you need to ensure
that a check for mandatory attributes has or is also implemented for example using
cl_wd_dynamic_tool=gtcheck_mandatory_attr_on_view( view_controller = l_view_controller
display_messages = abap_true )
If you want to rearrange the input fields you have to click on the container element for example Grouping of UI
Elements as shown below You then press the Re-Sort link and you will be able to move them Up and Down
When your done and click the Save and Close button in the bottom right hand corner you will be prompted to save
your changes in a customization transport As a result you only need to do this on your development systemclient -
nice
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
I have sometimes experienced that this customization seems to be done on the application NOT the application
configuration which means
a) The admin personalization of the application will be available on all the application configurations associated with
it
b) You can perform admin personalization even if the application doesnt have a configuration
However other times it is done on the application configuration as Vikrant Raj also points out in his comments to
this blog I believe there is a bug that gives this inconsistency but the intention from SAP is probably that it should be
saved on the application configuration as I think that makes most sense If anyone can shed any further light on this
(eg refer to a SAP note) please let me know
If you want to check which parts of an application has been customized select the drop down option Personalized
Elements and you will get a list of customized elements and be able to reset them to standard
So this is one way to achieve the described changes As mentioned in the introduction there aare also other ways to
do the same not covered by this blog
NOTE In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask
your functional IMG expert first
Here are some useful links
End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)
Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library
And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of
the way are also applicable for standard WDA applications
httpwwwsdnsapcomirjscngoportalprtrootdocslibraryuuidc0a2b7c2-1598-2e10-45bc-c556df3b9576
QuickLink=indexampoverridelayout=trueamp51591147228485
Best Regards Jan
2528 View s 9 Comments
Tags netw eaver w da abap w eb_dynpro portal sap_portal w ebdynpro customizing netw eaver_portal
w eb_dynpro_abap w ebdynpro_abap enhancement sap_netw eaver adaptation enhancing customization personalization
abap_w d
Create one webdynpro component in se80 like below screen shot
Call the other component from ur component
Posted by John Kalaiyarasan Jan 10 2013
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
then create one button in your view controller layout-gtfor that button create one custom action
then click on that action write the following code
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW
data lv_str type string
LO_API_COMPONENT = WD_COMP_CONTROLLER-gtWD_GET_API( )
LO_WINDOW_MANAGER = LO_API_COMPONENT-gtGET_WINDOW_MANAGER( )
CALL METHOD CL_WD_UTILITIES=gtCONSTRUCT_WD_URL
EXPORTING
APPLICATION_NAME = ZWD_TRAINING_FEEDBACK
IMPORTING
OUT_ABSOLUTE_URL = lv_str
In the above screen shot mention your webdynpro component name and defined variable name to hold the
component url
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
CALL METHOD LO_WINDOW_MANAGER-gtCREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_str
MODAL = ABAP_true
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW
LO_WINDOW-gtOPEN( )
In the above screen shot call external popup window and also pass the component url
then right on your webdynpro component-gtwebdynpro application
save active and test your application it will call the other component
1069 View s 2 Comments Tags w eb_dynpro
This blog explains how to navigate from one component view to other component view without adding Used
Components
Scenario Source component contains View with LinkToAction UI element on click of this Link navigates to
Destination component View without adding Used Component in the Source ComponentThis is can be achieved
using Dynamic Navigation by following interface IF_WD_NAVIGATION_SERVICES and method
do_dynamic_navigation
Prerequisites Should have basic knowledge on Web Dynpro ABAP
Create Two Web Dynpro Component by following
Destination Component
Create Web Dynpro with View and Window
Insert Caption UI Element in the View
Navigation from one component view to othercomponet view without adding Used Components
Posted by Sridhar S Jan 7 2013
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Embed the View into WindowActivate whole component
Source Component
Create Web Dynpro with View and Window See below there is no Used Component
Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction
UI Element
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Code
data lv_view_api type ref to if_wd_view_controller
lv_nav_serv type ref to if_wd_navigation_services
lv_view_api = wd_this-gtwd_get_api( )
lv_nav_serv = lv_view_api
lv_nav_serv-gtdo_dynamic_navigation(
source_window_name = W_COMP2
source_vusage_name = V_COMP2_USAGE_1
source_plug_name = DEFAULT
PLUG_PARAMETERS = PLUG_PARAMETERS
target_component_name = ZTEST_COMP1
target_component_usage = ZTEST_COMP1
target_view_name = W_COMP1
target_plug_name = DEFAULT
TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
)
Embed this View into Window Activate whole component
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Create the Webdynpro Application by following
Demo Select the above application Right click and Test When you clicks on below link it navigates to Destination
Components View
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
1212 View s 0 Comments Tags navigation w eb_dynpro dynamic
Dear All One of the way to display the GOS PDF document via Webdynpro hope this will help Step1 Select the list of
attachments from the business document using function module BDS_ALL_CONNECTIONS_GET for this you need
the following inputs Classname Classtype and objkey Step2 Convert the file ID (loio_id from the above function
module) to xstring using the method ldquoattachment_get_detailrdquo from the class ldquocl_hap_wd_document_uirdquo Data
lv_aid type bds_docid lv_fcon type string lv_fchex type xstring lv_mftyp type string lv_ret type bapiret2
attachment_get_detail( exporting attachment_id = lv_aid attachment_type = pdf importing
file_content = lv_fcon file_content_hex = lv_fchex mime_file_type = lv_mftyp s_return =
lv_ret ) Step3 Display the document in new browser using the method attach_file_to_response from
class cl_wd_runtime_services data l_file type string l_mime type string pdf_data type xstring l_mime =
applicationpdf l_file = titlepdf call method cl_wd_runtime_services=gtattach_file_to_response exporting
i_filename = l_file i_content = lv_fchex i_mime_type = l_mime
479 View s 2 Comments Tags w eb_dynpro
How to display GOS PDF document from Webdynpro
Posted by Prabhu Rajesh Jan 4 2013
In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro
ArchitectureWe generate a simple string in ABAP and send it to a servlet on a J2EE server This servlet generates an image with
SimpleCaptcha httpsimplecaptchasourceforgenet The generated images is received on the ABAP stack and
copied to a cached response so the captchastring is not in the url of the image
The source of the java application can be downloaded here (tested on SAP NW 731 SP5)
Captcha ServletThis is a simple servlet application that generates a captcha image from a given string
1 Download the simplecaptcha library
2 Create an external library DC and name it captchalib
3 Add the simplecaptcha jar-file to the libraries folder
4 Add the jar-files to the public part of the library
5 Create a new web module development component and name it captcha
6 Add a DC dependency between the web module and the library
7 Add a new servlet and give it a name and package
8 Copy the simplecaptchajar to the WEB-INFlib directory
9 Enter the following code
Using captcha in ABAP Webdynpro
Posted by Joachim Van Praet Dec 11 2012
01 package comflexsocaptcha
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
10 Add a class WordGenerator to be able to decide which word will be used to generate the captcha image
11 Adapt the webxml
12 Create an enterprise application DC with the name captchaear
13 Add the web module to the captchaear project
14 Adapt the applicationxml
02 import javaioIOException
03 import javautilArrayList
04 import javautilList
05 import javaxservletServletException
06 import javaxservlethttpHttpServlet
07 import javaxservlethttpHttpServletRequest
08 import javaxservlethttpHttpServletResponse
09 import comflexsocaptchanoiseCustomNoiseProducer
10 import nlcaptchaCaptcha
11 import nlcaptchaservletCaptchaServletUtil
12 import javaawtColor
13 import javaawtFont
14 public class CaptchaImage extends HttpServlet
15 private static final long serialVersionUID = 1L
16 private static int _width = 180
17 private static int _height = 60
18 private static final ListltColorgt COLORS = new ArrayListltColorgt(2)
19 private static final ListltFontgt FONTS = new ArrayListltFontgt(3)
20 static
21 COLORSadd(ColorBLACK)
22 COLORSadd(ColorBLUE)
23 FONTSadd(new Font(Geneva 2 48))
24 FONTSadd(new Font(Courier 1 48))
25 FONTSadd(new Font(Arial 1 48))
26
27 public CaptchaImage()
28 super()
29
30 protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
31 responsesetContentType(imagepng)
32 responsesetCharacterEncoding(UTF-8)
33 String word = requestgetParameter(captcha)
34 WordGenerator wordRenderer = new WordGenerator(word)
35 Captcha captcha = new CaptchaBuilder(_width _height)addText(wordRenderer)
36 gimp()
37 addNoise())
38 build()
39 CaptchaServletUtilwriteImage(response captchagetImage())
40
41
01 package comflexsocaptcha
02 import nlcaptchatextproducerTextProducer
03 public class WordGenerator implements TextProducer
04
05 private String text =
06 public WordGenerator(String text)
07 thistext = text
08
09 public String getText()
10 return thistext
11
12
01 ltxml version=10 encoding=UTF-8gt
02 ltweb-app xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~flexsocomltdisplay-namegt
04 ltservletgt
05 ltdescriptiongtltdescriptiongt
06 ltdisplay-namegtCaptchaImageltdisplay-namegt
07 ltservlet-namegtCaptchaImageltservlet-namegt
08 ltservlet-classgtcomflexsocaptchaCaptchaImageltservlet-classgt
09 ltservletgt
10 ltservlet-mappinggt
11 ltservlet-namegtCaptchaImageltservlet-namegt
12 lturl-patterngtcaptchapnglturl-patterngt
13 ltservlet-mappinggt
14 ltweb-appgt
01 ltxml version=10 encoding=ASCIIgt
02 ltapplication xmlnsxsi=httpwwww3org2001XMLSchema-instance xmlns=httpjavasuncomxmlnsjavaee
03 ltdisplay-namegtLocalDevelopment~captcha~ear~flexsocomltdisplay-namegt
04 ltmodulegt
05 ltwebgt
06 ltweb-urigtflexsocom~captchawarltweb-urigt
07 ltcontext-rootgtcaptchaltcontext-rootgt
08 ltwebgt
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
15 Deploy the ear file
16 Test the captcha httpltportalservergtltportgtcaptchacaptchapngcaptcha=test
ABAP Webdynpro application
In the ABAP WD application we build a random string to send to the captcha application
We request the captcha image on the ABAP server and provide it in a cached response to our webdynpro application
to hide the captcha string in the url
1 Create a new web dynpro component
2 In the component controller create a context node CAPTCHA with 3 strings SOURCE ANSWER IMAGE
3 Create method generate_captcha in the component controller In this method we create a random string with
this string we build the url to the J2EE server to generate the captcha image At the end of the method we copy the
image from the java server to a cached response on the ABAP stack and then we fill the context This is the code
4 To copy the image from the JAVA response to the ABAP response I created a separate method
GET_CACHED_URL Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)
09 ltmodulegt
10 ltapplicationgt
01 method GENERATE_CAPTCHA
02 CONSTANTS CO_ALFABET type CHAR30 VALUE abcdefghijklmnopqrstuvwxyz
03 DATA lv_captcha type CHAR08
04 lv_i type i
05 lv_char type CHAR01
06 lv_seed type i
07 lo_ran type ref to cl_abap_random_int
08 lv_url type string
09 lv_length type i value 8
10 generate a random string with length lv_length
11 lv_seed = sy-timlo
12 lv_i = STRLEN( co_alfabet ) - 1
13 lo_ran = cl_abap_random_int=gtcreate( min = 0 max = lv_i seed = lv_seed )
14 DO lv_length TIMES
15 lv_i = lo_ran-gtget_next( )
16 lv_char = CO_ALFABET+lv_i(1)
17 lv_i = lo_ran-gtget_next( )
18 if lv_i MOD 2 = 0
19 TRANSLATE lv_char TO UPPER CASE
20 endif
21 CONCATENATE lv_captcha lv_char into lv_captcha
22 ENDDO
23 build url to generate captcha image
24 CONCATENATE captchacaptchapngcaptcha= lv_captcha into lv_url
25 lv_url = wd_this-gtGET_CACHED_URL( lv_url )
26 Set data in context
27 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
28 DATA lo_el_captcha TYPE REF TO if_wd_context_element
29 DATA ls_captcha TYPE wd_this-gtElement_captcha
30 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
31 lo_el_captcha = lo_nd_captcha-gtget_element( )
32 lo_el_captcha-gtset_attribute( name = `SOURCE` value = lv_captcha )
33 lo_el_captcha-gtset_attribute( name = `IMAGE` value = lv_url )
34 endmethod
01 method GET_CACHED_URL
02 DATA lo_http_client TYPE REF TO if_http_client
03 lo_cached_response TYPE REF TO IF_HTTP_RESPONSE
04 lv_image TYPE xstring
05 lv_guid TYPE GUID_32
06 read the image on the java server
07 CALL METHOD cl_http_client=gtcreate_by_url
08 EXPORTING
09 url = httpltjavaservergtltportgt
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
5 Open the view of the webdynpro
6 In the context tab bind the CAPTCHA node from the componentcontroller
7 In the layout tab add following elements to the view
a An image and bind the source property to attribute IMAGE af the CAPTCHA node
b An input field and bind the property value to attribute ANSWER of the CAPTCHA node
c A button lsquocheck captcharsquo and assign an action CHECK
d A button refresh and assign an action REFRESH
8 Implement the 2 actionhandlers
10 IMPORTING
11 client = lo_http_client
12 EXCEPTIONS
13 OTHERS = 1
14 CALL METHOD lo_http_client-gtrequest-gtset_header_field
15 EXPORTING
16 name = ~request_uri
17 value = iv_url
18 CALL METHOD lo_http_client-gtsend
19 EXCEPTIONS
20 http_communication_failure = 1
21 http_invalid_state = 2
22 http_processing_failed = 3
23 CALL METHOD lo_http_client-gtreceive
24 EXCEPTIONS
25 http_communication_failure = 1
26 http_invalid_state = 2
27 http_processing_failed = 3
28 lv_image = lo_http_client-gtresponse-gtget_data( )
29 send the image to the cached response on the ABAP server
30 CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1
31 SET IMAGE TO MIME
32 lo_cached_response-gtSET_DATA( lv_image )
33 lo_cached_response-gtSET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=gtCONTENT_TYPE VALUE = imagepng )
34 lo_cached_response-gtSET_STATUS( CODE = 200 REASON = OK )
35 lo_cached_response-gtSERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 )
36 generate an url
37 CALL FUNCTION GUID_CREATE
38 IMPORTING
39 EV_GUID_32 = lv_guid
40 CL_WD_UTILITIES=gtCONSTRUCT_WD_URL( EXPORTING
41 APPLICATION_NAME = Z_CAPTCHA WEBDYNPRO APPLICATION NAME
42 IMPORTING OUT_LOCAL_URL = OV_URL )
43 CONCATENATE OV_URL lv_guid sy-uzeit png INTO OV_URL
44 CL_HTTP_SERVER=gtSERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE )
45 endmethod
01 method ONACTIONCHECK
02 DATA lo_nd_captcha TYPE REF TO if_wd_context_node
03 DATA lo_el_captcha TYPE REF TO if_wd_context_element
04 DATA ls_captcha TYPE wd_this-gtElement_captcha
05 get message manager
06 data lo_api_controller type ref to if_wd_controller
07 data lo_message_manager type ref to if_wd_message_manager
08 data lv_Str type string
09 lv_text type string
10 lv_type type I
11 read context
12 lo_nd_captcha = wd_context-gtget_child_node( name = wd_this-gtwdctx_captcha )
13 lo_el_captcha = lo_nd_captcha-gtget_element( )
14 lo_el_captcha-gtget_static_attributes( IMPORTING static_attributes = ls_captcha )
15 get message manager
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Create a web dynpro application object and test the application
Result
1867 View s 5 Comments Tags w eb_dynpro w eb_dynpro_abap captcha abap_w d
16 lo_api_controller = wd_This-gtWd_Get_Api( )
17 CALL METHOD lo_api_controller-gtGET_MESSAGE_MANAGER
18 RECEIVING
19 MESSAGE_MANAGER = lo_message_manager
20
21 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_ERROR
22 lv_text = ERROR
23 TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE
24 TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE
25 compare captcha answer with the source
26 if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER
27 lv_type = IF_WD_MESSAGE_MANAGER=gtCO_TYPE_STANDARD
28 lv_text = OK
29 endif
30 report message
31 CALL METHOD lo_message_manager-gtREPORT_MESSAGE
32 EXPORTING
33 MESSAGE_TEXT = lv_text
34 MESSAGE_TYPE = lv_type
35 RECEIVING
36 MESSAGE_ID = lv_str
37
38 endmethod
39 method ONACTIONREFRESH
40 WD_COMP_CONTROLLER-gtGENERATE_CAPTCHA( )
41 endmethod
Go to Tcode SE80
Select MIME Repository
Select faviconico The path is SAP gt PUBLIC gt BC gt UR gt Login gt assests
Change Logo on Address Bar for WD Appl
Posted by Dhivya Baskaran Dec 6 2012
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Change the icon by Right Click faviconico and select Upload and Replace from UploadDownload dropdown
Then select the image from local disk
Save the properties
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext
Follow SCNSite Index Contact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright
Now if you restart the application The URL address bar image will be the image you have uploaded Thus we
successfully changed the Logo in Address bar
1285 View s 7 Comments Tags w eb_dynpro basis w ebdynpro_abap
1 hellip 3 4 5 6 7 8
PreviousNext