Usage of ALV Function elements and making a column editable (ABAP WebDynpro)

...Previous 

8. Create a transparent container in the layout and include button for “Search” and “Save” functionality.  

 

 

9. Map the MARA node into DATA of the INTERFACECONTROLLER to pass the data into ALV.

 

10. Pull input_material into the FUNCTIONAL_ELEMENTS.

11. Include ALV TABLE VIEW into the View controller of the Material_master view. 

 

12. Populate the data in the WDDOINIT method of the MATERIAL_MASTER view for the MARA node.

  

11.  Include the Used controllers ALV_TABLE and INTERFACECONTROLLER in the view properties.

 

12. Code to fetch material data from MARA and bind it to node MARA.

METHOD wddoinit .
  DATA:
    node_mara      TYPE REF TO if_wd_context_node,
    elem_mara      TYPE REF TO if_wd_context_element,
    stru_mara      TYPE if_material_master=>element_mara .
  DATA:BEGIN OF wa_mara,
       matnr TYPE mara-matnr,
       lvorm TYPE mara-lvorm,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
       bismt TYPE mara-bismt,
       meins TYPE mara-meins,
       bstme TYPE mara-bstme,
       brgew TYPE mara-brgew,
       ntgew TYPE mara-ntgew,
       gewei TYPE mara-gewei,
       volum TYPE mara-volum,
       spart TYPE mara-spart,
       profl TYPE mara-profl,
       END OF wa_mara.
  DATA:t_mara LIKE TABLE OF wa_mara.
*  navigate from <CONTEXT> to <MARA> via lead selection
  node_mara = wd_context->get_child_node( name = if_material_master=>wdctx_mara ).
*-Bind Data into MARA node
  SELECT matnr
         lvorm
         mtart
         matkl
         bismt
         meins
         bstme
         brgew
         ntgew
         gewei
         volum
         spart
         profl FROM mara INTO TABLE t_mara
         WHERE ersda = '20080415'.
  node_mara->bind_table( t_mara ).
*Code to set ALV Editable
  DATA:
  lr_comp_alv TYPE REF TO if_wd_component_usage,
  lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
  lr_config TYPE REF TO cl_salv_wd_config_table.
*... ALV Component Usage
  lr_comp_alv = wd_this->wd_cpuse_alv_table( ).
  IF lr_comp_alv->has_active_component( ) IS INITIAL.
    lr_comp_alv->create_component( ).
  ENDIF.
  lr_comp_if_alv = wd_this->wd_cpifc_alv_table( ).
*... Configure ALV
  lr_config = lr_comp_if_alv->get_model( ).
  lr_config->if_salv_wd_table_settings~set_read_only(
      value  = abap_false
         ).
*Code to create material number as the input field in the ALV 
*toolbar and also to make Dangerous goods field as editable.          
  DATA lr_inputui1 TYPE REF TO cl_salv_wd_fe_input_field.
  DATA input1 TYPE REF TO cl_salv_wd_function.
  DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
  lr_column TYPE REF TO cl_salv_wd_column,
  lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
  CREATE OBJECT lr_inputui1 EXPORTING value_elementname = 'MATNR'.
  lr_inputui1->set_label_text( ' Material Number :' ).
  input1 = lr_config->if_salv_wd_function_settings~create_function( id = 'LINPUT1' ).
  input1->set_editor( lr_inputui1 ).
  lr_column_settings ?= lr_config.
  lr_column = lr_column_settings->get_column( 'PROFL' ).
  CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'PROFL'.
  lr_column->set_cell_editor( lr_input_field ).
ENDMETHOD.

13. Create an Action for the “SEARCH” . On action of search fetches the entered material in the ALV List. 

 

method ONACTIONSEARCH .
DATA:
      node_input_material                 TYPE REF TO if_wd_context_node,
      elem_input_material                 TYPE REF TO if_wd_context_element,
      stru_input_material                 TYPE if_material_master=>element_input_material ,
      item_matnr                          LIKE stru_input_material-matnr.
*   navigate from <CONTEXT> to <INPUT_MATERIAL> via lead selection
    node_input_material = wd_context->get_child_node( name = if_material_master=>wdctx_input_material ).
*   get element via lead selection
    elem_input_material = node_input_material->get_element(  ).
*   get single attribute
    elem_input_material->get_attribute(
      EXPORTING
        name =  `MATNR`
      IMPORTING
        value = item_matnr ).
 DATA:
    node_mara                           TYPE REF TO if_wd_context_node,
    elem_mara                           TYPE REF TO if_wd_context_element,
    stru_mara                           TYPE if_material_master=>element_mara .
  DATA:BEGIN OF wa_mara,
       matnr TYPE mara-matnr,
       lvorm TYPE mara-lvorm,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
       bismt TYPE mara-bismt,
       meins TYPE mara-meins,
       bstme TYPE mara-bstme,
       brgew TYPE mara-brgew,
       ntgew TYPE mara-ntgew,
       gewei TYPE mara-gewei,
       volum TYPE mara-volum,
       spart TYPE mara-spart,
       profl TYPE mara-profl,
       END OF wa_mara.
  DATA:t_mara LIKE TABLE OF wa_mara.
*  navigate from <CONTEXT> to <MARA> via lead selection
  node_mara = wd_context->get_child_node( name = if_material_master=>wdctx_mara ).
  SELECT matnr
         lvorm
         mtart
         matkl
         bismt
         meins
         bstme
         brgew
         ntgew
         gewei
         volum
         spart
         profl FROM mara INTO TABLE t_mara
         WHERE matnr = item_matnr.
  node_mara->bind_table( t_mara ).
endmethod.

Click here to continue.. 

 
 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image