Skip to Content
author's profile photo Former Member
Former Member

Native SQL - where condition .

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Dec 03, 2007 at 06:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 06:11 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.