View previous topic :: View next topic
|
Author |
Message |
jayakrishnan.h
New User
Joined: 14 Aug 2007 Posts: 1 Location: kochin
|
|
|
|
Hi I have a file with 1 header 1 footer and 1 detailed record.
I want to replicate only the detailed record to say 1 million times with same data except 2 fileds unique(acct number and another field ), remaining all fileds in the detailed record should be same.
So my output file should have 1 header, 1 footer and 1 million detailed record.
Can someone tell me the cobol code for this? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Yes, but given that you can't even be bothered to post in the correct forum it is unlikely that anyone will. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Just how is the process to determine what the million acct numbers are the other undefined field. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
First - you need to learn that JCL cannot do this. . . Never has , never will. JCL EXECutes things. That is all it does.
This may be done using some utility (like the sort) or code you have written. Neither is JCL. . .
Which release of which sort product is used on your system?
And one the tool has been decided, you need to answer Craig's question:
Quote: |
Just how is the process to determine what the million acct numbers are the other undefined field. |
|
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Since you asked for a COBOL solution, here is some COBOL Pseudo-code I quickly cobbled together - Assumes that both Acct Number and Other Field are numeric, and can accommodate numbers up to and including one million - adjust as needed.
Code: |
Be sure to specify the FILE STATUS clause in the SELECTs pointing to STATUS-CODE
Define FD's for your INPUT-FILE with INPUT-HEADER, INPUT-DETAIL, and INPUT-TRAILER
and your OUTPUT-FILE with OUTPUT-HEADER, OUTPUT-DETAIL, and OUTPUT-TRAILER (with the fields to be overlaid defined as well)
In the WORKING-STORAGE SECTION:
define SW-IP-OPEN with a PICTURE of X.
define SW-OP-OPEN with a PICTURE of X.
define SW-ERROR with a PICTURE of X.
define STATUS-CODE with a PICTURE of XX.
define SUB-SCRIPT with a PICTURE of S9(9) COMP.
In the PROCEDURE DIVISION:
MOVE 'N' TO SW-ERROR
OPEN INPUT INPUT-FILE
IF STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR OPENING INPUT-FILE'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'N' TO SW-IP-OPEN
MOVE 'Y' TO SW-ERROR
ELSE
MOVE 'Y' TO SW-IP-OPEN
OPEN OUTPUT OUTPUT-FILE
IF STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR OPENING OUTPUT-FILE'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'N' TO SW-OP-OPEN
MOVE 'Y' TO SW-ERROR
ELSE
MOVE 'Y' TO SW-OP-OPEN
READ INPUT-FILE
AT END
DISPLAY 'INPUT FILE IS EMPTY'
MOVE 'Y' TO SW-ERROR
END-READ
IF SW-ERROR = 'N' AND
STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR READING HEADER RECORD'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'Y' TO SW-ERROR
END-IF
END-IF
END-IF
IF SW-ERROR = 'N'
THEN
MOVE INPUT-HEADER TO OUTPUT-HEADER
WRITE OUTPUT-HEADER
IF STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR WRITING HEADER RECORD'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'Y' TO SW-ERROR
ELSE
READ INPUT-FILE
AT END
DISPLAY 'INPUT FILE CONTAINS NO DETAIL RECORDS'
MOVE 'Y' TO SW-ERROR
END-READ
IF SW-ERROR = 'N' AND
STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR READING DETAIL RECORD'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'Y' TO SW-ERROR
END-IF
END-IF
END-IF
IF SW-ERROR = 'N'
THEN
PERFORM
VARYING SUB-SCRIPT
FROM 1
BY 1
UNTIL SW-ERROR = 'Y' OR
SUB-SCRIPT > 1000000
MOVE INPUT-DETAIL TO OUTPUT-DETAIL
MOVE SUB-SCRIPT TO ACCT-NUMBER OF OUTPUT-DETAIL
MOVE SUB-SCRIPT TO OTHER-FIELD OF OUTPUT-DETAIL
WRITE OUTPUT-DETAIL
IF STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR WRITING DETAIL RECORD # ' SUBSCRIPT
DISPLAY 'STATUS-CODE WAS ' STATUS-CODE
MOVE 'Y' TO SW-ERROR
END-IF
END-PERFORM
END-IF
IF SW-ERROR = 'N'
THEN
READ INPUT-FILE
AT END
DISPLAY 'INPUT TRAILER RECORD MISSING'
MOVE 'Y' TO SW-ERROR
END-READ
IF SW-ERROR = 'N' AND
STATUS-CODE NOT = '00'
THEN
DISPLAY 'ERROR READING TRAILER RECORD'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'Y' TO SW-ERROR
END-IF
END-IF
IF SW-ERROR = 'N'
THEN
MOVE INPUT-TRAILER TO OUTPUT-TRAILER
MOVE 1000000 TO TRAILER-COUNT OF OUTPUT-TRAILER
WRITE OUTPUT-TRAILER
IF STATUS-CODE NOT = '00'
DISPLAY 'ERROR WRITING TRAILER RECORD'
DISPLAY 'STATUS CODE WAS ' STATUS-CODE
MOVE 'Y' TO SW-ERROR
END-IF
END-IF
IF SW-OP-OPEN = 'Y'
THEN
CLOSE OUTPUT-FILE
END-IF
IF SW-IP-OPEN = 'Y'
THEN
CLOSE INPUT-FILE
END-IF
GOBACK. |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Thanks RB - i missed the last line of the initial post. . .
d |
|
Back to top |
|
|
|