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: 

Select with constants

Former Member
0 Kudos

In SQL I can use a constant in my selection parameters. Is it possible to do this in ABAP as well? For instance is there a similar way to do the following in ABAP (obviously the following will not compile just an example of what I'm trying to do)?

data: begin of g_itab occurs 0,

order_no like vbap-vbeln,

line_no like vbap-posnr.

data: end of g_itab.

select vbeln '000010' into table g_itab.

1 ACCEPTED SOLUTION

suresh_datti
Active Contributor
0 Kudos

Hi Shaun,

No.. you cannot use constants in the field list..You can revise it as follows..


select vbeln posnr into table g_tab
       from vbap
       where posnr eq '000010'.

Regards,

Suresh Datti

6 REPLIES 6

suresh_datti
Active Contributor
0 Kudos

Hi Shaun,

No.. you cannot use constants in the field list..You can revise it as follows..


select vbeln posnr into table g_tab
       from vbap
       where posnr eq '000010'.

Regards,

Suresh Datti

0 Kudos

Thanks for your reply Suresh. I have a way around it but it requires an additional step that I was hoping to avoid. The example you provide below changes actually what I'm trying to do so it wouldn't work. Hopefully SAP supports this in the future.

0 Kudos

what exactly are you trying to do?

Suresh

0 Kudos

Suresh.... there are several ways to solve my issue and I've chosen one. You've answered my question and I won't bore you with the details of what I'm trying to do. It was more curiosity than anything. Basically I knew what I was trying to do could be done in standard ANSII SQL but wasn't sure if and how ABAP supported it. I had tried various methods but none worked. Last resort was to post the question here. Thanks again for your follow-up.

0 Kudos

I think you could do this in native sql.

exec sql.

select blah '0001' from xyz etc.

ENDEXEC.

eg,

DATA: BEGIN OF wa,

connid TYPE spfli-connid,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto,

END OF wa.

DATA c1 TYPE spfli-carrid VALUE 'LH'.

EXEC SQL.

SELECT '0001', cityfrom, cityto

INTO :wa

FROM spfli

WHERE carrid = :c1

ENDEXEC.

WRITE: / wa-connid, wa-cityfrom, wa-cityto.

By the way, Shaun the details won't bore us... your problem and solution may help others with similar issues, please share it if you can.

0 Kudos

Have you explored the option of using native SQL in ABAP ie EXEC..ENDEXEC stuff?

Regards,

Suresh Datti