Message Handling in Web Dynpro
 ( Assistance Class )


Step 1 :       Go to SE80 and create a web dynpro component ‘ZWD_MSG_HANDLE’


1.a) Select ‘YES’


1.b Provide description and Press ‘Enter’


1.c)    Provide name package name and save it       


Step 2 :  Creating Assistance Class.
2.aDouble click on component name


2.b)   Ensure Editing mode (Ctrl + F1)


2.c)   Provide an assistance class name starts with ‘Z’ and double click on it


2.d Select ‘Yes’


2.e)  Provide Package name

 

The following screen will appear


2.f)  Slect menu path Goto->Text Elements


2.g)  Provide message texts, save(Ctrl + S) , activate(Ctrl+F3) and Go back(F3).

 

Step 3 : Double click on main view to create context attribute and to design layout

 

3.a)    Right Click the context to create an attribute


3.b)    Provide attribute name and data type


3.c)    Goto ‘Layout’ tab
Creating Label ‘Name’


Creating Input Field


Binding the context attribute value ‘NAME’ to input field


Creating Push button and creating event ‘Validate’ 


Step 4 :  Goto ‘Method’ tab and double click on method ‘ONACTIONVALIDATE’


4.a Select Code Wizard(Ctrl + F7)


Read the value of the context attribute ‘NAME’


The variable ‘lv_name’ holds the input value


Declare a variable named ‘msg’ which will hold message texts


Using code wizard(Ctrl + F7),  Select radio button ‘Generate Message’ and choose a method ‘REPORT_ERROR_MESSAGE’ from the F4 help and press Enter


Delete the below selected lines


When user does not enter input value, Using instance object wd_assist, assign the error message text to variable ‘msg’ and call the method 'report_message_error', Otherwise assign success message text to variable ‘msg’ and call the method 'report_success'.


Activate the whole web dynpro component.

Step 5 : Create web dynpro application, enter description and save it



Right click on created application and choose ‘test’

 

OUTPUT :

When input field is empty


When input value is provided



By
R.Karthick,
Kaavian Systems.






Character to Currency format conversion 
(No Function Module)

I crossed across a requirement to convert amount in character type to currency format. The below code will convert the character type amount to formatted currency value.

Source Code :

REPORT  ZCHAR2CURR.
parameters  char(30type c.
data      : txt(30type c,
            curr(
40type c,
            len 
type i,
            temp 
type i.
len = 
strlen( char ).
temp = len - 
2.
concatenate ',' char+temp(2into txt.
curr = txt.
char = char+
0(temp).
len = 
strlen( char ).
do.
if len gt 3.
temp = len - 
3.
concatenate ',' char+temp(3into txt.
concatenate txt curr into curr.
char = char+
0(temp).
len = 
strlen( char ).
else.
txt = char+
0(len).
concatenate txt curr into curr.
exit.
endif.
enddo.
concatenate curr '.00' into curr.
write : 'Amount in Currency format :', curr.


OUTPUT :




OVS Search Help in Web Dynpro


­OVS (Object Value Selector) Search Help


Steps to implement OVS search help

1.      Create a new web dynpro component ‘zsimple_ovs’



2.Give Description and Press Enter



3.      Save (Ctrl + S)



4.      Ensure change mode (Ctrl + F1)



5.      Add a component ‘WDR_OVS’ in the used components tab and Save.



6.      Double click on the ‘Main’ in the tree ‘Views’.



7.      Go to ‘Properties’ tab and click on ‘Create Controller Usage’.



8.      Select the OVS component from the list and Save.



9.      Go to ‘Context’ tab and Right click the context node to create the attribute ‘MATNR’ for which we are going to implement search help.



10.  Provide Attribute name, Type and select ‘Object Value Selector’ as Input Help Mode.



11.  Select the OVS component as OVS Component Usage from the F4 Help Option and Save.



12.  Go to ‘Layout’ Tab , Right click ‘ROOTUIELEMENTCONTAINER’ and
Select ‘Insert Element’ to insert a new UI Element.



13.  Enter the ‘ID and Type as 'Label'(for Label) and press Enter. Provide label text and select  'Label for' values in its property bar. 

    

14.  Similarly create an input field.


    

15.  Bind the context attribute ‘MATNR’ to the value of the created input field and Save.


16.  Go to ‘Methods’ Tab and Enter the method name as ‘ON_OVS’ (Predefined Method),  method type as ‘Event Handler’, description and select the component ‘OVS’ in the F4 help option of the ‘Component Use’.



17.  Double click on method ‘on_ovs’. Then the following default coding would have been generated in this method.



18.  Try to understand the purpose of these codes as explained below. 
      Search Help Window will look below,



So let us explain the code using Search Help Window.

           *  If we want to use multiple fields for selection criteria, we can define those fields here, which will be shown in the screen.


Ex.

  types:
    
begin of lty_stru_input,
*   add fields for the display of your search input here
      matnr 
type mara-matnr,
    
end of lty_stru_input.


(Note : Here the label text will be automatically assigned from the data element which we have referred for the field.)

          *  This structure contains the fields for the internal table in which we store the data using select query depending on the data entered in the above fields.


Ex.

  types:
    
begin of lty_stru_list,
*   add fields for the selection list here
    matnr 
type mara-matnr,
    mtart type mara-mtart,
    
end of lty_stru_list.



          *  If you want to use your own label text rather than from data element, we can specify here.



Ex.

ls_text-name = `MATNR`.  "must match a field name of search
ls_text-
value = `My Material Number`"wd_assist->get_text( `001` ).
insert ls_text into table lt_label_texts.




          *  Below diagram shows which data the work area or table stores.




          *  Select query is used to retrieve the data for search help



Ex.

"variable
data : lv_matnr type string.

"assigning input text (Ex. 400* ) to variable
lv_matnr = <ls_query_params>-matnr.


if not lv_matnr is initial.
"replacing last character '*' with '%' to use with select query
replace all occurrences of '*' in lv_matnr with '%'.
else.
lv_matnr = '%'.
endif.

"Select query to retrieve data based on the input data
select matnr mtart from mara into corresponding 
  fields of table lt_select_list
  
where matnr like lv_matnr.



          *  Finally uncomment the following code and replace the name with the context attribute ‘MATNR’ and the value with <ls-selection>-matnr.



Ex.

ovs_callback_object->context_element->set_attribute(
                          name  = 
`MATNR`
                          
value = <ls_selection>-matnr ).


Save and Activate.

Create Web Dynpro Application and save it.





Output :


Test the application

 








    By
    Karthick.R,
    Kaavian Systems Pvt Ltd.,