Application Development and Automation 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: 
Read only

Need dynamic select statement

Former Member
0 Likes
579

data : gv_string type c.

concadinate 'ce4'  p_bukkrs into gv_string.-----> gv_string  having  my table name  gv_string is dynamicaly (ex. ce4100 , ce430000 ce49000 like that )

i need  to select some  fields  from that table (gv_string)

select * from
gv_string -
into table gt_acct.

am getting error  any solution to select  the  fields from gv_string

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
528

Hi,

try this example

REPORT ztx1406.

  data : gv_string type string

  data:it_mara type STANDARD TABLE OF mara.

CONCATENATE 'MA'  'RA' into gv_string.

select * from

(gv_string)

into table it_mara.

select * from

(gv_string)

into table gt_acct.

2 REPLIES 2
Read only

Former Member
0 Likes
529

Hi,

try this example

REPORT ztx1406.

  data : gv_string type string

  data:it_mara type STANDARD TABLE OF mara.

CONCATENATE 'MA'  'RA' into gv_string.

select * from

(gv_string)

into table it_mara.

select * from

(gv_string)

into table gt_acct.

Read only

former_member194152
Contributor
0 Likes
528
Specifying Source dynamically :
DATA wa TYPE scarr.
DATA name(10) TYPE c VALUE 'SCARR'.
SELECT  *  INTO  wa  FROM  (name) CLIENT SPECIFIED  WHERE mandt = '000'.
WRITE: / wa-carrid, wa-carrname.
Specifying Column dynamically :

DATA: itab TYPE STANDARD TABLE OF spfli,



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.


           wa LIKE LINE OF itab.

ENDIF.