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

Create a COMPONENTCONTROLLER -> in the CONTEXT Tab create an Node like MARA_NODE ( to get Material related Data from MARA Table)

while creating node-> ADD Attributes from the Structure-> Select the Required Fields

Create A view MAIN

in CONTEXT Node  of View MAIN drag MARA_NODE from Component to VIEW

in the LAYOUT create a Table and Bind it with MARA_NODE and create a Button with ACTION SEARCH   to  Navigate to Next Page

 create an INBOUND PLUG say MAIN_IN & OUTBOUND_PLUG say  MAIN_OUT

in METHOD Tab  of the View dbl click on the ACTIONr   ONACTIONSEARCH and give the code

METHOD onactionsearch .

*& Data declaration



  DATA lo_nd_mara_node TYPE REF TO if_wd_context_node.

  DATA lo_el_mara_node TYPE REF TO if_wd_context_element.

  DATA ls_mara_node    TYPE wd_this->element_mara_node.

  DATA lv_matnr        LIKE ls_mara_node-matnr.



*   navigate from <CONTEXT> to <MARA_NODE> via lead selection

  lo_nd_mara_node = wd_context->get_child_node( name = wd_this->wdctx_mara_node ).



*   @TODO handle not set lead selection

  IF lo_nd_mara_node IS INITIAL.

    wd_this->fire_main_out_plg(

    ).



  ENDIF.                           " IF lo_nd_mara_node IS INITIAL



*  get element via lead selection

  lo_el_mara_node = lo_nd_mara_node->get_element(  ).



*  @TODO handle not set lead selection

  IF lo_el_mara_node IS INITIAL.

  ENDIF.



*   get single attribute

  lo_el_mara_node->get_attribute(

    EXPORTING

      name =  `MATNR`

    IMPORTING

      value = lv_matnr ).



  CALL METHOD lo_nd_mara_node->set_attribute

    EXPORTING

*    index  = USE_LEAD_SELECTION

      value  = lv_matnr

      name   = 'MATNR'.

  wd_this->fire_main_out_plg(

  ).



ENDMETHOD. 

 in Method WDDOINIT give  the code

 
METHOD wddoinit .

*& Work variable declaraton

  DATA:

    t_mara TYPE STANDARD TABLE OF mara,

    mara_node TYPE REF TO if_wd_context_node.



*& Fetch material details form table <MARA>

  SELECT *

    FROM mara

    up to 10 rows

    INTO TABLE t_mara.



  IF sy-subrc NE 0.

    MESSAGE 'No Reocrds Found ' TYPE 'E'.

  ENDIF.                               " if sy-subrc ne 0



*& Move <context> to <MARA>

  mara_node = wd_context->get_child_node( 'MARA_NODE' ).



*& Bind the internal table with the view

  mara_node->bind_table( t_mara ).



ENDMETHOD.

 Create another View SECOND

provide INBOUND & OUTBOUND PLUGS SEC_IN AND SEC_OUT respectively.

 in LAYOUT create a Table and Button with ACTION BACK

in Context Node map the nodes from COMPONENT to VIEW

 in METHOD SEC_IN  give the code below

METHOD handlesec_in .

*& Data declaration

  DATA:

   mard_node    TYPE REF TO if_wd_context_node,

   t_mard       TYPE STANDARD TABLE OF mard,

   mara_node    TYPE REF TO if_wd_context_node,

   ls_mara_node TYPE wd_this->element_mara_node,

   lv_matnr     LIKE ls_mara_node-matnr.



*& Link <context> to <MARD>

  mard_node = wd_context->get_child_node( 'MARD_NODE' ).



* Navigate from <CONTEXT> to <MARA_NODE> via lead selection

  mara_node = wd_context->get_child_node( name = wd_this->wdctx_mara_node ).



  mara_node->get_attribute(

      EXPORTING

        name =  `MATNR`

      IMPORTING

        value = lv_matnr ).

*

*& Fetch data from MARD table

  SELECT * FROM mard INTO TABLE t_mard

           WHERE matnr EQ lv_matnr.



*& Bind the internal table with view

  mard_node->bind_table( t_mard ).



ENDMETHOD. 




  • No labels