Solved

Edited Numeric fields in COBOL

Posted on 2003-12-01
8
3,074 Views
Last Modified: 2013-11-13
hi,

i'm quite new to COBOL and i have a bit of a problem. I have the following fields:

01 NUM1 PIC S9(13)V9(2).
01 NUM2 PIC -Z(12)9.99.
01 TXT1 PIC X(15).
01 COMMENT PIC X(257).

NUM1 is populated by some process, and is copied into NUM2.

I am using COMMENT for the primary output, which contains "XXXXXXXXXXXXXX, -0.00"
where XXXXXXXXXXXXXX comes from TXT and -0.00 should come from NUM2 (using the STRING command)

however, if the value in NUM2 is less than 15 characted long, eg. -12.34.....the value in COMMENT becomes:

"XXXXXXXXXXXXXX,-          12.34"

now, is there some other way to make the output similar to this:

"XXXXXXXXXXXXXX,-12.34"??

thanks
0
Comment
Question by:logbook
  • 4
  • 3
8 Comments
 
LVL 15

Accepted Solution

by:
Raisor earned 250 total points
ID: 9856778
Hi,

Have you tried the INSPECT verb to edit the 15 digit numeric field in the input record to produce the desired number format on the output file?

Best regards, Raisor
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9860242
logbook,

Try changing

01 NUM2 PIC -Z(12)9.99.

to

01 NUM2 PIC -(13)9.99.

Dang123
0
 
LVL 9

Assisted Solution

by:Dang123
Dang123 earned 250 total points
ID: 9860636
logbook,

This may help you if you want to pull the number up against the string.

http://dbforums.com/arch/91/2003/1/666266

Dang123
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 15

Expert Comment

by:Raisor
ID: 9861177
Hi,

@Dang123 ... your link http://dbforums.com/arch/91/2003/1/666266 links to the same suggestion as mine: "Have you tried the INSPECT verb to edit the 15 digit numeric field in the input record to produce the desired number format on the output file?" What I see is that your link comes with some good examples!


Your question should be answered now, logbook!


Best regards, Raisor
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9861236
Raisor,
    The link I posted wasn't meant to overstep your suggestion, there are a number of solutions on the page. I haven’t needed to left justify a number before (and still don't) so I only took a quick look at the page. Sorry, didn't mean to offend.

    Your right though, between our suggestions logbook should be able to get the program working.

Dang123

0
 
LVL 15

Expert Comment

by:Raisor
ID: 9861389
Hi,

Well I’m sorry, Dang123, I absolutely didn’t want to express that I felt offended … there seems to be a misunderstanding!

What I was up to say was that I think I gave a hint to the right direction but that you gave the better examples.

My conclusion though was the same as yours: “between our suggestions logbook should be able to get the program working” …


Best regards, Raisor
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9861451
Raisor,
    Thanks, I wasn't sure if you were upset or not, I glad you not.

logbook,
    How are you making out with your program? Have you gotten closer to what you need?

Dang123


0
 

Author Comment

by:logbook
ID: 9989246
sorry i wasnt able to get back to this question since i posted it....

thanks for the help guys, but i was able to accomplish it using an unstring - string algo a friend came up....

cheers
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question