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: 

Separation and joining of CHAR variables ?

Former Member
0 Kudos

Hello SDN community,

I have the following problem:

my report has two CHAR variables, one has the LENGTH 10, the other has the LENGTH 2. The CHAR variable with the LENGTH 10 always begins with two zeros. I want to cut this two zeros out of the CHAR 10 variable and put the 2 figures from the CHAR 2 variable instead. How to do this?

Example:


DATA : char10 TYPE c LENGTH 10,
             char2   TYPE c LENGTH 2.

char10 = 0005632345.
char2  = 99.

first step => split char10 into 00 and 05632345

second step => replace 00 with 99 ( = char2 )

third step => join 99 and 05632345

I hope all of you understood my question

Thank you for your answers (:

Best regards,

Marius

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

data:lv_1 type char10,

data:lv_2 type char02.

lv_1 = '0012345678'.

lv_2 = 'AB'.

lv_1+0(2) = lv_2.

4 REPLIES 4

kesavadas_thekkillath
Active Contributor
0 Kudos

data:lv_1 type char10,

data:lv_2 type char02.

lv_1 = '0012345678'.

lv_2 = 'AB'.

lv_1+0(2) = lv_2.

Former Member
0 Kudos

Hello try this,


DATA : char10 TYPE c LENGTH 10,
             char2   TYPE c LENGTH 2
 
char10 =  '0005632345'.
char2  = '99'.

concatenate char2 char10+2(8) into char10.

write: char10.

Vikranth

0 Kudos

Thank you two, you're great

0 Kudos

hey, not to forget REPLACE with REGEX


REPLACE REGEX '^00' IN char10 WITH char2. " replace leading '00'
REPLACE REGEX '^0{2}' IN char10 WITH char2. " replace leading two '0'
REPLACE REGEX '^.{2}' IN char10 WITH char2. " replace leading two char

regards, Karsten