×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

floating trailing sign

floating trailing sign

floating trailing sign

(OP)
I have a signed input field, PIC 9(12)V9(6).

I have no problem converting this to a leading and trailing zero suppressed field for example -
Input - 000000000123.450000 Output 123.45
However, I do have a problem when it's signed. For instance, if I define the output as PIC Z(11)9.9(6)-,
the result is 123.450000-, NOT the result I would like - 123.45-, (or input = -12.4567 output = 12.4567-).  
Obviously, I can achieve the above by loads of code, but does anyone know if it's possible to get the desired result by simply using editting symbols ?     

RE: floating trailing sign

I'm not sure if it is possible to abbreviate Z(11) in
PIC Z(11)9.9(6)-
instead of using
ZZZZZZZZZZZ9.9(6)-

But I use similar display variable with trailing sign with the picture
PIC ZZZ.ZZZ.ZZZ.ZZZ.ZZ9,99-
and after moving in it e.g -1234,56 the output is correct, i.e. 1.234,56-  
However I'm using DECIMAL-POINT IS COMMA
  

RE: floating trailing sign

There is no standard way to achieve this result as zero-supressing from the right is not a standard function in COBOL.  Excel would do this, but we are not talking Excel.  

The way I would do it is with sub-string notation in a perform loop.  I can't think of anything easier.

RE: floating trailing sign

The following code snippet does roughly what you want.  You'd have to change it some if you didn't want the sign immediately after the decimal point or if you wanted a minimum number of decimal positions.

CODE

        IDENTIFICATION DIVISION.
        PROGRAM-ID. TEST-PROG.
        DATA DIVISION.
        01  WS-FIELD                      PIC Z(9)9.9(6)-.
        01  WS-TALLY                      PIC S9(4) COMP-5.
        PROCEDURE DIVISION.
        0000-PARA.
            MOVE -123.4 TO WS-FIELD
            COMPUTE WS-TALLY = LENGTH OF WS-FIELD - 1
            PERFORM VARYING WS-TALLY FROM WS-TALLY BY -1 UNTIL
                WS-FIELD(WS-TALLY:1) NOT EQUAL "0"
                MOVE WS-FIELD(WS-TALLY + 1:1) TO WS-FIELD(WS-TALLY:2)
            END-PERFORM
            DISPLAY WS-FIELD
            GOBACK
            .

Regards,

Glenn

RE: floating trailing sign

(OP)
Thanks to everyone for taking the time to reply.

I have plumped for Glenn's solution, as this seems the closest to my requirements.

Thanks again

David

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