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

SAP Script : Split an element and concatinate

Former Member
0 Likes
901

Dear All,

In SAP script, I have to split a text element into 2 parts, eg &matnr&, and then concatinate these 2 elements with a constant value in between how can I do that

To make clear say my Matnr is 12345678, I need an output like 1234 USA 5678. please suggest me in doing this.

Thanking you.

Regards

Venkat.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
770

Your character indexing is wrong.

For example A+2(3) means 3 characters in field A starting after the character 2.

So you should be using

&REGUH-ZALDT(2)& &REGUH-ZALDT2(2)& &REGUH-ZALDT4(2)&

Regads,

Nagaraju Chidurupalli.

6 REPLIES 6
Read only

LucianoBentiveg
Active Contributor
0 Likes
770

You need to call a subroutine with:

PERFORM rutine IN PROGRAM zprogram.

USING &MATNR&

CHANGING &NEW_MATNR&

ENDPERFORM.

Read only

Former Member
0 Likes
770

Did you try this..

&matnr(4)& USA &matnr+4&

Regards,

Nagaraju Chidurupalli

Read only

Former Member
0 Likes
770

Hi venkat,

If you want to dynamically split the material no. then you have to use a routine in the form & create a program & do that...

/:PERFORM SPLIT_MAT IN PROGRAM Z_SPLIT

/: USING &MATNR&

/: CHANGING &MAT1&

/:ENDPERFORM.

Or if you know where to split..like after first 4 characters..etc then try to use the below statements to do so...

MATNR+4& Offset - Output begins here. Offset refers to formatted value

&MATNR(5)& Length - Output data in the specified length

Message was edited by: Phani Kiran Nudurupati

Read only

0 Likes
770

Dear Peluku, Nag & Phani,

Thanks for your information, I got it solved !

I am trying other one, but unable to get right output.

I would like to split date into Day, month and year.

So I am doing so.

but it is not working, year field shows only 1char.

/: Set date mask = 'DDMMYY'

&REGUH-ZALDT(2)& &REGUH-ZALDT3(2)& &REGUH-ZALDT5(2)&

Please let me know, where is the mistake.

Thanking you.

Regards

Venkat.

Read only

Former Member
0 Likes
771

Your character indexing is wrong.

For example A+2(3) means 3 characters in field A starting after the character 2.

So you should be using

&REGUH-ZALDT(2)& &REGUH-ZALDT2(2)& &REGUH-ZALDT4(2)&

Regads,

Nagaraju Chidurupalli.

Read only

0 Likes
770

Dear Nag,

Thanks for quick info. problem Solved.

Thank you once again.

Closing thread, alloating points.

Regards

Venkat