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: 

Native SQL - where condition .

Former Member
0 Kudos

Hi All,

This is my code :

SELECT-OPTIONS: P_KUNAG FOR VBRK-KUNAG,

P_PRSDT FOR SY-DATUM .

EXEC SQL .

SELECT PRSDT, MATNR, KUNAG

INTO :ITAB

FROM ZXXXXXXXX

WHERE KUNAG ( BETWEEN :P_KUNAG-LOW AND :P_KUNAG-HIGH ).

AND PRSDT ( BETWEEN :P_PRSDT-LOW AND :P_PRSDT-HIGH ) .

ENDEXEC.

I want values from p_kunag between (from , to ) of select options .

Thanks

Vivek.

4 REPLIES 4

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

This is the sample code for parameters.You can try similar things if you are suing no-extension in select-options as below.

tables mara.

select-options s_matnr for mara-matnr no-extension.

data : v_name(20) type c,

v_total type i.

PARAMETERS : p_regno(10) TYPE c DEFAULT 'R1000'.

EXEC SQL PERFORMING write_details.

SELECT name, total INTO :v_name, :v_total FROM stu_det

WHERE regno = :p_regno

ENDEXEC.

&----


*& Form WRITE_details

&----


  • text

----


FORM write_details.

WRITE: / 'Student Details:', p_regno, v_name, v_total.

ENDFORM. "WRITE_details

0 Kudos

hi jayanthi ,

Thanks for ur your reply,But im using extension .

I want values ( from and to ) from Native SQL.

cheers

vivek.

Former Member
0 Kudos

Use the workarea of Itab here...

EXEC SQL.

SELECT prsdt, matnr, kunag FROM zxxxxx INTO :itab_WA WHERE

(kunag BETWEEN :P_kunag-loW AND :P_kunag-HIGH ) and (PRSDT BETWEEN :P_PRSDT-LOW AND :P_PRSDT-HIGH ) .

ENDEXEC.

If you want to fetch all the records...see the following example...it will help you...

PARAMETERS p_carrid TYPE spfli-carrid.

DATA: connid TYPE spfli-connid,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto.

EXEC SQL.

OPEN dbcur FOR

SELECT connid, cityfrom, cityto

FROM spfli

WHERE carrid = :p_carrid

ENDEXEC.

DO.

EXEC SQL.

FETCH NEXT dbcur INTO :connid, :cityfrom, :cityto

ENDEXEC.

IF sy-subrc <> 0.

EXIT.

ELSE.

...

ENDIF.

ENDDO.

EXEC SQL.

CLOSE dbcur

ENDEXEC.

Message was edited by:

Ramu

0 Kudos

Hi Ramu,

Thanks For your reply, But im using select option for ( Date ) input .

P_PRSDT. The code should fetch the values in between from and to date.

Cheers

vivek.