Ryan Lopez
Ryan Lopez

Reputation: 49

Remove extra spaces while fetching data from database

I just would like to ask if there's a way or it's possible to remove this spaces while comparing it at the same time in Select statement?

enter image description here

Maybe an error during the uploading process or encoding.

select DISTINCT z~mandt z~bukrs z~evbeln z~vbeln
z~fkdat z~vblstat z~zprn z~uname z~type v~werks
into corresponding fields of table zvbelnexttab
from zvbelnext as z inner join vbrp as v on z~vbeln = v~vbeln
WHERE z~vbeln IN vbeln
AND v~vbeln in vbeln
AND z~evbeln IN evbeln
AND z~fkdat  IN fkdat
AND v~werks IN werks
and z~uname IN uname
AND z~vblstat IN vblstat
and z~bukrs in bukrs order by z~evbeln ascending.

My task is to compare the range of evbeln that I will enter in the selection parameter. but it wouldn't show anything because of the extra spaces.

Upvotes: 1

Views: 1506

Answers (1)

Suncatcher
Suncatcher

Reputation: 10621

ABAP OpenSQL functions are available since Netweaver release 7.50 and what Florian says (it cannot be done with OpenSQL) is simply not true.

It can be done on recent ABAP releases with LTRIM and RTRIM:

SELECT DISTINCT LTRIM( z~evbeln,' ' ) AS trimmed
FROM zvbelnext
...

On older releases you have to think out alternative approaches.

Upvotes: 4

Related Questions