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: 

Retaining leading zero after sum operation

Former Member
0 Kudos
484

I have a variable g = 00000005. Now when I am adding g = g + 1.

The result is coming 6 but without leading zeroes.How could I retain leading zero after sum operation.

8 REPLIES 8

Former Member
0 Kudos
320

Hi,

Call conversion aplha exit after u get the value as 6.

Former Member
0 Kudos
320

hello

use this FM CONVERSION_EXIT_ALPHA_OUTPUT.

to over come this ..

Thank u

santhosh

0 Kudos
320

I have used it but before i had 5 leading zeros after 6 eg 000006 but after using this function module it is giving 00000000000006..which is not required.

0 Kudos
320

hi,

got it...

we have fm with same name CONVERSION_EXIT_ALFAN_OUTPUT i think u r using this check it properly it will work....

USE THIS CONVERSION_EXIT_ALPHA_OUTPUT

Edited by: santhosh kumar on Dec 4, 2008 6:41 AM

0 Kudos
320

Hi Priya,

Use TYPE N

DATA
     : VAL1(6)  TYPE N VALUE '000001'.

DO 10 TIMES.

VAL1 = VAL1 + 1.

WRITE / VAL1.

ENDDO.

Regards

former_member632729
Contributor
0 Kudos
320

Hi Priya,

Declare the g as type N.. then do sum.. okay..

ex :

data : d(7) type n value '0000005'.

g = g + 1.

write : g.

output is : 0000006.

Raghunath.S

Former Member
0 Kudos
320

Hi Priya,

Please declare variable g as a numeric of length 8(you can change the length as per the requirement).

Data g(8) type n.

Now if you add 1 to variable g which is 0000005, you will get the result as 0000006. Please try this out.

Thanks,

Deepthi

Former Member
0 Kudos
320

REPORT ZSRK_077 .

DATA : G(14) VALUE '000005',

LEN TYPE I.

FIELD-SYMBOLS : <FS_G> TYPE N.

LEN = STRLEN( G ).

ASSIGN G+0(LEN) TO <FS_G> CASTING TYPE N.

<FS_G> = <FS_G> + 1.

WRITE : / 'FS_G = ' , <FS_G>,

/ 'G = ' , G.