Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replicating records ina flat file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jayakrishnan.h

New User


Joined: 14 Aug 2007
Posts: 1
Location: kochin

PostPosted: Wed Mar 09, 2011 12:18 am    Post subject: Replicating records ina flat file
Reply with quote

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
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1753
Location: Bloomington, IL

PostPosted: Wed Mar 09, 2011 12:22 am    Post subject:
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Mar 09, 2011 12:50 am    Post subject:
Reply with quote

Just how is the process to determine what the million acct numbers are the other undefined field.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 09, 2011 1:05 am    Post subject:
Reply with quote

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
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Mar 09, 2011 2:39 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 09, 2011 3:13 am    Post subject: Reply to: Replicating records ina flat file
Reply with quote

Thanks RB - i missed the last line of the initial post. . . icon_redface.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us