Once the user will provide the input to the respective input fields and press the Search Button, it will call the Assistance class and fetch the data from the Database table and display the output to the tables of the respective tab strips.
method ONACTIONSEARCH_DETAILS .
*************************************************************************
***************** Material Number *******************
*************************************************************************
DATA lo_nd_material_number TYPE REF TO if_wd_context_node.
DATA lo_el_material_number TYPE REF TO if_wd_context_element.
DATA ls_material_number TYPE wd_this->element_material_number.
DATA lo_nd_plants TYPE REF TO if_wd_context_node.
DATA lo_el_plants TYPE REF TO if_wd_context_element.
DATA ls_plants TYPE wd_this->element_plants.
DATA: it_material TYPE zgt_material,
it_plant TYPE zgt_plant,
node_material TYPE REF TO if_wd_context_node,
node_plant TYPE REF TO if_wd_context_node.
* navigate from <CONTEXT> to <MATERIAL_NUMBER> via lead selection
lo_nd_material_number = wd_context->get_child_node( name = wd_this->wdctx_material_number ).
* get element via lead selection
lo_el_material_number = lo_nd_material_number->get_element( ).
* @TODO handle not set lead selection
IF lo_el_material_number IS INITIAL.
ENDIF.
* get all declared attributes
lo_el_material_number->get_static_attributes(
IMPORTING
static_attributes = ls_material_number ).
*************************************************************************
***************** Plant Input *******************
*************************************************************************
* navigate from <CONTEXT> to <PLANTS> via lead selection
lo_nd_plants = wd_context->get_child_node( name = wd_this->wdctx_plants ).
* get element via lead selection
lo_el_plants = lo_nd_plants->get_element( ).
* @TODO handle not set lead selection
IF lo_el_plants IS INITIAL.
ENDIF.
* get all declared attributes
lo_el_plants->get_static_attributes(
IMPORTING
static_attributes = ls_plants ).
* NAVIGATE FROM <CONTEXT> TO <Material_Details> VIA LEAD SELECTION .
node_material = wd_context->get_child_node('MATERIAL_DETAILS') .
* NAVIGATE FROM <CONTEXT> TO <Plant_Details> VIA LEAD SELECTION .
node_plant = wd_context->get_child_node('PLANT_DETAILS').
IF ls_material_number IS NOT INITIAL OR ls_plants IS NOT INITIAL.
CALL METHOD wd_assist->get_material_plant
EXPORTING
im_matnr = ls_material_number-matnr
im_werks = ls_plants-werks
IMPORTING
et_material = it_material
et_plant = it_plant.
ENDIF.
*** Binding <Internal tables> to the respective <Nodes>:
node_material->bind_table( it_material ).
node_plant->bind_table( it_plant ).
endmethod.
The structures and table types, those are declared globally through transaction SE11 and used by the Webdynpro Component.
The Line type used for Material Details:
The Table type used for Material Details:
The line type used for the Plant Details:
The table type used for Plant Details:
As this code uses the Assistance Class to fetch the data from the Database table, we need to develop a global class.
The Assistance Class details to fetch the details of the material as well as the respective plants:
The Method: GET_MATERIAL_PLANT in the class.
METHOD get_material_plant.
**** Type Declaration
TYPES: BEGIN OF ty_mara,
matnr TYPE matnr,
mtart TYPE mtart,
matkl TYPE matkl,
meins TYPE meins,
END OF ty_mara.
TYPES: BEGIN OF ty_makt,
matnr TYPE matnr,
spras TYPE spras,
maktx TYPE maktx,
END OF ty_makt.
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
TYPES: BEGIN OF ty_t001w,
werks TYPE werks_d,
name1 TYPE name1,
bwkey TYPE bwkey,
kunnr TYPE kunnr_wk,
lifnr TYPE lifnr_wk,
END OF ty_t001w.
**** Data Declaration
DATA: wa_mara TYPE ty_mara,
it_mara TYPE TABLE OF ty_mara,
wa_makt TYPE ty_makt,
it_makt TYPE TABLE OF ty_makt,
wa_marc TYPE ty_marc,
it_marc TYPE TABLE OF ty_marc,
wa_t001w TYPE ty_t001w,
it_t001w TYPE TABLE OF ty_t001w,
es_material TYPE zty_material,
es_plant TYPE zty_plant.
**** Constant Declaration
CONSTANTS: co_spras TYPE spras VALUE 'E'.
**** Selecting data from MARA Table
SELECT matnr
mtart
matkl
meins
FROM mara
INTO TABLE it_mara
WHERE matnr EQ im_matnr.
IF sy-subrc = 0.
SELECT matnr
spras
maktx
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr
AND spras = co_spras.
IF sy-subrc = 0.
LOOP AT it_mara INTO wa_mara.
es_material-matnr = wa_mara-matnr.
es_material-mtart = wa_mara-mtart.
es_material-matkl = wa_mara-matkl.
es_material-meins = wa_mara-meins.
READ TABLE it_makt INTO wa_makt WITH KEY matnr = wa_mara-matnr.
IF sy-subrc = 0.
es_material-maktx = wa_makt-maktx.
APPEND es_material TO et_material.
CLEAR: wa_mara,
wa_makt,
es_material.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
IF im_werks IS NOT INITIAL.
SELECT matnr
werks
FROM marc
INTO TABLE it_marc
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr
AND werks = im_werks.
IF sy-subrc = 0.
SELECT werks
name1
bwkey
kunnr
lifnr
FROM t001w
INTO TABLE it_t001w
FOR ALL ENTRIES IN it_marc
WHERE werks = it_marc-werks
AND werks = im_werks.
IF sy-subrc = 0.
LOOP AT it_t001w INTO wa_t001w.
es_plant-werks = wa_t001w-werks.
es_plant-name1 = wa_t001w-name1.
es_plant-bwkey = wa_t001w-bwkey.
es_plant-kunnr = wa_t001w-kunnr.
es_plant-lifnr = wa_t001w-lifnr.
APPEND es_plant TO et_plant.
CLEAR: wa_t001w,
es_plant.
ENDLOOP.
ENDIF.
ENDIF.
ELSE.
SELECT matnr
werks
FROM marc
INTO TABLE it_marc
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr.
IF sy-subrc = 0.
SELECT werks
name1
bwkey
kunnr
lifnr
FROM t001w
INTO TABLE it_t001w
FOR ALL ENTRIES IN it_marc
WHERE werks = it_marc-werks.
IF sy-subrc = 0.
LOOP AT it_t001w INTO wa_t001w.
es_plant-werks = wa_t001w-werks.
es_plant-name1 = wa_t001w-name1.
es_plant-bwkey = wa_t001w-bwkey.
es_plant-kunnr = wa_t001w-kunnr.
es_plant-lifnr = wa_t001w-lifnr.
APPEND es_plant TO et_plant.
CLEAR: wa_t001w,
es_plant.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
The output of the program will be as follows where we can find the details of the material and plantin two respective tabs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |