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

To Retieve Feilds of a Particular Table and Display it ...!

hi,

I am new to ABAP/4 Programming. Suppose we have a table called Zmaterial, it contains ID,NAME,DESCRIPTION and PICTURE fields, here what is my objective is i want to retrieve all of these field names from zmaterial in to my ABAP Program

Please Can Anyone Give me Solution ....!

Thanks

Prasad

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 05:03 AM

    Hi,

    For this you need to create an internal table of the same type as the Ztable i.e Zmaterial.

    Then by looping on that internal table and using the work area you can work on it in your program.

    For example,

    Create an internal table of same type as Zmaterial-

    data: itab type Zmaterial,

    wa_itab like line of itab.

    loop at itab into wa_itab.

    ..........

    ..........

    .........

    And do whatever ur requirement is.

    Itab table will have all the fields as table Zmaterial has.

    just use it as suppose, wa_itab-field1 etc.

    and then using write statement display it on ur screen..

    Thanks

    Revert back if any queries

    Reward points if useful

    Edited by: Malvika Sharma on May 28, 2008 7:04 AM

    Edited by: Malvika Sharma on May 28, 2008 7:06 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 05:05 AM

    Report zmaterial_out.

    tables : zmaterial.

    data : it_zmaterial like zmaterial occurs 0 with header line.

    select * from zmaterial into table it_zmaterial.

    loop at it_zmaterial.

    write : / it_zmaterial-ID, it_zmaterial-NAME, it_zmaterial-DESCRIPTION, it_zmaterial-PICTURE.

    clear it_zmaterial.

    endloop.

    Regards,

    Madan.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 05:06 AM

    Hi,

    For that u have to create the Report.

    REPORT zfir_v.

    TABLES : zmaterial.

    TYPE-POOLS: slis.

    DATA: BEGIN OF it_zmaterial OCCURS 0,

    ID LIKE zmaterial-ID,

    name hbkid LIKE zmaterial-NAME,

    material LIKE zmaterial-material,

    description LIKE zmaterial-description,

    END OF it_zmaterial .

    ----


    • Generating field catalog for the display of errors in ALV display. *

    ----


    DATA: v_repid LIKE sy-repid,

    i_fieldcat1 TYPE slis_t_fieldcat_alv,

    lv_layout TYPE slis_layout_alv,

    v_events TYPE slis_t_event,

    w_fieldcat TYPE slis_fieldcat_alv.

    &----


    *& START OF SELECTION SCREEN *

    &----


    SELECTION-SCREEN BEGIN OF BLOCK general WITH FRAME TITLE text-001.

    SELECT-OPTIONS:

    s_ID FOR zmaterial-ID ,

    s_name FOR zmaterial-NAME ,

    SELECTION-SCREEN END OF BLOCK general.

    &----


    *& INITIALIZATION. *

    &----


    INITIALIZATION.

    v_repid = sy-repid.

    lv_layout-colwidth_optimize = 'X'.

    &----


    *& START-OF-SELECTION event starts here. *

    &----


    START-OF-SELECTION.

    SELECT ID material name description

    FROM zmaterial

    INTO CORRESPONDING FIELDS OF TABLE it_zmaterial

    WHERE ID IN s_ID AND

    name IN s_name.

    &----


    *& To prepare the field catalogue dynamically based on the input *

    *& provided by the user on the selection-screen. *

    &----


    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    i_program_name = v_repid

    i_internal_tabname = 'IT_ZMATERIAL'

    • i_structure_name = 'ZMATERIAL'

    i_inclname = v_repid

    i_bypassing_buffer = 'X'

    i_buffer_active = ' '

    CHANGING

    ct_fieldcat = i_fieldcat1

    EXCEPTIONS

    inconsistent_interface = 1

    program_error = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    LOOP AT i_fieldcat1 INTO w_fieldcat.

    CASE w_fieldcat-fieldname.

    WHEN 'ID'.

    w_fieldcat-col_pos = 1.

    w_fieldcat-ddictxt = 'L'.

    w_fieldcat-seltext_l = 'ID'.

    MODIFY i_fieldcat1 FROM w_fieldcat.

    WHEN 'NAME'.

    w_fieldcat-col_pos = 2.

    w_fieldcat-ddictxt = 'L'.

    w_fieldcat-seltext_l = 'NAME'.

    MODIFY i_fieldcat1 FROM w_fieldcat.

    WHEN 'MATERIAL'.

    w_fieldcat-col_pos = 3.

    w_fieldcat-ddictxt = 'L'.

    w_fieldcat-seltext_l = 'MATERIAL'.

    MODIFY i_fieldcat1 FROM w_fieldcat.

    WHEN 'DESCRIPTION'.

    w_fieldcat-col_pos = 4.

    w_fieldcat-ddictxt = 'L'.

    w_fieldcat-seltext_l = 'DESCRIPTION'.

    MODIFY i_fieldcat1 FROM w_fieldcat.

    ENDCASE.

    ENDLOOP.

    &----


    *& To output a simple list *

    &----


    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = v_repid

    is_layout = lv_layout

    it_fieldcat = i_fieldcat1

    it_events = v_events

    TABLES

    t_outtab = it_zmaterial

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 28, 2008 at 05:12 AM

    Hi Prasad,

    Its very easy

    follow the simple steps

    1) create a internal table like your ztable

    data : itab type table of <ur ztable> with header line.

    2) write a select query to get contents from dbtable to your internal table

    *select * from <ur ztable > into table itab .*

    3) display the internal table

    loop at itab.

    write : / itab-id,

    itab-name,

    itab-description,

    itab-picture.

    endloop.

    save and activate your program

    then execute

    reward if helpful

    prasanth

    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.