cancel
Showing results for 
Search instead for 
Did you mean: 

CONCATENATE : Material with later "C"

0 Kudos
305

Hi ABAP Experts,

I have a requirement to CONCATENATE '0MATERIAL' transformation .

I have Material code starting number & character, where I have starting number I need to Add " C " in front of the code.

Eg: Material Code i have length 8, 12345678. I need the result like this C12345678.

I rote the below code, it is giving the result like this C00000000012345678 .

for business , it is very difficult to enter in selection screen.

How to get the result like this " C12345678 "

IF SOURCE_FIELDS-MATERIAL CO '0123456789'.
CONCATENATE 'C' SOURCE_FIELDS-MATERIAL+1(17) INTO RESULT.
ELSE.
RESULT = SOURCE_FIELDS-MATERIAL.
ENDIF.

Regards,

Jameel

View Entire Topic
0 Kudos

Thanks Ahmed. I will try.

since Material field length is 18 Char in BW, how the result will save in Table.

I am expecting leading zeros also , like this.

000000000C12345678

00000000C123456789

00000C123456789012

Regards,

Jameel

former_member187692
Participant
0 Kudos

Hello,

Initially remove leading zero and concatenate with 'C' and then add leading zero (or use a conversion routine).

SHIFT <field> LEFT DELETING LEADING '0'.
CONCATENATE 'C' <field> INTO <final>.

Adding leading zeros again, you can do a conversion routine.

CONVERSION_EXIT_<name>_INPUT

Eg:-

CONVERSION_EXIT_MATN1_INPUT

CONVERSION_EXIT_ALPHA_INPUT.

Note: You can also keep in mind about future S/4HANA migration and code accordingly (so when the material length changes you don't have to re-adjust your code again).

Warm Regards,

venkateswaran_k
Active Contributor
0 Kudos

Hi

Try similar to this way.

DATA : v_char(5) TYPE c VALUE 'C123456789012'.

SHIFT v_char RIGHT deleting trailing space.
translate v_char using ' 0'.
WRITE : v_char.

Regards,

Venkat

0 Kudos

Thanks Venkat,

I will try & let you know.

Regards,

Jameel