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

how to select record

Former Member
0 Likes
862

Hi all ,

i have a database table but0id and field IDNUMBER

and i have four input parameters say input1,input2,input3,input4.

input1 corresponds to first two characters of database field IDNUMBER.

and Input2 corresponds to but0id-IDNUMBER+2(5)

and input3 = but0id-IDNUMBER+8(3)

and input3 = but0id-IDNUMBER+11(2)

out of these four input parameters only first one is mandatory and all the others are optional.

i need to write a select statement

which will compare like input one with first two characters of Idnumber and so on

please help me

Thanks in Advance

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
796

Hi,

Try this and kindly reward points by clicking the star on the left of reply,if it helps.

data itab type standard table of but0id.

select * from but0id into table itab

where idnumber like 'input1%'

and idnumber like '%input2%'

and idnumber like '%input3%'

and idnumber like '%input4'.

But here % refers to set of characters.

Hi,

Try this and kindly reward points by clicking the star on the left of reply,if it helps.

data itab type standard table of but0id.

select * from but0id into table itab

where idnumber like 'input1%'

and idnumber like '%input2%'

and idnumber like '%input3%'

and idnumber like '%input4'.

But here % refers to set of characters.

4 REPLIES 4
Read only

Former Member
0 Likes
796

select wont allow u to take the offeset on the db field.

Instead of that select data from DBtable and put it into internal table.

then loop and check with the offsets for all input values and try to delete the unwanted values.

Thanks

eswar

Read only

Former Member
0 Likes
796

Dear Sai ram,

You want to write an SQL statement to retreive data from table based on your parameters isn't it. But values corresponding to sub-string values. Hope I got your problem correct.

You could solve in this way.

  • Code Starts

DATA : wa_but0id TYPE BUT0ID.

CONCATENATE input1 '*' INTO x.

SELECT SINGLE *

INTO CORRESPONDING FIELDS OF wa_but0id

FROM BUT0ID

WHERE IDNUMBER CP x.

Hope it helps.

Regards,

Deva.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
797

Hi,

Try this and kindly reward points by clicking the star on the left of reply,if it helps.

data itab type standard table of but0id.

select * from but0id into table itab

where idnumber like 'input1%'

and idnumber like '%input2%'

and idnumber like '%input3%'

and idnumber like '%input4'.

But here % refers to set of characters.

Read only

Former Member
0 Likes
796

Can try this...

tables: E3EDK25,TRAUTHREC,mara,PPFSRMTYP.

data: fld like mara-matnr.

data: begin of tab occurs 0.

include structure mara.

data: end of tab.

parameters: inp like E3EDK25-qualf,

inp2 like PPFSRMTYP-option,

inp3 like E3EDK25-qualf,

inp4 like TRAUTHREC-object.

if inp = ' '.

inp = '*'.

endif.

if inp2 = ' '.

inp2 = '*'.

endif.

if inp3 = ' '.

inp3 = '*'.

endif.

if inp4 = ' '.

inp4 = '*'.

endif.

concatenate inp inp2 inp3 inp4 into fld.

replace all occurrences of '*' in fld with '%'.

select * from mara into table tab where matnr like fld.