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

Convert value during a join statement

david_nguyen3
Explorer
0 Likes
3,344

Hi folks,

Is there a way to convert value of a table field during a select statement? I have a sql statement that doesn't work because a field has zero characters prefix.

SELECT EBANBANFN EBANBNFPO EBANSTATU EBANBSART EBANMENGE EBANLFDAT EKKOAEDAT EKKOEBELN EKKO~LIFNR

INTO TABLE GT_RFQ_DATA

FROM EBAN JOIN EKKO ON EKKOSUBMI = EBANBANFN

EBANBANFN = '0003006807' and EKKOSUBMI = '3006807'

Is it possible to do a join with that condition? Will reward points.

Note: I know how to get those data without a join, so I will not give out reward points for those advices.

Thanks for all of your helps.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,054

Try using the fucntion module CONVERSION_EXIT_ALPHA_INPUT to pad with leading Zeros

if you want to convert the value of

EKKOSUBMI = '3006807' to EKKOSUBMI = '0003006807'

or if you want to remove leading zeros

use CONVERSION_EXIT_ALPHA_OUTPUT function module.

Data: v_submi like ekko-submi.

v_submi = '3006807'

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = v_submi

IMPORTING

OUTPUT = v_submi

EXCEPTIONS

OTHERS = 1.

SELECT EBANBANFN EBANBNFPO EBANSTATU EBANBSART EBANMENGE EBANLFDAT EKKOAEDAT EKKOEBELN EKKO~LIFNR

INTO TABLE GT_RFQ_DATA

FROM EBAN JOIN EKKO ON EKKOSUBMI = EBANBANFN

EBANBANFN = '0003006807' and EKKOSUBMI = v_submi

7 REPLIES 7
Read only

Former Member
0 Likes
2,054

Before passing values to SELECT, try using conversion routines. That will help to extract data correctly. (If i have correctly understood your problem).

Read only

0 Likes
2,054

Hi Ashish,

the values are unknown before SELECT and they are in 2 table EKKO, EBAN as you see in the SELECT. Therefore , there are no way to get value and convert it before SELECT.

Thanks.

Read only

Former Member
0 Likes
2,055

Try using the fucntion module CONVERSION_EXIT_ALPHA_INPUT to pad with leading Zeros

if you want to convert the value of

EKKOSUBMI = '3006807' to EKKOSUBMI = '0003006807'

or if you want to remove leading zeros

use CONVERSION_EXIT_ALPHA_OUTPUT function module.

Data: v_submi like ekko-submi.

v_submi = '3006807'

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = v_submi

IMPORTING

OUTPUT = v_submi

EXCEPTIONS

OTHERS = 1.

SELECT EBANBANFN EBANBNFPO EBANSTATU EBANBSART EBANMENGE EBANLFDAT EKKOAEDAT EKKOEBELN EKKO~LIFNR

INTO TABLE GT_RFQ_DATA

FROM EBAN JOIN EKKO ON EKKOSUBMI = EBANBANFN

EBANBANFN = '0003006807' and EKKOSUBMI = v_submi

Read only

0 Likes
2,054

Hi Sid,

Thanks for your help. But the thing is that i want to <b>join EBAN with EKKO on the condition

EKKOSUBMI = EBANBANFN.</b> The example values is to show the difference between those values. I want to get a result set that match the condition not just one record.

Read only

0 Likes
2,054

In this case i think there is no way to fetch the data with join statment as the value in one table is padded with leading 0's and in other table it is padded with leading 0's.

Read only

0 Likes
2,054

I am thinking the same way to but I just want to investigate it. Thanks for your help.

Read only

0 Likes
2,054

Sid is right. As the link between 2 tables is not clear. One table field is padded with zeros and second is not padded with zeroes.

Just to try - can you see with LIKE in WHERE condition if it helps.