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: 

output from tables which I mention in select options of the screen as input

Former Member
0 Kudos

Dear All,

I want to fetch the data in the form of output from tables which I will mention in select options of the screen as input.

In selection screen option if I write any table name then how can i select this table in select query of ABAP program ?.

I may select any tables in select options of screen. But In select query I should get that table name automatically.. How ?

e.g. If i put table name as an input i.e. MARA in select option .

In program how to write select query to get records from that table ?

SELECT MTART MATKL from MARA

Every time I should not go to select query of program & replace the tablename.

How to solve this problem ?

3 REPLIES 3

former_member1245113
Active Contributor
0 Kudos

Hi,

PARAMETERS p_table(30)." type string.
"This is a Tested code Just Execute and Check
START-OF-SELECTION.
  DATA: lt_tmp TYPE REF TO data.
  DATA : line TYPE REF TO data.
  FIELD-SYMBOLS: <lt_tmp> TYPE STANDARD TABLE, <wa>, <dyn_field>.

  CREATE DATA lt_tmp TYPE STANDARD TABLE OF (p_table).
  ASSIGN lt_tmp->* TO <lt_tmp> .
  CREATE DATA line LIKE LINE OF <lt_tmp>.
  ASSIGN line->* TO <wa>.
  SELECT * FROM (p_table) INTO TABLE <lt_tmp>.
  IF sy-subrc = 0.
    LOOP AT <lt_tmp> ASSIGNING <wa>.
      DO.
        ASSIGN COMPONENT  sy-index
           OF STRUCTURE <wa> TO <dyn_field>.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
        IF sy-index = 1.
          WRITE:/ <dyn_field>.
        ELSE.
          WRITE: <dyn_field>.
        ENDIF.
      ENDDO.

    ENDLOOP.
  ENDIF.

Cheerz

Ram

Sandra_Rossi
Active Contributor
0 Kudos

Please don't help him: Total Questions: 111 (104 unresolved)

Former Member
0 Kudos

Thanks.

Very helpful answer.