Charater Alignment



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Charater Alignment

Postby cooldude14344 » Fri Mar 11, 2011 2:53 am

Friends

Our requirement is show the percentages with four decimal places, which would get printed in document.

The percentage variable must be a character field x(7) otherwise the printing system won't work.
when it get printed it prints as below

percentage1 23.5666%
percentage1 23.5666%
percentage1 3.56%

i would like to print it as below, so the decimal (.) comes in a same line.
percentage1 23.5666%
percentage1 23.5666%
percentage1 3.56%

please let me know how to achieve this.
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Charater Alignment

Postby BillyBoyo » Fri Mar 11, 2011 3:06 am

What "printing system" is this?

If you have an X(7), where does the "%" sign get into it (which would make it 8 characters long). I think your "printing system" is doing something (removing leading space) - unless you are populating the field with "unstring" and inadvertantly removing the leading space youself. Still don't understand how the % would fit in.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Charater Alignment

Postby cooldude14344 » Fri Mar 11, 2011 3:13 am

It is CSF, the % will be a static one in print composition. so passing the variable will be enough.
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Charater Alignment

Postby BillyBoyo » Fri Mar 11, 2011 3:32 am

OK, so what is CSF? What does it say about dropping leading spaces, or to put it another way, left-aligning fields. I guess if you are telling something that is formatting the print for you, there is documentation telling you how to right-align it. However, something has also dropped the lesser-significant zeros in one of your examples, so you'll have to stop it doing that as well, because if you right-align it still won't line up.

Perhaps you can centre it?

By the way, unless it is reading your source, I don't see how it would have to be PIC X(x). You could make it a numer-edited picture, anything you are calling won't know PIC ZZ.9999 from PIC X(7) (unless it is looking at your source).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Charater Alignment

Postby cooldude14344 » Fri Mar 11, 2011 3:49 am

It is a document composition tool used for align the documents. The dynamic values are passed as a parameters, unfortunately it only accepts character variables.
So left and right alignment won't look good if the percentage is a single digit. but in cobol can we do some kind of formating which would print the decimal points all at the same line?

Percentage 1 - 23.5666%
Percentage 2 - 3.5%
but it prints as
Percentage 2 - 3.5% which is left aligned.
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Charater Alignment

Postby BillyBoyo » Fri Mar 11, 2011 4:34 am

OK, I don't know what you have in your program, I don't know CSF, and I don't know what you mean by having to pass character values (a numeric edited field will look exactly the same as a character field when you pass it as a parameter, unless for some obtuse reason the package you are using is working off the source code).

If you have PIC Z9.9999 and you "DISPLAY" all of your test data after it has been put in the field, you will get the results you want in Cobol, except for the case of dropping trailing zeros, which, if you really want it, you'd have to do some extra code for.

You can move this PIC Z9.9999 (maybe try PIC Z9.99ZZ, dunno, never thought of it til now... no idea) to the PIC X9(7) field.

I suspect, however, that you will get the same problem. What should be straightforward isn't working. The format of the print is incorrect, and you are passing the data to a print formatting utility. Without seeing any code, my guess is it is the print formatting utility, ie the parameters that you are passing it to tell it how to print the fields (or default parameters if you are passing nothing).

If you like, please include the relevant cobol code and however it is that you execute the formatting utility. Or wait for someone who knows CSF, which I don't.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Charater Alignment

Postby dick scherrer » Fri Mar 11, 2011 10:00 am

Hello,

You can move this PIC Z9.9999 (maybe try PIC Z9.99ZZ, dunno, never thought of it til now... no idea) to the PIC X9(7) field.
Or you might redefine the edited field with the pic x field. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Charater Alignment

Postby cooldude14344 » Fri Mar 11, 2011 2:36 pm

I will give a try and come back to you guys..thanks
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Charater Alignment

Postby Zio69 » Fri Mar 11, 2011 2:42 pm

(maybe try PIC Z9.99ZZ, dunno, never thought of it til now... no idea)


Nope, no can do. Once you start with significative digits you must go on. Besides, once you've reached the decimal point it all becomes significative (at least as long as we're talking about COBOL/ASM/EZT).
Zio69
 
Posts: 31
Joined: Wed Feb 16, 2011 7:08 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post