Download Webdynpro table data in Cell formatted Excel Sheet (WebDynpro for ABAP)

...Previous

11.  The table is binded to ‘Node_Sflight’.  

 

 

12.   Insert one new table column for popin from the table.

 

13.  In that column, Insert cell variant.

      

14.  Go to the properties of “Table_popin_toggle_cell” in table column and provide

 ‘TOGGLE_CELL’ in ‘Variant key’ property.  

 

15.  Go to the properties of Table Column and provide ‘TOGGLE_CELL’ in

‘Selected Cell Variant’ property as in figure.  

 

16.   Go to the properties of ‘Table’ and bind Selected Popin property with table_popin

attribute of node_Sflight.  

17.  Create a popin window by Insert Table popin.  

 

 

18.  In that popin, create a transparent container .  

 

19.  Create a table in the container to show the line data details of a

particular flight.  

   

20.  The table in the popin is binded to subnode ‘Node_Sbook’.  

 

21.  Create another button “Export To Excel” which is used to export data from

table to Excel Sheet.  

 

Under the On_action properties of this element create one event “Export_Excel”.  

 

22.  Go to methods tab. Then write logic for all the methods.

23.  In the method list, Go to Get_Flights and click the code wizard.  

 

24.  By the code wizard, read the main node and sub node.  

 

i)              Method  To_get_Flight_details.  

METHOD onactionto_get_flights .

* Declarations
  
DATA lo_nd_node_sflight TYPE REF TO if_wd_context_node.

  
DATA lo_el_node_sflight TYPE REF TO if_wd_context_element.
  
DATA ls_node_sflight    TYPE        wd_this->element_node_sflight.
  
DATA lt_sflight         TYPE        wd_this->elements_node_sflight.

*   navigate from <CONTEXT> to <NODE_SFLIGHT> via lead selection
  lo_nd_node_sflight = wd_context->get_child_node( name = wd_this->wdctx_node_sflight ).

*   To get static attributes table
  lo_nd_node_sflight->get_static_attributes_table(
IMPORTING
  
table = lt_sflight ).

*To fill internal table
  
SELECT * FROM sflight
 
INTO CORRESPONDING FIELDS OF TABLE lt_sflight.

*   get element via lead selection
  lo_el_node_sflight = lo_nd_node_sflight->get_element( ).

*   @TODO handle not set lead selection
  
IF lo_el_node_sflight IS INITIAL.
  
ENDIF.
*   To bind the internal table to main node
  lo_nd_node_sflight->bind_table( lt_sflight ).
**********---------------------------------------------******************

*   Declarations of sub node
  
DATA lo_nd_node_sbook TYPE REF TO if_wd_context_node.
  
DATA lo_el_node_sbook TYPE REF TO if_wd_context_element.
  
DATA ls_node_sbook    TYPE        wd_this->element_node_sbook.
  
DATA lt_sbook         TYPE        wd_this->elements_node_sbook .

* navigate from <CONTEXT> to <NODE_SBOOK> via lead selection
  lo_nd_node_sbook = wd_context->path_get_node( path = 
`NODE_SFLIGHT.NODE_SBOOK` ).

* @TODO handle not set lead selection
  
IF lo_el_node_sbook IS INITIAL.
  
ENDIF.

* To fill the popin internal table based on values in first internal table
  
SELECT * FROM sbook
     
INTO CORRESPONDING FIELDS OF TABLE  lt_sbook
    
FOR ALL ENTRIES IN lt_sflight
        
WHERE carrid = lt_sflight-carrid AND
                                  connid = lt_sflight-connid 
AND
                                  fldate = lt_sflight-fldate.

* To bind internal table to the node
  
IF lo_nd_node_sbook IS NOT INITIAL.
    lo_nd_node_sbook->bind_table( lt_sbook ).
  
ENDIF.

ENDMETHOD.  

ii)            Method_Linedata

        METHOD onactionlinedata .
* Declarations
  
DATA lo_nd_node_sflight TYPE REF TO if_wd_context_node.
  
DATA lo_el_node_sflight TYPE REF TO if_wd_context_element.
  
DATA ls_node_sflight    TYPE        wd_this->element_node_sflight.
  
DATA lt_sflight         TYPE        wd_this->elements_node_sflight.

*   navigate from <CONTEXT> to <SFLIGHT> via lead selection
  lo_nd_node_sflight = wd_context->get_child_node( name = wd_this->wdctx_node_sflight ).

*   get element via lead selection
  lo_el_node_sflight = lo_nd_node_sflight->get_element( ).

* Declarations
  
DATA lt_sbook         TYPE        wd_this->elements_node_sbook.
  
DATA lo_nd_node_sbook TYPE REF TO if_wd_context_node.
  
DATA lo_el_node_sbook TYPE REF TO if_wd_context_element.
  
DATA ls_sbook         TYPE        wd_this->element_node_sbook.

* navigate from <CONTEXT> to <SBOOK> via lead selection
  lo_nd_node_sbook = wd_context->path_get_node (path = 
`NODE_SFLIGHT.NODE_SBOOK` ).

* @TODO handle non existant child
  
IF lo_nd_node_sbook IS NOT INITIAL.
    lo_el_node_sbook = lo_nd_node_sbook->get_element( ).
  
ENDIF.

* Filling the linedata internal table
  
SELECT * FROM sbook
    
INTO CORRESPONDING FIELDS OF TABLE lt_sbook
    
FOR ALL ENTRIES IN lt_sflight
    
WHERE carrid = lt_sflight-carrid AND
           connid = lt_sflight-connid 
AND
           fldate = lt_sflight-fldate.

* To bind internal table to line data node
  
IF lo_nd_node_sbook IS NOT INITIAL.
    lo_nd_node_sbook->bind_table( lt_sbook ).
  
ENDIF.
ENDMETHOD.  

25.  In Export_To _Excel method ,write logic to export data with fomats such as borders, Colours, etc.

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