Save Select Options and ALV Selection records in ABAP Web Dynpro Application

...Previous  

·         The variant fetched from table INDX is displayed in a variant table that contains the variant name, variant description, user name and variant creation date.

·         Select the variant from the variant table and click on “Proceed” button.

METHOD onactionproceed.

* Local Data Declarations
  DATA lo_nd_variant_table TYPE REF TO if_wd_context_node.
  DATA ls_variant_table    TYPE wd_this->element_variant_table.

* navigate from <CONTEXT> to <VARIANT_TABLE> via lead selection
  lo_nd_variant_table = wd_context->get_child_node( name = wd_this->wdctx_variant_table ).

* get all declared attributes
  lo_nd_variant_table->get_static_attributes(
    IMPORTING
      static_attributes = ls_variant_table ).

  CHECK ls_variant_table IS NOT INITIAL.

  DATA: my_component       TYPE REF TO if_wd_component,
        my_component_info  TYPE REF TO if_wd_rr_component,
        my_component_name  TYPE string,
        l_prog             TYPE indx-srtfd,
        l_id               TYPE indx-srtfd,
        l_pgmid            TYPE indx-pgmid,
        l_len              TYPE i.

  DATA lo_nd_header TYPE REF TO if_wd_context_node.
  DATA ls_header    TYPE wd_this->element_header.

* navigate from <CONTEXT> to <HEADER> via lead selection
  lo_nd_header = wd_context->get_child_node( name = wd_this->wdctx_header ).

  DATA lo_nd_item_details TYPE REF TO if_wd_context_node.
  DATA ls_item_details    TYPE wd_this->element_item_details.
  DATA li_item_details    TYPE wd_this->elements_item_details.

*   navigate from <CONTEXT> to <ITEM_DETAILS> via lead selection
  lo_nd_item_details = wd_context->get_child_node( name = wd_this->wdctx_item_details ).

*----Get component name
  my_component = wd_comp_controller->wd_get_api( ).
  my_component_info = my_component->get_component_info( ).
  my_component_name = my_component_info->get_name( ).

*----Read all the variants for this component
  l_len = STRLEN( my_component_name ).
  IF l_len GT 20.
    l_prog = my_component_name+0(20).
  ELSE.
    l_prog = my_component_name.
  ENDIF.

  CONCATENATE  : l_prog '%' INTO l_prog,
                 ls_variant_table-variant_name '%' INTO l_pgmid.

  SELECT  srtfd
    INTO l_id
    UP TO 1 ROWS
    FROM indx
    WHERE relid EQ 'YW'
      AND srtfd LIKE l_prog
      AND pgmid LIKE l_pgmid.
    EXIT.
  ENDSELECT.

  
IF sy-subrc EQ 0.
* navigate from <CONTEXT> to <PO_HEADER> via lead selection
    lo_nd_header = wd_context->get_child_node( name = wd_this->wdctx_header ).
    
IMPORT ls_header = ls_header
           li_item_details  = li_item_details FROM DATABASE indx(yw) ID l_id.

    IF sy-subrc EQ 0.

      CALL METHOD lo_nd_header->set_static_attributes
        EXPORTING
          static_attributes = ls_header.
    ENDIF.
  ENDIF.

  CALL METHOD lo_nd_item_details->bind_table
    EXPORTING
      new_items = li_item_details.

  wd_this->fire_to_main_plg( ).

ENDMETHOD.
 

·         Navigate to the “Main” view from “Variant_Table” view.

METHOD handlefrom_variant_table .

* Initialize selection screen
  wddoinit( ).

* Constants Declarations
  CONSTANTS: c_x    TYPE c VALUE 'X'.
  CONSTANTS: c_text TYPE string VALUE 'Select'.

  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context    TYPE wd_this->element_context.
  DATA lv_visible    LIKE ls_context-visible.

*   get element via lead selection
  lo_el_context = wd_context->get_element(  ).

*   get single attribute
  lo_el_context->set_attribute(
    EXPORTING
      value =  c_x
      name  = 'VISIBLE' ).

  DATA lr_nd_mcc_follow_up    TYPE REF TO if_wd_context_node.
  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  DATA lo_value               TYPE REF TO cl_salv_wd_config_table.
  DATA lo_cmp_usage           TYPE REF TO if_wd_component_usage.
  DATA: lr_column_settings    TYPE REF TO if_salv_wd_column_settings,
        lr_table_settings     TYPE REF TO if_salv_wd_table_settings,
        lr_input_field        TYPE REF TO cl_salv_wd_uie_input_field,
        lr_column             TYPE REF TO cl_salv_wd_column,
        lr_col_header         TYPE REF TO cl_salv_wd_column_header,
        lr_checkbox           TYPE REF TO cl_salv_wd_uie_checkbox.

  lo_cmp_usage =   wd_this->wd_cpuse_material_data_alv( ).

  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

* Navigate from <CONTEXT> to <ALV_CHGDLR> via lead selection
  lr_nd_mcc_follow_up = wd_context->get_child_node( name = wd_this->wdctx_item_details ).

  lo_interfacecontroller =   wd_this->wd_cpifc_material_data_alv( ).
  lo_interfacecontroller->set_data( r_node_data = lr_nd_mcc_follow_up ).

  lo_value = lo_interfacecontroller->get_model ( ).

  lr_table_settings ?= lo_value.
  lr_table_settings->set_visible_row_count (‘20’).

*sets column as a checkbox
  lr_column_settings ?= lo_value.
* Set required text
  lr_column = lr_column_settings->get_column( 'SELECT' ).

  CREATE OBJECT lr_checkbox
    EXPORTING
      checked_fieldname = 'SELECT'.

  lr_checkbox->set_enabled( abap_true ).
  lr_column->set_cell_editor( lr_checkbox ).

  lr_column = lr_column_settings->get_column( 
'SELECT' ).
  lr_col_header = lr_column->get_header( ).
  lr_col_header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none ).
  
lr_col_header->set_text( EXPORTING value = c_text ).

* initially when output is displayed, cursor is on first row.
* By below statement index is set to 0
  CALL METHOD lr_nd_mcc_follow_up->set_lead_selection_index
    EXPORTING
      index = '0'.

  lo_value->if_salv_wd_table_settings~set_read_only( abap_false ).

ENDMETHOD.

·         Populate the Plant range table and the ALV list with the material data along with selected entries.  

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