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

Select Statement

Former Member
0 Likes
908

HI,

I have one import parameter as Sales_org (VBAK-VKORG).

I need to write a select statement to get the records from VAKPA table and the condition should be as

Frst four characters of VAKPA-KUNDE = Sales_org.

I have written the select statement as

select KUNDE

from VAKPA

into table i_VAKPA

where KUNDE+0(4) = Sales_org.

I am getting error as we cannot use offset in the select statement.

Can anyone let me know how to write this query.

Regards,

Ram

10 REPLIES 10
Read only

Former Member
0 Likes
883

Hi Ram ,

You need to use the like statement in place of equal to .

Take the Sales_org into a variable and append % at the end of it.

Then use this varaible in the where clause.

Regards

Arun

Read only

0 Likes
883

Not clear Arun. Could you pls elaborate this with some example.

Regards,

Ram.

Read only

0 Likes
883

Hi Ram,

Decleare a variable which can accomodiate at 5 chars , let the variable be V_TEMP.

CONCATENATE Sales_org '%' into v_temp.

select KUNDE

from VAKPA

into table i_VAKPA

where KUNDE like v_temp.

Please try this and see if it helps.

Regards

Arun

Read only

0 Likes
883

Hi Arun,

My requirement is need to compare only the first 4 cahracters of field KUNDE = Sales_org.

Here the field KUNDE is of 10 character in length. like 'CH10234567'

and if my sales_org = CH10 then need to write select statement for this to satisfy the above condition.

select KUNDE

from VAKPA

into i_VAKPA

where KUNDE+0(4) = sales_org.

Regards,

Ram

Read only

0 Likes
883

Hi Ram ,

The statement will check only the first 4 char and will select all those records where the first 4 char of KUNDE is the input given by you.

Regards

Arun

Read only

Former Member
0 Likes
883

Hi,

Instead of KUNDE ...If it is okay..You can directly use the VKORG field in the table VAKPA..

select KUNDE

from VAKPA

into table i_VAKPA

where VKORG = Sales_org.

Thanks,

Naren

Read only

learnsap
Active Participant
0 Likes
883

Hi Ram Mohan,

Data v_text(6) type c

concatenate sales_org '%' into v_text.

select KUNDE

from VAKPA

into table i_VAKPA

where KUNDE like v_text.

I think this will solve the problem. Correct me if I am wrong.

Regards,

Ramesh S

*award points if reply is helpful

Message was edited by:

Ramesh Babu Srikakollu

Read only

Former Member
0 Likes
883

Hi,

Try this

First offset Sales org in a Temporary table then pass it to the SELECT statement

Since

u cant use Offset in Select statement

Thanks

Shankar S

Close it when its Answered

Read only

Former Member
0 Likes
883

HI RAM MOHAN,

TRY THIS...

DATA : BEGIN OF ITAB OCCURS 0,

KUNDE LIKE VAKPA-KUNDE,

END OF ITAB.

DATA : BEGIN OF ITAB1 OCCURS 0,

KUNDE LIKE VAKPA-KUNDE,

END OF ITAB1.

SELECT KUNDE FROM VAKPA INTO TABLE ITAB.

LOOP AT ITAB.

ITAB-KUNDE = ITAB-KUNDE+0(4).

MODIFY ITAB.

CLEAR ITAB.

ENDLOOP.

SELECT KUNDE FROM VAKPA INTO TABLE ITAB1 WHERE KUNDE EQ ITAB-KUNDE.

if it is helpful let me know.

Senthil kumar

Read only

Former Member
0 Likes
883

hi

store the sales org. in a variable and try like this

data v_sorg like vakpa-vkorg.

v_sorg = <Sales org.>

select KUNDE

from VAKPA

into table i_VAKPA

where KUNDE LIKE '%V_SORG%'.

if helpful, reward

Sathish. R