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!

PICTURE clause 4

Status
Not open for further replies.

tubiron

MIS
Apr 24, 2003
5
US
Can someone explain why a field defined with this
02 C-AMOUNT PIC S9(6)V99.

shows up with wierd character. This should be numeric
but I'm getting something like this: 0000732{
in the field.

thanks

 
David,

However, the UNSTRING you provided in the previous example made no mention of WS-IDX-FILE-NBR-FIELD. Indeed the results you are showing would indicate that WS-IDX-FILE-NBR-FIELD is not involved at all.

Tom Morrison
 
True. The example of code was for the app I wrote to read from a comma delimited file and write the records to an indexed file.

I was testing with another COBOL app to then read from my index file and output to a different sequential file. I thought trimming leading zeroes was done simply by using 'Z' in the PIC clause of a field. But, for some reason I'm still getting the zeros.

Basically, the code for this test app involves reading the index file record and then writing out from the WS fields...

MOVE IDX-FILE-NBR-FIELD TO WS-IDX-FILE-NBR-FIELD
WRITE OUT-SEQ-REC FROM WS-IDX-REC.

 
Okay.
WORKING STORAGE.
01 WS-FILE-FIELDS.
03 WS-IDX-FILE-KEY PIC 9(11).
03 WS-FIELD1 PIC X(10).
03 WS-FIELD2 PIC X(10).
03 WS-FILE-NBR-FIELD PIC Z9(6)V9(2).
...etc

DATA DIVISION.

(input record file - index file that I wrote to on previous job step; defined exactly as is in previous job step)

FD IDX-FILE-REC.
01 IDX-FILE-FIELDS.
03 IDX-FILE-KEY PIC 9(11).
03 FIELD1 PIC X(10).
03 FIELD2 PIC X(10).
03 IDX-FILE-NBR-FIELD PIC S9(6)V9(2).
...etc
...........................

(output record - test to see that my data in above index file is being stored properly)

FD SEQ-FILE-REC PIC X(250).

PROCEDURE DIVISION.

READ IDX-FILE-REC NEXT RECORD
AT END GO TO END-JOB
NOT AT END PERFORM OUTPUT-RESULTS
END-READ.

OUTPUT-RESULTS.
MOVE IDX-FILE-FIELDS TO WS-FILE-FIELDS.
WRITE SEQ-FILE-REC FROM WS-FILE-REC.

I've been looking at WS-FILE-NBR-FIELD PIC Z9(6)V9(2)
in WORKING STORAGE. I've tried it this way and as
WS-FILE-NBR-FIELD PIC S9(6)V9(2), but I still get the leading zeroes showing up in my output record.
0002250{

Thanks.
-David

 
MOVE IDX-FILE-FIELDS TO WS-FILE-FIELDS

is a group move. Group moves do not reformat the elementary fields inside the groups. You must move each elementary field, one at a time.
 
Tom, Webrabbit,

I kept my code the same, except I added the line below to test Webrabbit's suggestion and it still does not trim off the leading zero. I do the group move, but then I do an individual move after the group move. I still get the leading zeros showing up for the WS-FILE-NBR-FIELD on my test output.

Recap defined fields:
File field...
03 IDX-FILE-NBR-FIELD PIC S9(6)V9(2).
WS field...
03 WS-FILE-NBR-FIELD PIC Z(6)V9(2).

OUTPUT-RESULTS.
MOVE IDX-FILE-FIELDS TO WS-FILE-FIELDS.
MOVE IDX-FILE-NBR-FIELD TO WS-FILE-NBR-FIELD
WRITE SEQ-FILE-REC FROM WS-FILE-REC.

 
David,

From a previous post you showed:
Code:
01 WS-FILE-FIELDS.
      03 WS-IDX-FILE-KEY PIC 9(11).
      03 WS-FIELD1   PIC X(10).
      03 WS-FIELD2   PIC X(10).
      03 WS-FILE-NBR-FIELD  PIC Z9(6)V9(2).

But you are doing this:
WRITE SEQ-FILE-REC FROM WS-FILE-REC.

Could this be the source of the confusion??

Tom Morrison
 
Sorry about that.
WRITE SEQ-FILE-REC FROM WS-FILE-REC
should be
WRITE SEQ-FILE-REC FROM WS-FILE-FIELDS.
 
01 WS-MAKER-REC.
02 WS-MAKER-PRIME-KEY PIC 9(11).
FD SEQ-FILE
01 SEQ-FILE-REC PIC X(365).

WORKING STORAGE is...

02 WS-MAKER-FIELDS.
03 WS-MAKER-CONAME PIC X(30).
03 WS-MAKER-ADDRESS1 PIC X(30).
03 WS-MAKER-ADDRESS2 PIC X(30).
03 WS-CITY PIC X(30).
03 WS-STATE PIC X(2).
03 WS-ZIP PIC 9(9).
03 WS-MAKER-PHONE PIC 9(12).
03 WS-MAKER-CONTACT PIC X(20).
03 WS-MAKER-COMMENTS PIC X(30).
03 WS-MAKER-ACCT PIC 9(16).
03 WS-MAKER-SW1 PIC X(1).
03 WS-MAKER-ABA PIC 9(9).
03 WS-MAKER-LIMIT PIC 9(6).
03 WS-MAKER-CHRG-PERC PIC 9(5).
03 WS-MAKER-OPEN-DATE PIC 9(8).
03 WS-MAKER-TYPE PIC 9(4).
03 WS-MAKER-WAIVE-CHRG-SW PIC X(1).
03 WS-MAKER-AVG-SIZE PIC Z(6)V9(2).
03 WS-MAKER-NBR-C PIC 9(7).
03 WS-MAKER-AVG-SIZE-P PIC S9(6)V9(2).
03 ...
03 ...
 
Sorry...

FD SEQ-FILE
01 SEQ-FILE-REC PIC X(365).

WORKING STORAGE is...
01 WS-MAKER-REC.
02 WS-MAKER-PRIME-KEY PIC 9(11).
02 WS-MAKER-FIELDS.
03 WS-MAKER-CONAME PIC X(30).
03 WS-MAKER-ADDRESS1 PIC X(30).
03 WS-MAKER-ADDRESS2 PIC X(30).
03 WS-CITY PIC X(30).
03 WS-STATE PIC X(2).
03 WS-ZIP PIC 9(9).
03 WS-MAKER-PHONE PIC 9(12).
03 WS-MAKER-CONTACT PIC X(20).
03 WS-MAKER-COMMENTS PIC X(30).
03 WS-MAKER-ACCT PIC 9(16).
03 WS-MAKER-SW1 PIC X(1).
03 WS-MAKER-ABA PIC 9(9).
03 WS-MAKER-LIMIT PIC 9(6).
03 WS-MAKER-CHRG-PERC PIC 9(5).
03 WS-MAKER-OPEN-DATE PIC 9(8).
03 WS-MAKER-TYPE PIC 9(4).
03 WS-MAKER-WAIVE-CHRG-SW PIC X(1).
03 WS-MAKER-AVG-SIZE PIC Z(6)V9(2).
03 WS-MAKER-NBR-C PIC 9(7).
03 WS-MAKER-AVG-SIZE-P PIC S9(6)V9(2).
03 ...
03 ...




 
What is the definition of WS-FILE-NBR-FIELD? At one point you show it as Z9(6)V9(2) and in another you show it as
Z(6)V99. If it is the first, that's why you have leading zeroes. You're only suppressing one zero followed by 6 digits left of the decimal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top