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: 

SQL Statement

Former Member
0 Kudos

Hi all

Any way to make the below statement dynamic.

student table include fields like firstname, lastname, admino.

data: fname(20) type c,

lname(20) type c,

name(20) type c.

fname = 'firstname'.

lname = 'lastname'.

Select <b>fname lname</b> into (name) from student where

admino = '012345'.

endselect.

i want the sql statement for fname, lname take from the variable... anyway to do that?

3 REPLIES 3

Former Member
0 Kudos

Hi..Gary..

Can u be more clear in your requirement??

Regards

Pranali

Former Member
0 Kudos

HI,

TRY LIKE THIS.

data: fname(20) type c,

lname(20) type c,

name(50) type c.

fname = 'firstname'.

lname = 'lastname'.

CONCATENATE FNAME LNAME INTO NAME.

THEN USE WAT CONDITON U WANT.

IF HELPFUL REWARD SOME POINTS.

WITH REGARDS,

SURESH ALURI.

Former Member
0 Kudos

Hi,

tables : student.

parameters : p_admino TYPE admino. " you can give single value

select-options : s_admino for admino. " u can give range fo values.

data : begin of tbl_student occurs 0,. " internal table with header

fname(20)

lname(20) ,

name(20),

end of tbl_student.

Select fname lname name

from student

into table tbl_student

where admino = p_admino. or

where admino in s_admino.

if sy-subrc = 0.

sort tbl_stuent by fname.

endif.

" to Display the records.

loop at tbl_student.

write 😕 tbl_student-fname,tbl_student-lname,tbl_student-name.

clear :tbl_student.

endloop.

<b>Rewards with points if helpful.</b>

Regards,

Vijay.