Skip to Content

HI every one,

                   as one some one raised question regarding the dropdown by key using supply function here it is.

SCENARIO:   here i am having the three drop downs one is COMPANY CODE,second is PLANT ,third is STORAGE LOCATION.

       when the company code is changed then the corrosponding plants related to the changed company code are loaded ,the corresponding storage location details for the plant in the leadselection are loaded automatically.

/wp-content/uploads/2014/10/0_1_563995.jpg

when we change company code from 0001 to 0005 then the corrosponding plants are loaded into dropdown

and one is lead selected ,based on the leadselected plant the respective storage locations are also loaded.

/wp-content/uploads/2014/10/0_2_564061.jpg

STEP1:  CREATE GLOBAL CLASS.

/wp-content/uploads/2014/10/1_564064.jpg

method GET_ALL_COMPANY_CODES_DROP.
*  TYPES:BEGIN OF TY_BUKRS,
*         BUKRS TYPE BUKRS,
*         END OF TY_BUKRS.
DATA:LT1_BUKRS TYPE wdr_context_attr_value_list.

select bukrs as value BUKRS as text from t001 into TABLE lt1_bukrs.
lt_ccode
= lt1_bukrs.
endmethod.

method GET_PLANT_BY_COMP_CODE_DROP.
types :begin of ty_bwkey,
bwkey
type bwkey,
end of ty_bwkey.

data:lt_bwkey TYPE TABLE OF ty_bwkey,
lt1_werks
TYPE  wdr_context_attr_value_list.

select bwkey from t001k into table lt_bwkey where bukrs = c_code.
if sydbcnt <> 0.
select werks as value werks as text from t001w into table lt1_werks for ALL ENTRIES IN lt_bwkey where bwkey = lt_bwkeybwkey.
if sysubrc = 0.
lt_werks
= lt1_werks.
endif.
endif.
endmethod.

method GET_STORGAE_BY_PLANT_DROP.

DATA:LT1_LGORT TYPE wdr_context_attr_value_list.
select lgort as value lgort as text from t001l INTO TABLE LT1_LGORT where  werks = c_WERKS.
LT_LGORT
= LT1_LGORT.

endmethod.

method GET_ALL_COMPANY_CODES.
TYPES:BEGIN OF TY_BUKRS,
BUKRS
TYPE BUKRS,
END OF TY_BUKRS.
DATA:LT1_BUKRS TYPE TABLE OF TY_BUKRS.

select bukrs from t001 into TABLE lt1_bukrs.
lt_ccode
= lt1_bukrs.
endmethod.

method GET_PLANT_BY_COMAPANY_CODE.
types :begin of ty_bwkey,
bwkey
type bwkey,
end of ty_bwkey,
begin of ty_werks,
werks
type werks_d,
end of ty_werks.

data:lt_bwkey TYPE TABLE OF ty_bwkey,
lt1_werks
TYPE TABLE OF  ty_werks.

select bwkey from t001k into table lt_bwkey where bukrs = c_code.
if sydbcnt <> 0.
select werks from t001w into table lt1_werks for ALL ENTRIES IN lt_bwkey where bwkey = lt_bwkeybwkey.
if sysubrc = 0.
lt_werks
= lt1_werks.
endif.
endif.
endmethod.

method GET_STORGAE_LOCATION_BY_PLANT.
types: begin of ty_werks,
werks
type werks_d,
end of ty_werks.
DATA:LT1_LGORT TYPE TABLE OF ty_werks.
select lgort from t001l INTO TABLE LT1_LGORT where  werks = c_WERKS.
LT_LGORT
= LT1_LGORT.
endmethod.


/wp-content/uploads/2014/10/2_1_564073.jpg

/wp-content/uploads/2014/10/2_2_564080.jpg

/wp-content/uploads/2014/10/2_3_564068.jpg

/wp-content/uploads/2014/10/2_4_564102.jpg

/wp-content/uploads/2014/10/2_5_564070.jpg

/wp-content/uploads/2014/10/2_6_564081.jpg

method WDDOINIT .
DATA lo_nd_level1 TYPE REF TO if_wd_context_node.

DATA ls_level1 TYPE wd_this->Element_level1.
DATA lt_level1 TYPE wd_this->Elements_level1.

*   navigate from <CONTEXT> to <LEVEL1> via lead selection
lo_nd_level1
= wd_context->get_child_node( name = wd_this->wdctx_level1 ).

CALL METHOD ZCL_LEVELS=>GET_ALL_COMPANY_CODES
IMPORTING
LT_CCODE
= LT_LEVEL1
.

lo_nd_level1->bind_table( new_items = lt_level1 set_initial_elements = abap_false ).
endmethod.



method SUPPLY_LEVELS .
* General Notes
* =============
* A common scenario for a supply method is to aquire key
* informations from the parameter <parent_element> and then
* to invoke a data provider.
* A free navigation thru the context, especially to nodes on
* the same or deeper hierachical level is strongly discouraged,
* because such a strategy may easily lead to unresolvable
* situations!!

*  if necessary, get static attributes of parent element
DATA: ls_parent_attributes_level1 TYPE wd_this->element_level1,
ls_parent_attributes_level2
type wd_this->element_level2,
lo_nd_node
type ref to if_wd_context_node,
lo_nd_node_info
type ref to if_wd_context_node_info,
lv_node_name
type string,
value_set
type wdr_context_attr_value_list,
lo_nd_level2
TYPE REF TO if_wd_context_node,
lo_nd_level2_info
TYPE REF TO if_wd_context_node_info,
lo_nd_level3_info
TYPE REF TO if_wd_context_node_info,
lt_level2
TYPE wd_this->Elements_level2,
lo_nd_level3
TYPE REF TO if_wd_context_node,
lt_level3
TYPE wd_this->Elements_level3.

lo_nd_node = parent_element->GET_NODE( ).
lo_nd_node_info
= lo_nd_node->GET_NODE_INFO( ).
lv_node_name
= lo_nd_node_info->GET_NAME( ).

case lv_node_name.
when wd_this->wdctx_level1.

*        navigate from <CONTEXT> to <LEVEL2> via lead selection
lo_nd_level2
= wd_context->path_get_node( path = `LEVEL1.LEVEL2` ).
lo_nd_level2_info
= lo_nd_level2->GET_NODE_INFO( ).

parent_element->get_static_attributes(
IMPORTING
static_attributes
= ls_parent_attributes_level1 ).
CALL METHOD ZCL_LEVELS=>GET_PLANT_BY_COMAPANY_CODE
EXPORTING
C_CODE  
= ls_parent_attributes_level1bukrs
IMPORTING
LT_WERKS
= lt_level2.
CALL METHOD ZCL_LEVELS=>GET_PLANT_BY_COMP_CODE_DROP
EXPORTING
C_CODE  
= ls_parent_attributes_level1bukrs
IMPORTING
LT_WERKS
= value_set.

lo_nd_level2_info->set_attribute_value_set( name = ‘WERKS’ value_set = value_set ).
lo_nd_level2
->bind_table( new_items = lt_level2 set_initial_elements = abap_false ).

when wd_this->wdctx_level2.

*        navigate from <CONTEXT> to <LEVEL3> via lead selection
lo_nd_level3
= wd_context->path_get_node( path = `LEVEL1.LEVEL2.LEVEL3` ).
lo_nd_level3_info
= lo_nd_level3->GET_NODE_INFO( ).
parent_element
->get_static_attributes(
IMPORTING
static_attributes
= ls_parent_attributes_level2 ).

CALL METHOD ZCL_LEVELS=>GET_STORGAE_LOCATION_BY_PLANT
EXPORTING
C_WERKS 
= ls_parent_attributes_level2werks
IMPORTING
LT_LGORT
= lt_level3.
CALL METHOD ZCL_LEVELS=>GET_STORGAE_BY_PLANT_DROP
EXPORTING
C_WERKS 
= ls_parent_attributes_level2werks
IMPORTING
LT_LGORT
= value_set.

lo_nd_level3_info->set_attribute_value_set( name = ‘LGORT’ value_set = value_set ).

lo_nd_level3->bind_table( new_items = lt_level3 set_initial_elements = abap_false ).
ENDCASE.
endmethod.



/wp-content/uploads/2014/10/3_1_564094.jpg


/wp-content/uploads/2014/10/3_2_564098.jpg


/wp-content/uploads/2014/10/3_3_564099.jpg


/wp-content/uploads/2014/10/3_4_564100.jpg


/wp-content/uploads/2014/10/3_5_564101.jpg

/wp-content/uploads/2014/10/3_6_564093.jpg



method WDDOINIT .
DATA lo_nd_level1 TYPE REF TO if_wd_context_node.
DATA lo_el_level1 type ref to if_wd_context_element.
DATA lo_nd_level1_info TYPE REF TO if_wd_context_node_info.
DATA ls_level1 TYPE wd_this->Element_level1.
DATA lo_nd_level2 TYPE REF TO if_wd_context_node.
data lo_el_level2 type ref to if_wd_context_element.
DATA lo_nd_level2_info TYPE REF TO if_wd_context_node_info.
DATA ls_level2 TYPE wd_this->Element_level2.
DATA lo_nd_level3 TYPE REF TO if_wd_context_node.
DATA lo_nd_level3_info TYPE REF TO if_wd_context_node_info.
DATA lo_el_level3 TYPE REF TO if_wd_context_element.
data value_set type wdr_context_attr_value_list.

*   navigate from <CONTEXT> to <LEVEL1> via lead selection
lo_nd_level1
= wd_context->get_child_node( name = wd_this->wdctx_level1 ).
lo_nd_level1_info
= lo_nd_level1->GET_NODE_INFO( ).
lo_el_level1
= lo_nd_level1->GET_ELEMENT( ).
lo_el_level1
->get_static_attributes(
IMPORTING
static_attributes
= ls_level1 ).

CALL METHOD ZCL_LEVELS=>GET_ALL_COMPANY_CODES_DROP
IMPORTING
LT_CCODE
= value_set
.

lo_nd_level1_info->set_attribute_value_set( name = ‘BUKRS’ value_set = value_set ).

*     navigate from <CONTEXT> to <LEVEL2> via lead selection
lo_nd_level2
= wd_context->path_get_node( path = `LEVEL1.LEVEL2` ).
lo_nd_level2_info
= lo_nd_level2->GET_NODE_INFO( ).
lo_el_level2
= lo_nd_level2->GET_ELEMENT( ).

* navigate from <CONTEXT> to <LEVEL3> via lead selection
lo_nd_level3
= wd_context->path_get_node( path = `LEVEL1.LEVEL2.LEVEL3` ).
lo_nd_level3_info
= lo_nd_level3->GET_NODE_INFO( ).
lo_el_level3
= lo_nd_level3->get_element( ).
*  refresh value_set.

endmethod.

  method ONACTIONON_LEVEL_SELECT .


DATA lo_nd_level1 TYPE REF TO if_wd_context_node.
DATA lo_nd_level2 TYPE REF TO if_wd_context_node.
DATA lo_nd_level3 TYPE REF TO if_wd_context_node.
DATA lt_level1 TYPE wd_this->Elements_level1.
data ls_level1 like line of lt_level1.
DATA lt_level2 TYPE wd_this->Elements_level2.
data ls_level2 like line of lt_level2.
DATA lt_level3 TYPE wd_this->Elements_level3.
data ls_level3 like line of lt_level3.
data:lv_key type string,
lv_index
type i.
CALL METHOD WDEVENT->GET_DATA
EXPORTING
NAME  
= ‘KEY’
IMPORTING
VALUE  = lv_key.
CASE ID.

WHEN ‘LEVEL1’.

lo_nd_level1 = wd_context->get_child_node( name = wd_this->wdctx_level1 ).
lo_nd_level1
->get_static_attributes_table( importing table = lt_level1 ).
loop at lt_level1[] into ls_level1.
if ls_level1bukrs = lv_key.
lv_index
= sytabix.
endif.
ENDLOOP.

CALL METHOD lo_nd_level1->SET_LEAD_SELECTION_INDEX
EXPORTING
INDEX  = lv_index
.

WHEN ‘LEVEL2’.

lo_nd_level2 = wd_context->path_get_node( path = `LEVEL1.LEVEL2` ).
lo_nd_level2
->get_static_attributes_table( importing table = lt_level2 ).
loop at lt_level2[] into ls_level2.
if ls_level2werks = lv_key.
lv_index
= sytabix.
endif.
ENDLOOP.

CALL METHOD lo_nd_level2->SET_LEAD_SELECTION_INDEX
EXPORTING
INDEX  = lv_index
.

WHEN ‘LEVEL3’.

lo_nd_level3 = wd_context->path_get_node( path = `LEVEL1.LEVEL2.LEVEL3` ).
lo_nd_level3
->get_static_attributes_table( importing table = lt_level3 ).
loop at lt_level3[] into ls_level3.
if ls_level3lgort = lv_key.
lv_index
= sytabix.
endif.
ENDLOOP.

CALL METHOD lo_nd_level3->SET_LEAD_SELECTION_INDEX
EXPORTING
INDEX  = lv_index
.
ENDCASE.


endmethod.





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