Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Field Symbol Header Line

Former Member
0 Kudos

Hello,

In my program, I want to extract the structure of a field symbol into two different dynamic internal tables. In the 1st internal table I want to get header lines of the fs and in the 2nd int. table, I need the body of fs. I solved how to do the 2nd part, but I still couldn't manage to copy header lines as I mentioned.

Thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Please check this will give you the solution,

If you want the coloumn name of field symbol,

TABLES: Mara.

FIELD-SYMBOLS : <i_itab> TYPE ANY TABLE.

DATA: lt_tabledescr_ref TYPE REF TO cl_abap_tabledescr,

lt_descr_ref TYPE REF TO cl_abap_structdescr,

wa_table TYPE abap_compdescr.

DATA: it_tab TYPE TABLE OF mara.

ASSIGN it_tab TO <i_itab>.

lt_tabledescr_ref ?= cl_abap_typedescr=>describe_by_data( <i_itab> ).

lt_descr_ref ?= lt_tabledescr_ref->get_table_line_type( ).

LOOP AT lt_descr_ref->components INTO wa_table .

WRITE: / wa_table-name.

ENDLOOP.

Thanks,

Selva M

5 REPLIES 5

Former Member
0 Kudos

Hi,

Assuming your internal table with header line is GT_ITAB.

Use 2 field symbols:

<FS_HEADER_LINE> type (Type of Work Area)

<FS_ITAB> type (Type of Internal Table)

data : lf_header_line type string value 'GT_ITAB',

lf_itab type string value 'GT_ITAB[]'.

assign (lf_header_line) to <FS_HEADER_LINE>.

assign (lf_itab) to <FS_ITAB>.

Now.

<FS_HEADER_LINE> if assigned will give u the content of header line

<FS_ITAB> if assigned will give u the content of itab body.

Sridhar

Former Member
0 Kudos

Hi S. Kannepalli ,

I solved how to get content of the body. My problem is to get header line content into another internal table as DATA.

For example:

Target Table:

header: a b c

body1: 12 14 22

body2: 33 41 131

Result Table:

header: no need for a header.

body1: a b c

0 Kudos

Hi kerimmkilic,

I am not sure if you got your question. Do you want to determine the names and types of the table fields at runtime? Then you can use the ABAP run time type services (RTTS).

DATA: descr_ref TYPE ref to cl_abap_tabledescr.

descr_ref ?= cl_abap_typedescr=>describe_by_data( <table> ).

The administrative data of the table is then stored in attributes of descr_ref. As an example, the key fields can be found in descr_ref->key.

Best,

Chris

Former Member
0 Kudos

Hi,

Please check this will give you the solution,

If you want the coloumn name of field symbol,

TABLES: Mara.

FIELD-SYMBOLS : <i_itab> TYPE ANY TABLE.

DATA: lt_tabledescr_ref TYPE REF TO cl_abap_tabledescr,

lt_descr_ref TYPE REF TO cl_abap_structdescr,

wa_table TYPE abap_compdescr.

DATA: it_tab TYPE TABLE OF mara.

ASSIGN it_tab TO <i_itab>.

lt_tabledescr_ref ?= cl_abap_typedescr=>describe_by_data( <i_itab> ).

lt_descr_ref ?= lt_tabledescr_ref->get_table_line_type( ).

LOOP AT lt_descr_ref->components INTO wa_table .

WRITE: / wa_table-name.

ENDLOOP.

Thanks,

Selva M

Former Member
0 Kudos

Thanks for all answers. Selva solved my problem.