Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with fixing output, low-values maybe?

Status
Not open for further replies.

wolves

Programmer
Jan 26, 2001
130
US
Have some output from a program that I add '-' in between my numbers to make it a '-' delimited file that I load into an access database, anyway, I move field by field from the input file to the output file. All fields in the output file are pic -------9.99.

Some of the fields in my output look like this:
0.00- 0.00- ...........- 0.00- 0.00-

The .........- is what concerns me.

Do I need to move my field into an alpha field, then move low-values into my output field first?

Kind of lost.
 
Please show us the appropriate file/record definitions and code segment where you are moving data into the file's record before the write.

Tom Morrison
 
Hi Wolves,

You've posted this problem in another forum and it didn't contain enough detail there either.

As Tom suggested, just provide the relevant WS and PD code with a brief verbal description of the problem, I'm sure someone here then will be able to help you solve it.

Regards, Jack.
 
Are you sure the input fields are all numeric ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Will post the FD and the WS as soon as I am able to get the code again. Monday morning

Thx in advance.
 
Here is the info: As you can see, even though this is not lined up correctly, but if you would paste it to word or notepad, you will see that THIS-FIELD4 comes out a little messed up, cannot figure out why. The input file is sometimes 0, or spaces, either way, it is messed up.

Thx

WORKING-STORAGE SECTION.
01 PROGRAM-NAME PIC X(08).

01 WS-WORK-AREA.
05 Field-x PIC 9(6).
05 Field-xx PIC 9(5).
05 Field-xxx PIC S9(15)V9(02).
05 EOF PIC X VALUE 'N'.


COPY INPUT-STRUC.
(01 INPUT-REC.
05 THIS-FIELD PIC X(6).
05 IN-MONETARY-FIELDS.
10 THIS-FIELD2 PIC S9(9)V99 COMP-3.
10 THIS-FIELD3 PIC S9(9)V99 COMP-3.
10 THIS-FIELD4 PIC S9(9)V99 COMP-3.
10 THIS-FIELD5 PIC S9(9)V99 COMP-3.)

COPY OUTPUT-STRUC.
(01 OUTPUT-REC.
05 THAT-FIELD PIC X(6).
05 OUT-MONETARY-FIELDS
10 THAT-FIELD2 PIC --------9.99.
10 FILLER PIC X(01) VALUE '~'.
10 THAT-FIELD3 PIC --------9.99.
10 FILLER PIC X(01) VALUE '~'.
10 THAT-FIELD4 PIC --------9.99.
10 FILLER PIC X(01) VALUE '~'.
10 THAT-FIELD5 PIC --------9.99.
10 FILLER PIC X(01) VALUE '~'.)

MAINLINE

PERFORM 1000-FIRST
PERFORM 2000-FILE UNTIL EOF=’Y’

MAINLINE-EXIT.
EXIT.


1000-FIRST

READ INFILE INTO INPUT-STRUC
AT END MOVE 'Y' TO EOF
GO TO 1000-FIRST-EXIT
END-READ

FIRST-EXIT.
EXIT.

2000-FILE
INITIALIZE OUTPUT-STRUC
MOVE THIS-FIELD TO THAT-FIELD
MOVE THIS-FIELD2 TO THAT-FIELD2
MOVE THIS-FIELD3 TO THAT-FIELD3
MOVE THIS-FIELD4 TO THAT-FIELD4
MOVE THIS-FIELD5 TO THAT-FIELD5
WRITE OUTREC FROM OUTPUT-STRUC
READ INFILE INTO INPUT-STRUC
AT END
MOVE 'Y' TO EOF
GO TO 2000-MAIN-PROCESS-EXIT
END-READ.
2000-FILE-EXIT.
EXIT.


OUTPUT

THIS-FIELD THIS-FIELD2 THIS-FIELD3 THIS-FIELD4 THIS-FIELD5
AAAAAA 0.00~ 0.00~ ..............~ 0.00~
BBBBBB 0.00~ 0.00~ ..............~ 0.00~
CCCCCC 0.00~ 0.00~ ..............~ 0.00~
DDDDDD 0.00~ 0.00~ ..............~ 0.00~


 
Based on what you've shown, I'd have to say that THIS-FIELD4 is not a valid COMP-3 value on the input file.

Regards.

Glenn
 
At first glance, I would think that you do not have valid numeric COMP-3 data in THIS-FIELD4. Have you been able to run this with a debugger? You might want to try something like this:
Code:
if THIS-FIELD4 numeric
    MOVE THIS-FIELD4         TO THAT-FIELD4
else
    move "nonumeric" to THAT-FIELD4(1:)
end-if

By the way, the mechanism for getting pretty code like to appear is to bracket your code with [tt][ignore]
Code:
...
[/ignore][/tt] TGML markup tags.


Tom Morrison
 
Here are my displays in the program:
NOTE: Here is the new copybooks. I printed a typo. The FIELD5 and is 11 places before the decimal not 9 like the others.

Code:
COPY INPUT-STRUC.
    (01   INPUT-REC.
  	05   THIS-FIELD          	 PIC X(6).
        05 IN-MONETARY-FIELDS.
  	   10   THIS-FIELD2    	 PIC S9(9)V99 COMP-3.
  	   10   THIS-FIELD3	 PIC S9(9)V99 COMP-3.
  	   10   THIS-FIELD4	 PIC S9(9)V99 COMP-3.
           10   THIS-FIELD5	 PIC S11(9)V99 COMP-3.)
  	   
 COPY OUTPUT-STRUC.
    (01   OUTPUT-REC.
  	05  THAT-FIELD              PIC X(6).
        05  OUT-MONETARY-FIELDS
  	    10   THAT-FIELD2 	 PIC --------9.99.
  	    10   FILLER          PIC X(01) VALUE '~'.
  	    10   THAT-FIELD3     PIC --------9.99.
  	    10   FILLER          PIC X(01) VALUE '~'.
  	    10   THAT-FIELD4 	 PIC --------9.99.
  	    10   FILLER          PIC X(01) VALUE '~'.
            10   THAT-FIELD5	 PIC ----------9.99.
  	    10   FILLER          PIC X(01) VALUE '~'.)

DISPLAYS:

THIS-FIELD2
00000000000
THAT-FIELD2
0.00

THIS-FIELD3
00000000000
THAT-FIELD3
0.00

THIS-FIELD4
00000000000
THAT-FIELD4
0.00

THIS-FIELD5
0000000147868
THAT-FIELD5
1478.68

OUTPUT FILE:

0.00~ 0.00~ 0.00~..............~ 1478.68~

There is something going on between field4 and field5 that I cannot figure out. The input fields look OK and are numberic, the outputs are OK, except between 4 and 5?

 
What COBOL compiler are you using? What hardware/operating system?
 
Where is your output file being sent? How are you viewing it? Is there a chance the output line length is longer than your terminal definition and you're a victim of wraparound or an imbedded Carriage-Return?

Glenn
 
I am using a COBOL 85 mainframe compiler on a S/390 using OS390.
 
I am on a mainframe using OS390. I am viewing in a SDSF window. I am just tabbing over (F11) to get to where I want to see. I don't it's wraparound, imbedded Carriage Return is something though to think about
 
There could be a problem in your buffer area or a problem with the characteristics of your file (your file definition).

About your FD areas:
If I calculated correctly your FD record size should be:

Code:
WORKING-STORAGE SECTION.

FD  MY-INPUT-FILE
    LABEL RECORDS STANDARD.
01  MY-INPUT-RECORD.
  05  MY-INPUT-DATA          PIC X(30).

FD  MY-OUTPUT-FILE
    LABEL RECORDS STANDARD.
01  MY-INPUT-RECORD.
  05  MY-INPUT-DATA          PIC X(54).

Also:
The contents of the fields in error may give you a clou of what the problem is.

If you have a hex editor you can see the hex (or binary) value of the fields in error.
I assume you don't have a hex editor.

When you don't have a hex editor then you may be able to read these files (using a little program) into a binary field and then display the numeric contents. Something like this:

Code:
01  myData.
  05  dumpField.
    10  binaryZeroField  PIC  X(02) VALUE
                               LOW-VALUES.
    10  theFieldInError  PIC  X(06).
  05  REDEFINES  dumpField.
    10  theBinaryValue   PIC  9(09) BINARY.
  05  theDecimalValue    PIC  9(09).

* I assume that PIC 9(09) BINARY takes 8 bytes!!!
* (which should be correct!).

PROCEDURE DIVISION

* read the field in error and you must do an
* alphanumeric move in order not to change the
* bit pattern!!!
MOVE  field-4(1:6) TO  theFieldInError

* the next move is not really necessary, 
* but now you can save this value
* in a file in display format!
MOVE  theBinaryValue  TO  theDecimalValue
DISPLAY theDecimalValue

* to 'see' the hex (or binary) value use the 
* calculator from your windows desktop
* (or whatever operating system you are working on)
* There are other ways to do this...
* This is just one way of making the
* binary contents visible.
* (e.g. see intrinsic bit manipulation)

Regards, Wim.
 
You should be able to use IDCAMS to dump the file in hex to confirm field content.

Glenn
 
If you're using OS/390 are you using ISPF as your editor? If ISPF, ANY file opened in "EDIT" (menu item 2) can be viewed in HEX by typing "HEX" on the command line. "HEX OFF" resets it.

Hope this simplifies things.

Make friends with your edtor!

TLogan
The Man with a Snappy Moniker
 
You said it was an access file.
Therefore I assume you are on a PC
and do not have the ISPF editor mentioned
(there is a PC version but it is a commercial product).

You can scan the internet and download a free version of a text editor with hex(display) capabilities.
And browse the file as suggested by 3gm and tlogan.
Or use the code fragment (or something similar) I suggested earlier.


Regards, Wim Ahlers.
 
I am going to load the file into access, but for now, it's a file on a mainframe.

Well, thanks all for all the advice, found the issue with your help. Transfering the file to a hex editor I was able to see the NULL value that did not belong throwing the output off. Live and learn. Thanks for helping out an amateur. Problems and mistakes are a great learning tool.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top