Skip to Content
author's profile photo Former Member
Former Member

Field Symbol Header Line

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2012 at 10:14 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2012 at 09:24 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2012 at 09:38 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2012 at 10:13 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2012 at 11:20 AM

    Thanks for all answers. Selva solved my problem.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.