2010 Jul 01 6:48 AM
Hi,
I am adding char field to char field, but if field1 has preceeding zero's and when we add field2 to it the zero's are removed , how to take care of this. zeros can vary from 1 to any number of preceding zero
ie.
field1(40) type c.
field2(2) type c.
field1 = '035567011'.
field2 = '11'.
field1 = field1 + field2
currently I have the result field1 = 35567022, but I need the result as field1 = 035567022
please suggest how to do this.
thanks
bobby
2010 Jul 01 7:01 AM
count = 0.
do 15 times.
if field1+0(1) = '0'.
shift field1 left.
concateante count ' 0'.
else.
exit.
endif.
enddo.
then after adding ur filedls concatenae count with field1
2010 Jul 01 7:06 AM
Hi Bobby,
Use the Function Module CONVERSION_EXIT_ALPHA_INPUT to add leading zeroes to the result.
Regards
Sajid
2010 Jul 01 7:07 AM
2010 Jul 01 7:10 AM
Hello
data: field1(40) type c.
data: field2(2) type c.
data: len1 type i.
data: len2 type i.
field1 = '00035567011'.
len1 = strlen( field1 ).
shift field1 left deleting leading '0'.
len2 = strlen( field1 ).
len1 = len1 - len2.
field2 = '11'.
field1 = field1 + field2.
shift field1 left deleting leading space.
do len1 times.
concatenate '0' field1 into field1.
enddo.
write field1.
2010 Jul 01 7:15 AM
Hi Bobby,
This is a FAQ. Please search in SCN before Posting.
Use Conversion_exit_alpha_input. Function Module.
With Regards,
Sumodh.P
2010 Jul 01 7:36 AM
HI Bobby,
Declare one more variable as N.... as shown below... This will solve your requirent.
DATA:
field1(40) TYPE c,
field2(2) TYPE c,
field3 TYPE N LENGTH 9.
field1 = '035567011'.
field2 = '11'.
field3 = field1 + field2.
WRITE field3.
please let me know if that solved your problem.
Thanks
Suraj