2007 Jul 12 2:19 PM
Hello,
i would like to create an internal range table about a table, which Name is in a Field.
I had create a Table with following Fields:
FALL CHAR10
LFDNR INT2
ZUORD CHAR5
FNAME M_COMB_FNAME
SIGN SIGN
OPTIO OPTION
HIGH HIGH_RANGE
LOW LOW_RANGE
At first i would like to create an internal range table, about a table which name is standing in the Field FNAME. And if there is a new Tablename in the Field FNAME, than i would like to create a new internal range table.
My suggestions are:
At First to create a Fieldsymbol:
assign (FNAME) to ).
And now, to create the new range table.
But How?
there are "create data", but it´s not working.
And then to fill the range table...
Is there anybody, who could help me.
Thanks.
2007 Jul 13 6:59 AM
Hi see the below code .... all Your 4 steps
<b>1.At First to create a Fieldsymbol:
2.then, to identify the typ
3.to create the new range table.
4.to fill the range table...</b>
TYPE-POOLS: abap.
DATA: ls_component TYPE abap_componentdescr, "Zeile der Strukturbeschreibung
lt_component TYPE abap_component_tab, "Tabelle der Strukturbeschreibung
lr_strucdescr TYPE REF TO cl_abap_structdescr, "Referenz auf Datentyp der Struktur
lr_tabledescr TYPE REF TO cl_abap_tabledescr, "Referenz auf Datentyp der Tabelle
lr_data_struct TYPE REF TO data, "Referenz auf die erzeugte Struktur
lr_data_table TYPE REF TO data, "Referenz auf die erzeugte Tabelle
l_count TYPE i. "Anzahl Komponenten
FIELD-SYMBOLS: <fs_comp> TYPE ANY, "Um auf eine Komponente zu zugreifen
<fs_struct> TYPE ANY, "Um auf die Struktur zu zugreifen
<fs_table> TYPE ANY TABLE. "Um auf die Tabelle zu zugreifen
* (1) identify components required in your dynamic table
CLEAR ls_component.
ls_component-name = 'CARRID'.
ls_component-type ?= cl_abap_typedescr=>describe_by_name( 'SFLIGHT-CARRID' ).
INSERT ls_component INTO TABLE lt_component.
CLEAR ls_component.
ls_component-name = 'CONNID'.
ls_component-type ?= cl_abap_typedescr=>describe_by_name( 'SFLIGHT-CONNID' ).
INSERT ls_component INTO TABLE lt_component.
CLEAR ls_component.
ls_component-name = 'FLDATE'.
ls_component-type ?= cl_abap_typedescr=>describe_by_name( 'SFLIGHT-FLDATE' ).
INSERT ls_component INTO TABLE lt_component.
* (2) create structure description in accordance to componentdata:
IF lt_component IS NOT INITIAL.
lr_strucdescr = cl_abap_structdescr=>create( lt_component ).
ENDIF.
* (3) create table description for structure descriptiondata:
lr_tabledescr = cl_abap_tabledescr=>create( p_line_type = lr_strucdescr ).
* (4) create structure and assign
CREATE DATA lr_data_struct TYPE HANDLE lr_strucdescr.
ASSIGN lr_data_struct->* TO <fs_struct>.
* (5) create table and assign
CREATE DATA lr_data_table TYPE HANDLE lr_tabledescr.
ASSIGN lr_data_table->* TO <fs_table> .
* (6) fill table (from database)
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE <fs_table>.
* (7) output
l_count = LINES( lt_component ).
LOOP AT <fs_table> INTO <fs_struct>.
DO l_count TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_struct> TO <fs_comp>.
IF sy-index = 1.
WRITE: / <fs_comp>.
ELSE.
WRITE: <fs_comp>.
ENDIF.
ENDDO.
ENDLOOP. "<fs_table> INTO <fs_struct>
reward points if it is usefull...
Girish
2007 Jul 13 3:04 PM
Thanks four your big help.
Your Answer was very helpfull.
But it´s possible to create a real rangetable (like DATA: variable TYPE RANGE OF TABLE) with this structure (lr_strucdescr or lr_tabledescr) and the structure from any table.
2007 Jul 13 3:39 PM
yes we can ..
<b>RANGES tables</b>
You can use the following variants of the TYPES and DATA statements to create internal tables of the same type as selection tables.
TYPES|DATA <rangetab> TYPE RANGE OF <type>.
or
TYPES|DATA <rangetab> LIKE RANGE OF <obj>.
<b>
This defines internal standard tables whose line type is a structure as follows:</b>
SIGN(1) TYPE C
OPTION(2) TYPE C
LOW TYPE <type> bzw. LIKE <obj>
HIGH TYPE <type> bzw. LIKE <obj>
<b>This statement is simply a shortened form of the following statements:</b>
DATA: BEGIN OF <rangetab> OCCURS 0,
sign(1) TYPE c,
option(2) TYPE c,
low LIKE <f>,
high LIKE <f>,
END OF <rangetab>.
<b>please seee this link @ page no.8</b>
<a href="http://">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e701051a-0e01-0010-2096-81524fe2f32b</a>
reward points if it is usefull .....
Girish
2007 Jul 17 9:22 AM
it´s not possible.
TYPES|DATA have to be a real Table and the Tablename standing in a variable in my case.
And i only know the structure like lr_strucdescr or lr_tabledescr.