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

Urgent help required........

Former Member
0 Likes
933

Hi all,

I want some solution regarding truncation.

Currently I am having a variable A with data type NUMC (5).

If A =00000, then it should display blank

If A = 00006, then it should display only 6

If A = 00012, then it should display only 12.......and likewise.

Please provide me necessary solution.

Regards,

Mainak

Hi all,

I want some solution regarding truncation.

Currently I am having a variable A with data type NUMC (5).

If A =00000, then it should display blank

If A = 00006, then it should display only 6

If A = 00012, then it should display only 12.......and likewise.

Please provide me necessary solution.

Regards,

Mainak

8 REPLIES 8
Read only

Former Member
0 Likes
911

Hi,

Declare a variable with data type C for first value i,e to display space when it is 0000 and for other values display four variables with data type I and move the values accordingly and display them.

Regards,

Anji

Read only

Former Member
0 Likes
911

Take a look at the no-zero command.

Or you could move to a field of type C then do

SHIFT <FIELD> LEFT DELETING LEADING '0'.

Message was edited by:

Martin Shinks

Read only

Former Member
0 Likes
911

Hi,

You can use <b>write numc no-zero.</b> option.

Otherwise.

Do the following.

<b>DATA: CHAR(5) , N(5) TYPE N.

CHAR = N.

DO 5 TIMES.

IF CHAR+SYINDEX(1) = '0'.

CHAR+SYINDEX(1) = ' ' .

ELSE.

EXIT.

ENDDO.

CONDENSE CHAR.</b>

Reward if my answer helps you.

Regards,

Sandhya

Read only

Former Member
0 Likes
911

Hi,

There are 3 ways .

1. Use CONVERSION_EXIT_ALPHA_OUTPUT each time before you print it. along with no-zeroes option of write statement.

2. Change the datatype

3. Create one more variable of type i, and assign this variable a to newly created variable and then print newly created variable.

Hope that helps.

Regards

Kapadia

***Assigning points is the way to say thanks in SDN.***

Read only

Former Member
0 Likes
911

Execute the code .

data : a(5)  type n ,
        b(5) type c .

       a = b = '5'.

       write:/ a.
       write:/ b.

assign it to a char dataype and use this in the display instead of numc.

regards,

vijay

Read only

Azeemquadri
Contributor
0 Likes
911

data: a(5) type n.

a = 7.

write a no-zero.

output = 7.

Read only

Former Member
0 Likes
911

one option is move this value to character variable and replace all zeroes with spaces.

I mean :

data B(5) type c.

move a to b.

And then replace zeroes with spaces.

regards,

G@urav.

Read only

Former Member
0 Likes
911

one more variation is

<b>data : a(5) type n ,

b(5) type c .

a = b = '0'.

write:/ a no-zero. " you can use no-zero in the write

write:/ b.</b>