Skip to Content

First create the Web Dynpro component then your view automatically embedded into window, Now your component will look like below.

1.PNG

To create the context click on context menu on v_view. For create the context node and attribute make the cordiality as mention below,  here visi attribute have the type as wdui_visibility for dynamically change the visibility. Bill and Nbill have the type as wdy_boolean for handle the read_only attribute.

2.PNG

Click on layout button to design the user interface,

Steps,

1.Right click on Root ui element container->insert element->id Tc1->Typ->Transparent container.

2. Right click on Tc->create form->Select the note slee

3. Follow the same step as mention in step 1 but give the id Tc.

4. Same as step 1 instead of transparent container insert one table give id name as Table Then create binding.

3.PNG

4.PNG

5.PNG

6.PNG

7.PNG

8.PNG

Here Billable is has the value from drop down by key i.e from data element. Then create on enter action for sele then write the below code,

DATA lo_nd_slee TYPE REF TO if_wd_context_node.

     DATA lo_el_slee TYPE REF TO if_wd_context_element.

     DATA ls_slee TYPE wd_this->Element_slee.

     DATA lv_sele TYPE wd_this->Element_sleesele.

     DATA lv_tab TYPE REF TO cl_wd_table.

*   navigate from <CONTEXT> to <SLEE> via lead selection

     lo_nd_slee = wd_context->get_child_node( name = wd_this->wdctx_slee ).

*   get element via lead selection

     lo_el_slee = lo_nd_slee->get_element( ).

*   @TODO handle not set lead selection

     IF lo_el_slee IS INITIAL.

     ENDIF.

*   get single attribute

     lo_el_slee->get_attribute(

       EXPORTING

         name `SELE`

       IMPORTING

         value = lv_sele ).

   DATA lo_nd_n_bill TYPE REF TO if_wd_context_node.

   DATA ls_n_bill TYPE wd_this->Element_n_bill.

   DATA lt_n_bill TYPE wd_this->Elements_n_bill.

* navigate from <CONTEXT> to <N_BILL> via lead selection

   lo_nd_n_bill = wd_context->get_child_node( name = wd_this->wdctx_n_bill ).

CALL METHOD lo_nd_n_bill->INVALIDATE.

CLEAR lt_n_bill.

DO lv_sele TIMES.

APPEND ls_n_bill to lt_n_bill.

ENDDO.

   DATA lo_el_context TYPE REF TO if_wd_context_element.

* get element via lead selection

   lo_el_context = wd_context->get_element( ).

* set single attribute

   lo_el_context->set_attribute(

     name `VISI`

     value = 2 ).

   lo_nd_n_bill->bind_table( new_items = lt_n_bill set_initial_elements = abap_false ).

Create the on enter action on Table column Billable i.e for drop down field do the following,

DATA lo_tab TYPE REF TO cl_wd_table.

   DATA lo_nd_n_bill TYPE REF TO if_wd_context_node.

   DATA lo_el_n_bill TYPE REF TO if_wd_context_element.

   DATA ls_n_bill TYPE wd_this->Element_n_bill.

* navigate from <CONTEXT> to <N_BILL> via lead selection

   lo_nd_n_bill = wd_context->get_child_node( name = wd_this->wdctx_n_bill ).

“Read the Cursor position element

   lo_el_n_bill = wdevent->get_context_element(‘CONTEXT_ELEMENT’).

* get all declared attributes

   lo_el_n_bill->get_static_attributes(

     IMPORTING

       static_attributes = ls_n_bill ).

“Set the values

IF ls_n_billbillable = ‘BILLABLE’.

   CLEAR Ls_n_billCOST.

   Ls_n_billnbill = .

   ls_n_billbill = ‘X’.

     lo_el_n_bill->set_static_attributes(

     EXPORTING

       static_attributes = ls_n_bill ).

   ELSEIF ls_n_billbillable = ‘NON-BILLAB’.

    CLEAR: Ls_n_billCLIENT, Ls_n_billCLIENT_NAME.

   Ls_n_billnbill = ‘X’.

   ls_n_billbill = .

     lo_el_n_bill->set_static_attributes(

     EXPORTING

       static_attributes = ls_n_bill ).

ENDIF.

Then create application save + active and then test your component  will have the following output,

9.PNG

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply