0% found this document useful (0 votes)
44 views3 pages

Structure Table: 'Select'

This document outlines a method for dynamically creating an ABAP table structure and populating it from column data retrieved from a POD header. It retrieves column details from the POD header, builds the table structure and column definitions, creates an in-memory table, populates it with rows of data, and binds it to an ABAP context node to display the dynamic table.

Uploaded by

Robert Walls
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

Structure Table: 'Select'

This document outlines a method for dynamically creating an ABAP table structure and populating it from column data retrieved from a POD header. It retrieves column details from the POD header, builds the table structure and column definitions, creates an in-memory table, populates it with rows of data, and binds it to an ABAP context node to display the dynamic table.

Uploaded by

Robert Walls
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

METHOD wddoinit .

*Structure table
DATA :
comp_tab TYPE cl_abap_structdescr=>component_table,
comp LIKE LINE OF comp_tab,
stru_type TYPE REF TO cl_abap_structdescr,
table_type TYPE REF TO cl_abap_tabledescr,
node_info TYPE REF TO if_wd_context_node_info,
node TYPE REF TO if_wd_context_node,
lo_nd_pod_header TYPE REF TO if_wd_context_node,
lt_pod_header TYPE wd_this->elements_pod_header,
ls_pod_header TYPE wd_this->element_pod_header,
my_table TYPE REF TO data,
my_row TYPE REF TO data,
lt_data TYPE TABLE OF dfies,
lt_final TYPE TABLE OF dfies,
ls_final TYPE dfies,
lv_fdata TYPE ddobjname,
lv_query TYPE string.
FIELD-SYMBOLS : <table> TYPE table,
<row> TYPE data,
<fs> TYPE any.
*---> POD header details
lo_nd_pod_header = wd_context->get_child_node( name = wd_this>wdctx_pod_header ).
CALL METHOD lo_nd_pod_header->get_static_attributes_table
IMPORTING
table = lt_pod_header.
READ TABLE lt_pod_header INTO ls_pod_header INDEX 1.
*---> find columns against POD header groups
lv_query = 'SELECT'.
LOOP AT lt_pod_header INTO ls_pod_header.
lv_fdata = ls_pod_header-zfield_tab.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname
= lv_fdata
TABLES
dfies_tab
= lt_data
EXCEPTIONS
not_found
= 1
internal_error = 2
OTHERS
= 3.
IF sy-subrc EQ 0.
LOOP AT lt_data INTO ls_final.
CONCATENATE lv_query 'a~' ls_final-fieldname INTO lv_query.
ENDLOOP.
APPEND LINES OF lt_data TO lt_final.

ENDIF.
ENDLOOP.
SELECT c~carrname p~connid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON p~carrid
=
AND p~cityfrom =
AND p~cityto
=
INNER JOIN sflight AS f ON f~carrid =
AND f~connid =

c~carrid
p_cityfr
p_cityto )
p~carrid
p~connid ).

*---> Prepare dynamic table structure


LOOP AT lt_final INTO ls_final.
IF ls_final-fieldname NE 'MANDT'.
comp-name = ls_final-fieldname.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'CHAR8' ).
APPEND comp TO comp_tab.
ENDIF.
ENDLOOP.
stru_type = cl_abap_structdescr=>create( comp_tab ).
*---> Node information
CALL METHOD wd_context->get_node_info
RECEIVING
node_info = node_info.
*---> Create lower level node
CALL METHOD node_info->add_new_child_node
EXPORTING
name
= 'POD_DATA'
static_element_rtti = stru_type
is_static
= abap_false
RECEIVING
child_node_info
= node_info.
CALL METHOD wd_context->get_child_node
EXPORTING
name
= 'POD_DATA'
RECEIVING
child_node = node.
CALL METHOD node_info->get_static_attributes_type
RECEIVING
rtti = stru_type.
*---> Create table type
table_type = cl_abap_tabledescr=>create( p_line_type = stru_type ).
CREATE DATA my_table TYPE HANDLE table_type.
ASSIGN my_table->* TO <table>.
*---> Create lines
CREATE DATA my_row TYPE HANDLE stru_type.
ASSIGN my_row->* TO <row>.

*Loop at lt_tab into ls_tab.


*Loop at comp_tab into comp.
*Assign component comp-name of structure <row> to <fs>
*Endloop.
*Append <row> to <table>.
*Endloop.
node->bind_table( <table> ).
*
ENDMETHOD.

You might also like