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: 

Convert value from CHAR 35 to CHAR10 in SELECT statement

Hi All,

I am fetching one field from DB table which is of length CHAR35 and I want to use the same in another SELECT statement via FOR ALL ENTRIES where field name of 10 character is being compared with field of 35 characters.

I don't want to use offset method but wanted to convert CHAR35 field into CHAR10 field using CAST operator in SELECT statements. I searched couple of threads on SDN but couldn't help.

Can anyone suggest.

Thanks !!

3 REPLIES 3

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

btp_rap
You can try using the LEFT function in the SELECT statement to convert the CHAR35 field into a CHAR10 field. This will extract the 10 leftmost characters of the CHAR35 field and return it as a CHAR10 field. Syntax:


SELECT LEFT(<char35_field>, 10) 
FROM <table_name>


For example:
SELECT LEFT(field_name_35, 10) 
FROM table_name

Sandra_Rossi
Active Contributor
0 Kudos

What is your ABAP version?

0 Kudos

TYPES: BEGIN OF ys_demo,

material TYPE char10,
END OF ys_demo.

DATA: lt_mat TYPE TABLE OF ys_demo.

START-OF-SELECTION.

SELECT matnr AS material FROM mara INTO TABLE lt_mat.