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

Search logic

Former Member
0 Likes
719

Hi,

I have to write a RFC for searching order number based on text, order type or order number.

There can be an instance any of the fields can be empty and search engin should get results based on input.

I guess I will have to write so many combinations to achieve this search. Can any one suggest if they know any other logic to write such kind of search.

Regards

Ria

Hi,

I have to write a RFC for searching order number based on text, order type or order number.

There can be an instance any of the fields can be empty and search engin should get results based on input.

I guess I will have to write so many combinations to achieve this search. Can any one suggest if they know any other logic to write such kind of search.

Regards

Ria

4 REPLIES 4
Read only

Former Member
0 Likes
649

HI,

You can populate your search condition in the Ranges.

Create range table for each field namely text, order type, order number. Use

IN <text> and

IN <ORDERTYPE> and

IN <ORDERNUMBER> in the where clause.

Regards,

Vara

Read only

Former Member
0 Likes
649

Hi ,

You can refer for the function module CPWBBROWSER_SEARCH_FOR_STRING, this might give some clue about how to go about doing this,

Rgds,

Read only

Former Member
0 Likes
649

Hi

Kindly try this logic.

DATA: cond_text(255) TYPE c.

IF TEXT IS NOT INITIAL.
CONCATENATE 'and' 'TEXT like %search_text%' 
       INTO cond_text SEPARATED BY space.
ENDIF.

IF Order_type IS NOT INITIAL.
CONCATENATE 'and' 'Order_type like %Order_type%' 
       INTO cond_text SEPARATED BY space.
ENDIF.
...
...
...

if cond_text is not inital.
  WRITE ' ' TO cond_text+0(4). 
  SELECT * FROM TABLE INTO CORRESPONDING FIELDS OF TABLE i_Tab
  WHERE (cond_text).
else.
  SELECT * FROM TABLE INTO CORRESPONDING FIELDS OF TABLE i_Tab.
endif.

Hope this helps!

Kindly assign points for helpful answers!

best regards

Thangesh

Read only

ibrahim_u
Active Participant
0 Likes
649

parameters : po_type.
parameters : po_num.

ranges : ro_type for ORDER_TYPE?.
ranges : ro_num  for ORDER_NUMBER?.

if po_type ne space.
  move 'I'     to ro_type-sign. 
  move 'EQ'    to ro_type-option.
  move po_type to ro_type-low.
  append ro_type.
endif.

if po_num ne space.
  move 'I'    to ro_num-sign. 
  move 'EQ'   to ro_num-option.
  move po_num to ro_num-low.
  append ro_num.
endif.

select * from TABLE where order_type IN ro_type
                      and order_num  IN ro_num.

ibrahim