‎2007 Dec 13 1:46 PM
hi experts,
I have a deep structure......hw to write select statement for tht..
regards,
sandeep.
‎2007 Dec 13 1:54 PM
If it's a structure you cannot perform a SELECT statement...
What's the name of this deep struc?
‎2007 Dec 13 3:31 PM
Hi,
In a Deep structures you can have data, tables, structures, objects and etc. We can create a Deep internal table based on deep structure.
Also is possible create Deep transparent table. And you can use the SELECT with a deep table.
There is no difference with Deep transparent table and Deep Internal table.
Look at follow example, i hope it solve your doubts !
REPORT zmar.
CLASS main DEFINITION.
PUBLIC SECTION.
DATA t_sflight TYPE TABLE OF sflight.
DATA e_sflight TYPE sflight.
ENDCLASS. "main DEFINITION
" Structure
DATA: BEGIN OF e_data,
field1 TYPE char01,
field2 TYPE char01,
field3 TYPE char01,
END OF e_data.
* Table without header line
DATA: t_table LIKE STANDARD TABLE OF e_data.
* Deep Structure
DATA: BEGIN OF e_deep_struc,
struc TYPE spfli, "structure of table SPFLI
table LIKE t_table, "Internal table like t_data
o_main TYPE REF TO main, "Object Reference of class main
END OF e_deep_struc.
"Internal table with structure of e_table
DATA t_deep_table LIKE STANDARD TABLE OF e_deep_struc.
" Your Deep table will like this
* STRUC
* SPFLI-MANDT
* SPFLI-CARRID
* SPFLI-CONNID
* SPFLI-COUNTRYFR
* SPFLI-CITYFROM
* SPFLI-AIRPFROM
* SPFLI-COUNTRYTO
* SPFLI-CITYTO
* SPFLI-AIRPTO
* SPFLI-FLTIME
* SPFLI-DEPTIME
* SPFLI-ARRTIME
* SPFLI-DISTANCE
* SPFLI-DISTID
* SPFLI-FLTYPE
* SPFLI-PERIOD
*TABLE
* Table[initial]
*O_MAIN
* {O:5*PROGRAM=<PROGRAM>CLASS=MAIN}
START-OF-SELECTION.
" Select only one line into a structure struc of e_deep_struc
SELECT *
FROM spfli
INTO e_deep_struc-struc
UP TO 1 ROWS.
ENDSELECT.
IF sy-subrc IS INITIAL.
" Populate e_data
DO 3 TIMES.
MOVE: 'A' TO e_data-field1,
'B' TO e_data-field2,
'C' TO e_data-field3.
" Populate table of e_deep_struc with values of e_data
APPEND e_data TO e_deep_struc-table.
" Create an object o_main of structure e_deep_struc
CREATE OBJECT e_deep_struc-o_main.
ENDDO.
" Insert line into table T_SFLIGHT of object O_MAIN
SELECT *
FROM sflight
INTO TABLE e_deep_struc-o_main->t_sflight
UP TO 3 ROWS.
" Populate the internal table t_deep_table with values of structure e_deep_struc
APPEND e_deep_struc TO t_deep_table.
CLEAR e_deep_struc.
ENDIF.
IF NOT t_deep_table IS INITIAL.
WRITE 'Content of T_DEEP_TABLE-STRUC'.
" Read all field of internal table t_deep_table into structure e_deep_struc
LOOP AT t_deep_table INTO e_deep_struc.
WRITE: / e_deep_struc-struc-carrid,
e_deep_struc-struc-connid,
e_deep_struc-struc-countryfr.
WRITE / 'Content of T_DEEP_TABLE-TABLE'.
" Do It
* MOVE e_deep_struc-table TO t_table.
* LOOP AT t_table INTO e_data ......
* WRITE: e_data-field1,
* e_data-field2,
* e_data-field3.
* ENDLOOP.
* Or Just do it
LOOP AT e_deep_struc-table INTO e_data.
WRITE: / e_data-field1,
e_data-field2,
e_data-field3.
ENDLOOP.
WRITE / 'Content of T_DEEP_TABLE-O_MAIN->T_SFLIGHT'.
" Read the internal table t_sflight of object o_main from structure e_deep_struc
LOOP AT e_deep_struc-o_main->t_sflight INTO e_deep_struc-o_main->e_sflight.
WRITE: / e_deep_struc-o_main->e_sflight-carrid,
e_deep_struc-o_main->e_sflight-connid,
e_deep_struc-o_main->e_sflight-fldate.
ENDLOOP.
CLEAR e_deep_struc.
ENDLOOP.
ENDIF.
Kind Regards.
Marcelo Ramos