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

Use variable in SQL statement

Former Member
0 Likes
480

HI guys:

I need code three SQL statements.the returned field and selected table are all same,there is only a difference in their "where" statement.

Sample code:

select marcmatnr marcwerks

into table it_data

from MARC inner join MBEW on marcmatnr = mbewmatnr

where marcmatnr like 'A%' and mbewzplp1 = '001'.

second one........................ mbew~zplp2 = '001'

third one......................... mbew~zplp3 = '001'

Could I write a FORM gather them with transporting a parameter ZPLPX to determine which condiniton will be execute?

thank you very much.

3 REPLIES 3
Read only

abdul_hakim
Active Contributor
0 Likes
455

Hi Tilani.

Welcome to SDN.

You can very well do it by passing as a parameter of the subroutine.

Abdul

Read only

0 Likes
455

Hi,

You can use perform to do that.

it looks good also.

VIjay

Read only

Former Member
0 Likes
455

Hi tianli,

1. source text

This concept of dynamic where

condition is called source text.

2. use like this.

This is important in the code ---> WHERE (mywhere).

REPORT abc LINE-SIZE 80.

DATA : it_data LIKE TABLE OF mara WITH HEADER LINE.

*----


QUOTES ARE IMPORTANT

PERFORM mysql USING 'mbew~zplp2 = ''001'''.

*----


FORM mysql USING mywhere.

SELECT marcmatnr marcwerks

INTO TABLE it_data

FROM marc INNER JOIN mbew ON marcmatnr = mbewmatnr

WHERE (mywhere).

ENDFORM. "mysql

regards,

amit m.