## String numeric value into pipe delimited without leading zeros?

## String numeric value into pipe delimited without leading zeros?

(OP)

How can I do this? I have a value defined pic 999.99 (or even zz9.99). If the value is 60.00 I need to string the value as

|60.00|

How do I do that in my string command? I always get |060.00| or | 60.00|

Thanks so much!

|60.00|

How do I do that in my string command? I always get |060.00| or | 60.00|

Thanks so much!

## RE: String numeric value into pipe delimited without leading zeros?

That gives you a result

then you move that result to PIC z that you made

so it looks like this:

WORKING-STORAGE SECTION.

01 first PIC 9(6).

01 second PIC 9(6).

01 result PIC 9(6).

01 displayResult PIC Z(6).

PROCEDURE DIVISION.

ADD first second GIVING result.

MOVE result to displayResult.

DISPLAY displayResult.

and i think that is it !

you always have to have one VARIABLE for DISPLAYING!

## RE: String numeric value into pipe delimited without leading zeros?

01 ws-hold-fine2 pic zz9.99.

Say the value is 10.00

The below code will look like

AAAAA|SDSSSS| 10.00|

The spaces is killing me!!! THANKS

move zeros to ws-hold-fine2.

move ws-hold-fine to ws-hold-fine2.

string 'AS' delimited by size

'|' delimited by size

cit-mag-no delimited by size

'|' delimited by size

new-cit-no delimited by size

'|' delimited by size

'Fine' delimited by size

'|' delimited by size

ws-hold-fine2 delimited by size

into courtrec.

## RE: String numeric value into pipe delimited without leading zeros?

Create several numeric working storage ranging from 1 to n number of digits depending on the maximum length of your variables. i.e.,

NUM1 PIC 9.99.

NUM2 PIC 99.99.

NUM3 PIC 999.99. and so on.

In your program logic you will have to test the result with something like below:

IF (RESULT < 10)

MOVE RESULT TO NUM1

DO STRING-ROUTINE

ELSE

IF (RESULT < 100)

MOVE RESULT TO NUM2

DO STRING-ROUTINE

ELSE

IF (RESULT < 1000)

MOVE RESULT TO NUM3

DO STRING-ROUTINE

ELSE

more testing here up to the maximum digits

END-IF.

## RE: String numeric value into pipe delimited without leading zeros?

I did this

01 ws-hold-fine2 pic 999.99.

01 ws-hold-fine3 pic x(6).

Then I did

move ws-hold-fine to ws-hold-fine2.

if ws-hold-fine2 (1:1) = '0'

move ws-hold-fine2 (2:5) to ws-hold-fine3

else

move ws-hold-fine2 to ws-hold-fine3.

Worked great...thanks for the help!

## RE: String numeric value into pipe delimited without leading zeros?

This also eliminates leading zeroes.

01 RESULT PIC 9(10)V99 VALUE ZEROES.

..RESULT above has 12 digits so in your logic do this

MOVE ZEROES TO I1.

MOVE ZEROES TO I2.

PERFORM VARYING I1 FROM 1 BY 1

UNTIL (I1 >= 12)

OR (I2 = 999)

IF (RESULT(I1) >= 1) AND (RESULT(I1) <= 9)

MOVE 999 TO I2

END-IF

END-PERFORM.

COMPUTE I2 = 12 - I6 + 1.

STRING SO AND SO DELIMITED BY SOMETHING

RESULT(I1:I2) DELIMITED BY SIZE

ETC.....

## RE: String numeric value into pipe delimited without leading zeros?

RESULT PIC 9(10).99 << 13 Char

MOVE ZEROES TO I1.

MOVE ZEROES TO I2.

PERFORM VARYING I1 FROM 1 BY 1

UNTIL (I1 >= 13)

OR (I2 = 999)

IF (RESULT(I1:1) >= 1) AND (RESULT(I1:1) <= 9)

OR (RESULT(I1:1) = ".")

MOVE 999 TO I2

END-IF

END-PERFORM.

COMPUTE I2 = 13 - I6 + 1.

STRING SO AND SO DELIMITED BY SOMETHING

RESULT(I1:I2) DELIMITED BY SIZE

ETC.....

## RE: String numeric value into pipe delimited without leading zeros?

This is incredibly simple to generate (one move versus an entire routine) and is completely workable on any target system that can handle |060.00| . . .

## RE: String numeric value into pipe delimited without leading zeros?

## CODE

05 filler pic x(01) value spaces.

05 mynum pic z(3)9. <---- this one change according to your needs.

01 my-sourcenum pic 9(4).

01 dummy pic x(30).

01 my-outputvar pic x(30)

...

move my-sourcenum to mynum

unstring varx delimited by all spaces into dummy my-outputvar

something similar to the above will give you what you want

Regards

Frederico Fonseca

SysSoft Integrated Ltd

www.syssoft-int.com

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?

FAQ181-2886: How can I maximize my chances of getting an answer?