cancel
Showing results for 
Search instead for 
Did you mean: 

On lead selection for node inside node showing empty table

Former Member
0 Kudos
78

Hi all,

     I am a novice .Please solve my problem . i have created a node inside a node in view context

         context

            L EKKO (Cardinality : 0..n , selection 0..1)

             .           L EKPO (Cardinality : 0..n , selection 0..1 )

             .                @   EBELN

             .                @   EBELP

             .               @   MATNR

             .@EBELN

              @BUKRS

              @LIFNR

            @--indicates attributes

        In WDDOINIT i have written the following code :

*************************************************************************************************************************************************

""""""""""CODE FOR EKKO
    DATA LO_ND_EKKO TYPE REF TO IF_WD_CONTEXT_NODE.

    DATA LS_EKKO TYPE WD_THIS->ELEMENT_EKKO.
    DATA LT_EKKO TYPE WD_THIS->ELEMENTS_EKKO.

*  navigate from <CONTEXT> to <EKKO> via lead selection
     LO_ND_EKKO = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_EKKO ).

     SELECT EBELN BUKRS AEDAT lifnr FROM EKKO
     INTO CORRESPONDING FIELDS OF TABLE LT_EKKO UP TO 100 ROWS
     WHERE EBELN LIKE '45000174%'.

     SORT LT_EKKO BY EBELN.

     LO_ND_EKKO->BIND_TABLE( NEW_ITEMS = LT_EKKO SET_INITIAL_ELEMENTS = ABAP_FALSE ).

"""""""""""CODE FOR EKPO
      DATA LO_ND_EKPO TYPE REF TO IF_WD_CONTEXT_NODE.

      DATA LS_EKPO TYPE WD_THIS->ELEMENT_EKPO.
      DATA LT_EKPO TYPE WD_THIS->ELEMENTS_EKPO.
      DATA LT_EKPOI TYPE IF_VIE1=>ELEMENTS_EKPO.

*    navigate from <CONTEXT> to <EKPO> via lead selection
      LO_ND_EKPO = WD_CONTEXT->PATH_GET_NODE( PATH = `EKKO.EKPO` ).

      SELECT EBELN EBELP AEDAT MATNR BUKRS MENGE MEINS NETPR
      INTO TABLE LT_EKPO FROM EKPO FOR ALL ENTRIES IN LT_EKKO
      WHERE EBELN = LT_EKKO-EBELN.

      SORT LT_EKPO BY EBELN EBELP.

      LO_ND_EKPO->BIND_TABLE( NEW_ITEMS = LT_EKPO SET_INITIAL_ELEMENTS = ABAP_FALSE ).

******************************************************************************************************************************************

In ONLEADSELECTION EVENT

******************************************************************************************************************************************

DATA LO_ND_EKKO TYPE REF TO IF_WD_CONTEXT_NODE.
   DATA LO_EL_EKKO TYPE REF TO IF_WD_CONTEXT_ELEMENT.
   DATA LS_EKKO TYPE WD_THIS->ELEMENT_EKKO.

* navigate from <CONTEXT> to <EKKO> via lead selection
   LO_ND_EKKO = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_EKKO ).

* get element via lead selection
   LO_EL_EKKO = LO_ND_EKKO->GET_ELEMENT( ).

* get all declared attributes
    LO_EL_EKKO->GET_STATIC_ATTRIBUTES(
     IMPORTING
       STATIC_ATTRIBUTES = LS_EKKO ).
"""""""""FOR EKPO
       DATA LO_ND_EKPO TYPE REF TO IF_WD_CONTEXT_NODE.

       DATA LT_EKPOL TYPE WD_THIS->ELEMENTS_EKPO.

       DATA LT_EKPO TYPE WD_THIS->ELEMENTS_EKPO.

       DATA LS_EKPO TYPE WD_THIS->ELEMENT_EKPO.

*   navigate from <CONTEXT> to <EKPO> via lead selection
       LO_ND_EKPO = WD_CONTEXT->PATH_GET_NODE( PATH = `EKKO.EKPO` ).

       LO_ND_EKPO->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_EKPO ).

LOOP AT LT_EKPO INTO LS_EKPO WHERE EBELN = LS_EKKO-EBELN.

APPEND LS_EKPO TO LT_EKPOL.

  ENDLOOP.

* navigate from <CONTEXT> to <EKPO> via lead selection
   LO_ND_EKPO = WD_CONTEXT->PATH_GET_NODE( PATH = `EKKO.EKPO` ).

   LO_ND_EKPO->BIND_TABLE( NEW_ITEMS = LT_EKPOL SET_INITIAL_ELEMENTS = ABAP_FALSE ).

CLEAR LT_EKPO.

*************************************************************************************************************************************

in the output i wanted to display two tables EKKO and EKPO .If i select one record in ekko i should get its corresponding items data in ekpo.

But when the output is displayed its showing both ekko data and all the records in ekpo irrespective of the lead selection.when

selecting any other row in ekko using the lead selection it is showing empty ekpo table.

condition : i wanted to fetch the data from database using select only in wddoinit of view (not involving component controller context )

and use that data to populate ekpo table in lead selection and also the context nodes should be  node inside node.

Debugging: i found that in the leadselection action get static attributes is not fetching any data (i.e.,  LT_EKPO is empty ).

For more details see the attached screen shots

Please help.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member129652
Active Participant
0 Kudos

Dear Raghavendra,

  Let's assume that you did not use 'SINGLETON' in the context.  Without singleton, we can focus on the elements and temporary forget about the nodes.

  Please imagine that the context in the following way:  The context root contains lots of EKKO elements.  Each EKKO element also contains lots of EKPO elements.

  In your WDDOINIT, you just put all EKPO elements under the first EKKO element.

  This is the reason why you find nothing in the 'ONLEADSELECTION' event.   In other words, there is no EKPO element under the other EKKO elements.

  The best solution is to create a 'Supply Function' for the node EKPO.  In the context, open the node EKPO, you will find a property called 'Supply Function'.  Please enter a method name and implement the method.  This is a good and quick fix.

  If you really want to perform all SELECT statements in WDDOINIT, you have to put EKPO elements under correct EKKO elements.  Then, in the 'ONLEADSELECTION' event, you only need to change the lead selection of EKPO. 

  Another approach is to keep all EKPO records in your assist class.  In the 'ONLEADSELECTION' event, find proper EKPO records and bind them.

Former Member
0 Kudos

Hi Lee,

" If you really want to perform all SELECT statements in WDDOINIT, you have to put EKPO elements under correct EKKO elements.  Then, in the 'ONLEADSELECTION' event, you only need to change the lead selection of EKPO.   "

        Please elaborate on this (i.e., How to put ekpo elements under correct ekko elements ).Please explain.

former_member129652
Active Participant
0 Kudos

Dear Raghavendra,

  Sorry, Raghavendra.  After a test, it is not doable.  Please ignore it.

chengalarayulu
Active Contributor
0 Kudos

Raghav,

in first time execution you will be getting the output i guess,,,,

second time onwards it is not happening right?

Former Member
0 Kudos

YES thats right , on execution i can see the output in ekko and ekpo tables (but ekpo contents are not coming according to lead selection in ekko ). after selecting other lead in ekko table then ekpo is showing empty. (i have attached the screen shots also output1 is immediate output after execution ,

output2 is output after selecting other record in ekko ) .

chengalarayulu
Active Contributor
0 Kudos

well,

as per my understanding EKPO is child node for EKKO, if yes,

then enable singleton for EKPO and create a SUPPLY_FUNCTION,

then write the code which you have written in WDDOINIT for EKPO,

automatically selected record related data will be populated on EKPO.

if not, you can revert.

Former Member
0 Kudos

Hi Chengalarayulu ,

          Yes ekpo is child node for ekko.

      Are you suggesting to write the select query in supply function ? .

               I am asked to avoid writing select query in supply function because every time the lead selection changes the select query gets executed and that effects the performance of the application.

              Can you suggest any thing like fetching the data in wddoinit (touching database in wddoinit at a time )  and Looping the ekpo table to get records based on selected records in ekko in leadselection action or supply function. but my problem is i'm not able to access the ekpo records after changing the lead selection.Please suggest.

                   Thanks in advance.

chengalarayulu
Active Contributor
0 Kudos

Just fetch all the required data from EKPO initially(it may be at WDDOINT of comp_controller / view controller), and store it globally, means at Component controller level/assistance class level, in SUPPLY_FUNCTION level, just copy the source and delete the unwanted records from copy, and then bind this to node.