cancel
Showing results for 
Search instead for 
Did you mean: 

Field symbols in Assistant Class ?

murali_ram
Participant
0 Kudos

Hello Guru's,

I need a clarification and detailed explanation ( Code ) for my query.

Is it possible to refer field symbols in the assistant class method. i just gone through one example  WDA program of select-options.

SAPTechnical.COM - Using Select-Options in Web Dynpro for ABAP

In that they mentioned field symbols . But simply they written the code in view. As far as my understanding sql queries should not write inside view.

So iam practising to write each and every sql queries ( select queries ) inside assistant class.  Could you please explain me how to write or refer field symbols inside assistant class method.


DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
  DATA: RT_CARRID TYPE REF TO DATA.
  DATA: ISFLIGHT TYPE TABLE OF SFLIGHT.
  DATA: WSFLIGHT TYPE SFLIGHT.
  FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE.

* Retrieve the data from the select option
  RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_CARR_ID' ).
* Assign it to a field symbol
  ASSIGN RT_CARRID->* TO <FS_CARRID>.
  CLEAR ISFLIGHT. REFRESH ISFLIGHT.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE ISFLIGHT FROM SFLIGHT
  WHERE CARRID IN <FS_CARRID>.
  NODE_FLIGHTS = WD_CONTEXT->GET_CHILD_NODE( NAME = `FLIGHTS` ).
  NODE_FLIGHTS->BIND_ELEMENTS( ISFLIGHT ).
ENDMETHO


In other words.simply i dont want select query in middle of that code.. i need to metion that in assistant class method. and should need to call the assistant method here. please help.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Murali Ram,

For your example, you just need to create a method in assistance class and call it inside Webdynpro view.

Create method GET_FLIGHT_DATA( ) in assistance class


Parameters:   it_carrid TYPE ref to DATA ( Importing Parameter )

                      rt_result TYPE FLIGHTTAB ( Returning Parameter )

   

     logic:

          field-symbols: <ft_carrid> type table.

             assign it_carrid->* to <ft_carrid>.

             if <ft_carrid> is not assigned. " check if carried is assigned

               return.

             endif.

        

SELECT * INTO TABLE rt_result FROM SFLIGHT
  WHERE CARRID IN <FT_CARRID>.

Now call the assistance class method inside WD as below

  


DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
  DATA: RT_CARRID TYPE REF TO DATA.
  DATA: ISFLIGHT TYPE TABLE OF SFLIGHT.
  DATA: WSFLIGHT TYPE SFLIGHT.


* Retrieve the data from the select option

  RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_CARR_ID' ).

 


     CLEAR ISFLIGHT.


  ISFLIGHT = WD_ASSIST->GET_FLIGHT_DATA(

          EXPORTING IT_CARRID = RT_CARRID ).


  NODE_FLIGHTS = WD_CONTEXT->GET_CHILD_NODE( NAME = `FLIGHTS` ).
  NODE_FLIGHTS->BIND_ELEMENTS( ISFLIGHT ).

Here, we are passing select options as data reference and retrieving the result back.

Hope this helps you.

Regards,

Rama

murali_ram
Participant
0 Kudos

Thank u ramakrishna

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

You could create a method in assistance class(say get_flightdata) with importing parameter of type ANY TABLE and then pass the field symbol reference to it and then use it in your method.

Regards,

Kiran

murali_ram
Participant
0 Kudos

Thanks kiran