Skip to Content
0
Former Member
Dec 16, 2003 at 01:39 PM

Dyanmic SQL Select Statement

26 Views

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 😔