Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Using BAPI in Web Dynpro Application
 in SE80 Create a Web Dynpro Application ie. ZMATERIAL_WEBDYNPRO_BAPI

in this example we shall be displaying displaying details for a material passed to the BAPI

BAPI used :  BAPI_MATERIAL_DISPLAY

First create an COMPONENTCONTROLLER  in the Context Tab create a Node as BAPI_ MATERIAL_DISPLA

now create an Attribute with importing parameters for the BAPI

in the Methods Tab ( add a method like: EXECUTE_BAPI_MATERIAL_DISPLAY and dbl click on it

give the code below 

METHOD execute_bapi_material_display .

* declarations for context navigation
 
data lo_bapi_material_displa type ref to if_wd_context_node.
 
data  lo_importing type ref to if_wd_context_node.
 
data lo_material_evg type ref to if_wd_context_node.
 data lo_element type ref to if_wd_context_element.



* declarations for parameters
data lv_material type bapimatall-material.


 data ls_c_material_evg type.

if_componentcontroller=>element_material_evg.



* get all involved child nodes

  lo_bapi_material_displa = wd_context->get_child_node(

wd_this->wdctx_bapi_material_displa ).

  lo_importing = lo_bapi_material_displa->get_child_node(

 wd_this->wdctx_importing ).

  lo_material_evg = lo_importing->get_child_node(

wd_this->wdctx_material_evg ).



* get input from context

  lo_importing->get_attribute(

  exporting

      name  = 'MATERIAL'
 
importing

  value = lv_material ).



  lo_element = lo_material_evg->get_element( ).



  lo_element->get_static_attributes(

   IMPORTING static_attributes = ls_c_material_evg ).

 
Call Function ' BAPI_MATERIAL_DISPLAY'
   Exporting

       material =                        lv_material

       material_evg =                    ls_c_material_evg

"   IMPORTING

"      return =                          wd_this->return



* store output to context
ENDMETHOD.

Create a View -> MAIN

in the CONTEXT  Tab  of View Map the Nodes by draging the node BAPI_ MATERIAL_DISPLA form right to left

 in the Layout use the following UI Elements

AN input Field to  get the Material Number from User

Table , Button with Action ->GET MATERIAL

 in The METHODS Tab create an ACTION  ONACTIONGET_MATERIAL and give the code below

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L1S52 {
color: #0000FF;
}

method onactionget_material .

  data lo_componentcontroller type ref to ig_componentcontroller .
 lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
 lo_componentcontroller->execute_bapi_material_display(
  ).

endmethod.

now link the view with the WINDOW and create a web dynpro application , save and activate the the Application and TEST it.



  • No labels