‎2008 Dec 04 7:13 AM
I have to add 2 variable like N000000006 AND N000000001, so that i get the result N000000007.
I tried out with soo many method, removing leading N , THEN 0 but still I am not able to get this result.
‎2008 Dec 04 7:16 AM
Remove 'N' and after that move rest number to other variable which if of type Interger and then add two variables. Again concatenate 'N' and sum and move that to original variable.
Regards,
Aparna.
‎2008 Dec 04 7:21 AM
Hi Priya..
Whats the datatype of N000000006 and N000000001.....
Regards
‎2008 Dec 04 7:23 AM
data : var1(10) type c,
var2(10) type c,
l_result type i,
l_char(9) type c,
l_digits type i.
var1 = 'N000000001'.
var2 = 'N000000006'.
l_result = var1+1(9) + var2+1(9).
l_char = l_result.
condense l_char no-gaps.
l_digits = strlen( l_char ).
l_digits = 9 - l_digits.
check l_digits > 0.
do l_digits times.
concatenate '0'
l_char
into l_char.
condense l_char no-gaps.
enddo.
concatenate 'N'
l_char
into l_char.
condense l_char no-gaps.Regards,
Mohaiyuddin
‎2008 Dec 04 7:26 AM
I have to add 2 variable like N000000006 AND N000000001, so that i get the result N000000007.
I tried out with soo many method, removing leading N , THEN 0 but still I am not able to get this result.c
First remove the N, by using var11(9) and var21(9)
Then remove leading zeroes
Then use WRITE statement : WRITE var3 (TYPE C) to var4 (TYPE P)
Then add the two variables
Then convert result to type C using WRITE var5 (TYPE P) to var6(TYPE C)
Then add leading zeroes
Then add leading N
Thats it really !!!!
‎2008 Dec 04 7:26 AM
Hi,
try this
parameters:
p_num1(10) type c,
p_num2(10) type c.
data:
w_val1(9) type n,
w_val2(9) type n,
w_result(9) type n,
W_final(10) type C.
w_val1 = p_num1+1.
w_val2 = p_num2+1.
w_result = w_val1 + w_val2.
concatenate 'N' w_result into W_final.
write:W_finalPut any NXXXXXXXXX number of 9 digit in the parameters you will get your desired result.
Regards,
Anirban
‎2008 Dec 04 7:38 AM
DATA: l_input1(10) TYPE c VALUE 'N000000001',
l_input2(10) TYPE c VALUE 'N000000006',
l_output(10) TYPE c.
DATA: l_output1(9) TYPE n,
l_output2(9) TYPE n,
l_output3(9) TYPE n.
SHIFT l_input1 LEFT DELETING LEADING 'N'.
SHIFT l_input2 LEFT DELETING LEADING 'N'.
MOVE l_input1 to l_output1.
MOVE l_input2 to l_output2.
l_output3 = l_output1 + l_output2.
CONCATENATE 'N' l_output3 INTO l_output.
WRITE: l_input1, l_input2.
WRITE: l_output1, l_output2, l_output3.
*MOVE l_output3 to l_output.
WRITE: l_output.
‎2008 Dec 04 8:22 AM
Hi Priya,
try this out
DATA : var TYPE string VALUE 'N000000006',
var1 TYPE string VALUE 'N000000001',
str(10)," TYPE string,
str1(10)," TYPE string,
str2(10), "TYPE string,
len TYPE i.
len = STRLEN( var ) - 1.
str = var+0(1).
str1 = var+1(len).
len = STRLEN( var1 ) - 1.
str = var+0(1).
str2 = var1+1(len).
DATA : str3(10)." TYPE string.
str3 = str1 + str2.
data len2 type i.
*CONCATENATE str str3 INTO str.
len2 = strlen( str3 ).
len = len - 1.
condense str3 no-gaps.
data : new(10).
do len times .
concatenate '0' new into new.
enddo.
concatenate str new str3 into str.
IF sy-subrc IS INITIAL.
ENDIF.
regards
Ramchander Rao.K