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

Dyanmic SQL Select Statement

Hello,

Trying to build a dynamic select statement from a listbox but this is the best I can get and I only end up with a error "Missing value" I was hoping someone might have an idea or maybe a better way to do this ???

DATA: listbox TYPE REF TO CL_HTMLB_LISTBOX.

DATA: if TYPE REF TO CL_HTMLB_INPUTFIELD.

if ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

id = 'startdate'

name = 'inputfield' ).

myStart = if->value.

if ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

id = 'enddate'

name = 'inputfield' ).

myEnd = if->value.

CONCATENATE 'MDATE between' myStart 'and' myEnd

INTO myWhereDate SEPARATED BY SPACE.

listbox ?= CL_HTMLB_MANAGER=>GET_DATA(

request = request

id = 'sid'

name = 'listBox' ).

CLEAR listselections.

LOOP AT listbox->selections INTO listselection.

CONCATENATE listselections '(' 'SID' '=' '"' listselection '"' 'AND' myWhereDate ')' 'OR'

INTO listselections SEPARATED BY SPACE.

ENDLOOP.

IF strlen( listselections ) > 0.

listselections = listselections+1.

ENDIF.

IF listbox->selection IS INITIAL.

listbox->selection = ' '.

ENDIF.

IF listselections IS INITIAL.

listselections = ' '.

ELSE.

CONCATENATE listselections '(' 'SID' '=' '"Z"' ')'

INTO myWhere SEPARATED BY SPACE.

ENDIF.

select * from ZDIALOG_STATS into

corresponding fields of table helladialog up to 250 rows

WHERE (myWhere)

order by sid.

It's not the nicest coding but being a Java Programmer and trying to adapt what I know works to BSP's is rather challenging 😔

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2003 at 02:55 PM

    I found the problem and now it works but if someone has a nicer way of coding this, especially if I don't have to include a DUMMY ending of SID='Z' that would be great.

    DATA: listbox TYPE REF TO CL_HTMLB_LISTBOX.

    DATA: if TYPE REF TO CL_HTMLB_INPUTFIELD.

    if ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

    id = 'startdate'

    name = 'inputfield' ).

    myStart = if->value.

    if ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

    id = 'enddate'

    name = 'inputfield' ).

    myEnd = if->value.

    CONCATENATE '(' 'MDATE between' myStart 'and' myEnd ')'

    INTO myWhereDate SEPARATED BY SPACE.

    listbox ?= CL_HTMLB_MANAGER=>GET_DATA(

    request = request

    id = 'sid'

    name = 'listBox' ).

    CLEAR listselections.

    LOOP AT listbox->selections INTO listselection.

    CONCATENATE '''' listselection '''' INTO listselection.

    CONCATENATE listselections '(' 'SID' '=' listselection ')' 'OR'

    INTO listselections SEPARATED BY SPACE.

    ENDLOOP.

    IF strlen( listselections ) > 0.

    listselections = listselections+1.

    ENDIF.

    IF listbox->selection IS INITIAL.

    listbox->selection = ' '.

    ENDIF.

    IF listselections IS INITIAL.

    listselections = ' '.

    ELSE.

    CONCATENATE listselections '(' 'SID' '=' '''Z''' ')' 'AND' myWhereDate

    INTO myWhere SEPARATED BY SPACE.

    ENDIF.

    select * from ZDIALOG_STATS into

    corresponding fields of table helladialog up to 250 rows

    WHERE (myWhere)

    order by sid.

    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.