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

how to select table fields dynamically?

Hi,

In a table i have 16 fields like a1,a2,----a16, based on user entry on selection screen, i hvae to fetch field.

Ex. If user enters 2 on selection screen i have to fetch 2nd field of the table,if it is 5 i have to fetch 5th field etc.

Is there any solution to get fields without using case and endcase.

Thnak u.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 05:21 AM

    Hi,

    You can use case or if statements..

    Thanks

    Shyja

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 05:21 AM

    Try like this:

    
    DATA: L_FLD(30).
    
    CONCATENATE 'FIELD_' P_NO INTO L_FIELD. " < FIELD_5
    
    SELECT (L_FLD)
    INTO L_VALUE
    FROM ZTAB
    WHERE COND = CONDITION.

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 05:49 AM

    if it is select options in your selection screen...just use "IN" in your query....

    if u r entries r of parameters type.

    declare it as select-options in this way

    selection-options:<entry> for <reference-field> no-extension no intervals.

    reward if usefull.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 06:55 AM

    Hi,

    Try like this:

    DATA: itab TYPE STANDARD TABLE OF spfli,

    wa LIKE LINE OF itab.

    DATA: line(72) TYPE c,

    list LIKE TABLE OF line(72).

    line = ' CITYFROM CITYTO '.

    APPEND line TO list.

    SELECT DISTINCT (list)

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM spfli.

    IF sy-subrc EQ 0.

    LOOP AT itab INTO wa.

    WRITE: / wa-cityfrom, wa-cityto.

    ENDLOOP.

    ENDIF.

    Regards,

    Bhaskar

    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.