Application Development 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: 

SELECT statement with WHERE clause results in an ERROR

Former Member
0 Kudos

Hi All,

I am using following select statement in a program line within a SmartForm which results in an error.

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1

WHERE VBELN = '220'

AND PARVW = 'SP'.

If I modify this statement as below then it is working fine.

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1.

Can anyone please suggest me what is the problem with above statement.

Regards,

Avaneet

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

you should use the leading zeros before 220

25 REPLIES 25

Former Member
0 Kudos

Hi

you should use the leading zeros before 220

0 Kudos

Hi srinivasu,

I have also tried with leading zeros before 220, but no luck.

matt
Active Contributor
0 Kudos

What error are you getting?

0 Kudos

Hi All,

I dont know the exact error. But if I use following statement, no data is displayed in the output while if i see in the table VBPA, one row is available with VBELN = '220' and PARVW = 'SP'.

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1

WHERE VBELN = '220'

AND PARVW = 'SP'.

But If I use following statement, data is displayed in the output.

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1.

I have also tried to store '220' and 'SP' in variables and uses these variables in the select statement. But this is also not working.

Please help to resolve this issue.

0 Kudos

it was told already that '220' is definetly wrong (it is also wrong if you store in variable), the value has to be '0000000220' (if you don't know why than make a search on conversion exits + check the domain behind VBPA-VBELN in SE11)

SP is OK (I checked), however there is a converiosn exit as well

first replace the 220 in your select statement, if still no entry with this combination, than simply there are no entries with this combination

0 Kudos

hi..avaneet..

vbeln has 10 character space.

when u r giving a specific value in Select stmt as in ur case its '220' , we should always give with its total length.

so in ur where clause give it as

SELECT * 
FROM VBPA 
INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1
WHERE VBELN = '0000000220' 
AND PARVW = 'SP'.

regards,

Padma

If this also not gves proper answer,

check the declaration for ur field vbeln in t_kunnr1.

try to give it as

vbeln type vbpa-vbeln

Edited by: Padmashree RamMaghenthar on Oct 17, 2008 6:19 PM

matt
Active Contributor
0 Kudos

Thank-you - now you've been explicit, I can make suggestions. Next time, try to give sufficient information without being promted.

If you look at the domains VBELN and PARVW, you'll see they both have conversion routines - ALPHA and PARVW respectively. Use those conversion routines before doing the select.

DATA: l_vbeln TYPE vbeln,
      l_parvw TYPE parvw.

l_vbeln = '220'.
l_parvw = 'SP'.
CALL FUNCTION MODULE 'CONVERSION_EXIT_ALPHA_INPUT' 
    EXPORTING INPUT = l_vbeln
    IMPORTING OUTPUT = l_vbeln.
CALL FUNCTION MODULE 'CONVERSION_EXIT_PARVW_INPUT' 
    EXPORTING INPUT = l_parvw
    IMPORTING OUTPUT = l_parvw.


SELECT * 
FROM VBPA 
    INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1
    WHERE VBELN EQ l_vbeln
      AND PARVW EQ l_parvw.  

So, the vbeln value was held internally with leading zeros, AND the parvw value 'SP' is held internally as 'AG'. But don't ever select using "AG", always use the conversion exits.

matt

0 Kudos

Hi,

I have also tried with 10 digit VBELN value like this:

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1

WHERE VBELN = '0000000220'

AND PARVW = 'SP'.

But it is still not selecting any data.

If I see the table entries in VBPA from transaction SE11, it is showing an entry with VBELN = 220.

0 Kudos

this work for me... I executed it..


DATA: BEGIN OF t_kunnr1 OCCURS 0.
        INCLUDE STRUCTURE vbpa.
DATA: END OF t_kunnr1.

SELECT *
FROM vbpa
INTO CORRESPONDING FIELDS OF TABLE t_kunnr1
WHERE vbeln = '0000000001'
AND parvw = 'SP'.
if sy-subrc eq 0.
WRITE:/ 'Done'.
endif.

0 Kudos

that'll work, because "SP" (sold-to party) is internally stored as "AG" (Auftraggeber), old German legacy...to add to the confusion, there also is an internal value "SP" (Spediteur = Carrier).

Thomas

P.S. just saw now that you mentioned "AG" already...please ignore

0 Kudos

Hi

First chack in SE11 by giving the entries 000000220 and SP

then see how many records it is displaying

matt
Active Contributor
0 Kudos

>

> P.S. just saw now that you mentioned "AG" already...please ignore

Too late!

0 Kudos

avaneet,

when we see in the table, it display only values without preceeding zeros.

check this structure declaration and try it.

types: begin of ty_vbpa,

vbeln type vbpa-vbeln,

posnr type vbpa-posnr,

parvw type vbpa-parvw,

kunnr type vbpa-kunnr,

lifnr type vbpa-lifnr,

end of ty_vbpa.

data: t_kunnr1 type standard table of ty_vbpa.

wa_kunnr1 type ty_vbpa.

now use the above fields in select query and check it.

it wil work.

0 Kudos

First I did not find, 'cause I checked in German...

Funny thing there is an SP (Spediteur) ==> CR (Forwarding agent) as well

matt
Active Contributor
0 Kudos

As Thomas said, delightfully adding to the confusion. But now the original poster knows all about conversion exits, he'll never have this problem again. Well, here's hoping anyway.

0 Kudos

I would even call them confusion exits

0 Kudos

Hi ,

Try to declare the structure again ....

Regards,

Bharani

matt
Active Contributor
0 Kudos

>

> Hi ,

> Try to declare the structure again ....

>

>

>

> Regards,

> Bharani

Try to read the whole thread before posting.

matt
Active Contributor
0 Kudos

No, my telepathy skills are weak this afternoon. You'll have to tell me.

What error are you getting? ( Though srinivasu bv is probably correct ).

P561888
Active Contributor
0 Kudos

Hi,

Here VBELN is char 10 and store with leading zero , so for the retriving this we need to add the leading zeros.

Try this way

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1

WHERE VBELN = '0000000220'

AND PARVW = 'SP'.

the second one dont have the where clause so it will work fine.

regards,

Bharani

Former Member
0 Kudos

Hi avaneet,

Try holding the values 220 and SP in a local variables and use that local variables in the select statement probably it may work.

Cheers!!

Former Member
0 Kudos

Hi,

Use this...

Data: v_vbeln like VBPA-VBELN,

v_parvw like VBPA-PARVW.

v_vbeln = '220'.

v_parvw = 'SP'.

SELECT *

FROM VBPA

INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1

WHERE VBELN = v_vbeln

AND PARVW = v_parvw.

raymond_giuseppi
Active Contributor
0 Kudos

Try

SELECT * 
  FROM VBPA 
  INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1
  WHERE VBELN = '0000000220' AND PARVW = 'AG'.

Respect the field definitions and conversion-exits.

Regards

Former Member
0 Kudos

Hi Avannet

What about the error ?

still you are getting same errror or what??

Former Member
0 Kudos

Thanks Matt.

I used conversion routines suggested by you and now it starts working.

Again thanks a lot.