×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

String numeric value into pipe delimited without leading zeros?

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!

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

First you should compute what you need.
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?

(OP)
Maybe I am missing something?

       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?

Pic zzz99.99 is still treated as character and you will get the blank fill if you use it in a string statements. Here's what I usually do to eliminate blanks:

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?

(OP)
OK, I got it...

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?

A better method is to search for the occurrence of blanks in a numeric variable. This way you only need one working storage.
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?

Sorry my finger is fast..
 
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?

Why does someone believe  |060.00|  is a problem?

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

01 varx.
   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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close