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

how can i see fields with their field names in application server

generally when ever we sent data to aplication server we wil see only field values ,how can i send field values with their field names to application server,

my requirement is to see all fields with their corresponding fieldnames in application server.

here i am having data in ITAB .

thnks in adv...

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 04:16 PM

    I suppose you want a header line with the names of the structure in a file?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      Plz chk if the code below helps..

      DATA: g_msg(50) TYPE c, " Message

      l_line(1024) TYPE c,

      l_field(100) TYPE c,

      g_file TYPE string, " Output file name

      FIELD-SYMBOLS: <fs>.

      g_file should be given the filename.

      • Open file

      OPEN DATASET g_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

      IF sy-subrc <> 0.

      g_msg = 'Download Failed &'.

      EXIT.

      ENDIF.

      • Write data to file; separate fields by tabs

      • Write header to file

      CLEAR l_line.

      • You can either add descriptions or add fieldnames in this depending on your interest

      CONCATENATE 'Title 1' 'Title 2' 'Title 3' 'Title 4' INTO l_line

      SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

      TRANSFER l_line TO g_file.

      LOOP AT t_out. "t_out is the internal table which has the records to be written in appln. server

      CLEAR l_line.

      WHILE 1 = 1.

      ASSIGN COMPONENT sy-index OF STRUCTURE t_out TO <fs>.

      IF sy-subrc <> 0.

      EXIT.

      ENDIF.

      IF sy-index = 1.

      l_line = <fs>. "This is to start a fresh line with the value of the 1st field.

      ELSE.

      l_field = <fs>. "This is to continue the values of rest of the fields of the same record.

      CONDENSE l_field.

      CONCATENATE l_line l_field INTO l_line

      SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

      ENDIF.

      ENDWHILE.

      TRANSFER l_line TO g_file.

      IF sy-subrc <> 0.

      g_msg = 'Download Failed &'.

      EXIT.

      ENDIF.

      ENDLOOP.

      • Close file

      CLOSE DATASET g_file.

      IF sy-subrc <> 0.

      g_msg = 'Download Failed &'.

      ENDIF.

  • Posted on Jan 15, 2009 at 10:31 PM

    Hi Mahendra,

    You can get field names declared in your internal table by using the program logic given below.

    TYPE-POOLS : abap.

    • SAMPLE INTERNAL TABLE

    DATA: BEGIN OF tabl occurs 0,

    mandt TYPE mara-mandt,

    matnr TYPE mara-matnr,

    ersda TYPE mara-ersda,

    ernam TYPE mara-ernam,

    laeda TYPE mara-laeda,

    aenam TYPE mara-aenam,

    vpsta TYPE mara-vpsta,

    pstat TYPE mara-pstat,

    lvorm TYPE mara-lvorm,

    mtart TYPE mara-mtart,

    mbrsh TYPE mara-mbrsh,

    END OF tabl.

    DATA : it_details TYPE abap_compdescr_tab,

    wa_comp TYPE abap_compdescr.

    DATA : ref_descr TYPE REF TO cl_abap_structdescr.

    ref_descr ?= cl_abap_typedescr=>describe_by_data( tabl ).

    it_details[] = ref_descr->components[].

    loop at it_details into wa_comp.

    write:/ wa_comp.

    endloop.

    You can write contents of this internal table it_details to display or write internal table fieldnames in your output file

    Best Regards,

    Krishna

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 16, 2009 at 01:37 AM

    hi

    i think u wil be help this

    REPORT test.

    ----


    DATA:

    ok_code LIKE sy-ucomm,

    ref_struc TYPE REF TO data.

    ----


    FIELD-SYMBOLS:

    <fs_struc> TYPE ANY,

    <fs_comp> TYPE ANY.

    ----


    PARAMETERS:

    pa_tab TYPE dd02l-tabname DEFAULT u2019SPFLIu2019.

    ----


    START-OF-SELECTION.

    ----


    CREATE DATA ref_struc TYPE (pa_tab).

    ASSIGN ref_struc->* TO <fs_struc>.

    SELECT * FROM (pa_tab)

    INTO <fs_struc>

    UP TO 100 ROWS

    .

    DO.

    ASSIGN COMPONENT sy-index OF STRUCTURE <fs_struc> to <fs_comp>.

    IF sy-subrc <> 0.

    NEW-LINE.

    EXIT.

    ENDIF.

    WRITE: <fs_comp>.

    ENDDO.

    ENDSELECT.

    IF sy-subrc <> 0.

    MESSAGE e041(bc402).

    ENDIF.

    Cheer

    nawa

    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.