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

Table Select

Former Member
0 Likes
759

How Do Everyone.

I have declared a Field symbol <compare_field> type c.

I have then assigned a char(10) input field to this

field symbol.

The problem I am now facing is I am trying to select

from the table KNA1 for the matching customer no.

i.e.

SELECT SINGLE *

FROM

kna1

WHERE

kunnr = <compare_field>.

e.g. Customer No held on KNA1 Table is '0002000001'

My <compare_field> doesn't contain leading zeroes, it

has '2000001' stored in it. As a consequence it is saying

that the customer does not exists in the above statement,

when it clearly does. But if through SE11 I enter 2000001

the customer appears.

Can anyone explain this to me.

Cheers

Andy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
731

HI Andy,

Use the fm CONVERSION_EXIT_ALPHA_INPUT before you use that var in the select.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting input = <compare_field>

importing output = <compare_field>.

SELECT SINGLE *

FROM

kna1

WHERE

kunnr = <compare_field>.

7 REPLIES 7
Read only

FredericGirod
Active Contributor
0 Likes
731

Hi,

KUNNR is a CHAR length 10.

and ' 2000001' is different from '0002000001'.

so declare your field-symbols as type CHAR.

Rgd

Frédéric

Read only

Former Member
0 Likes
732

HI Andy,

Use the fm CONVERSION_EXIT_ALPHA_INPUT before you use that var in the select.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting input = <compare_field>

importing output = <compare_field>.

SELECT SINGLE *

FROM

kna1

WHERE

kunnr = <compare_field>.

Read only

Former Member
0 Likes
731

Hi andy,

1. Automatic conversion

2. The reason is the field which is ASSIGNED to field symbol

<b>is declared as type c,</b>

hence, automatic conversion

(ie. adding zeroes to the left when fetching from sql)

does not happen AUTOMATICALLY,

3. so that EXACT MATCH is not found.

4.<b> If the original field is declared

like KNA1-KUNNR,

THEN IT WILL WORK FANTASTIC.

</b>

*------- SEE THIS CODE - JUST COPY PASTE AND TRY

REPORT abc.

PARAMETERS : a LIKE kna1-kunnr.

*PARAMETERS : a(10) TYPE C. "<---- WON'T WORK

DATA : kna1 LIKE TABLE OF kna1 WITH HEADER LINE.

FIELD-SYMBOLS : <abc> LIKE kna1-kunnr.

ASSIGN a TO <abc>.

SELECT * FROM kna1

INTO TABLE

kna1 WHERE kunnr = <abc>.

BREAK-POINT.

regards,

amit m.

Message was edited by: Amit Mittal

Read only

Former Member
0 Likes
731

did u try casting

Assign char to <compare_field> casting .

Read only

Former Member
0 Likes
731

Hi Andy,

Before going to select,pass the feld symbol value to the FM CONVERSION_EXIT_ALPHA_INPUT,which will add the leading zeros to the field value.

The reason why the table selects the values in SE11 if you enter without zeros is it has the conversion inbuilt.You can see that if you go to the DOMAIN of the KUNNR.If you see the definition of the domain,there exists a Conversion routine field which has value as ALPHA.If you double click you will know the FM used in the background when you check for the values in SE11.

Message was edited by: Phani Kiran Nudurupati

Read only

Former Member
0 Likes
731

Hello,

you could use the function module 'CONVERSION_EXIT_ALPHA_INPUT'. Should solve your problem.

Regards Wolfgang

Read only

0 Likes
731

Thanks guys for you help, much appreciated.

I used the FM 'CONVERSION_EXIT_ALPHA_INPUT'

as suggested.