View previous topic :: View next topic |
Author |
Message |
kavya Beginner
Joined: 22 Sep 2005 Posts: 12 Topics: 8
|
Posted: Thu Sep 22, 2005 1:51 am Post subject: co sequetial processing |
|
|
hi every one
i got a master file and hundreds of transaction files , based on the transaction file information i need to update the master file and store the output in seperate file i have to do it through cobol..waiting for ur reply  |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Thu Sep 22, 2005 2:53 am Post subject: |
|
|
kavya,
This seems to be some hands on exercise given to you. In long run, it would not be good for you if we give you the answer right away. All we can do is to guide you. You have to try and design the code yourself.
Okay.. First of all, I believe your master file is a VSAM KSDS. Transaction file must be a flat file - PS.
Declare your file-section as shown below.
Code: |
FILE-CONTROL.
SELECT I-TRAN ASSIGN TO UT-S-ITRAN.
SELECT I-MASTER ASSIGN TO IMASTER
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS MASTER-KEY
FILE STATUS IS WS-MASTER-STAT.
|
Make sure you declare a 2 byte (X(02)) variable to capture the file-status of Master file (WS-MASTER-STAT). You need to declare this in Working-Storage section.
Then code your FD Section in Data Division. I have assumed that your master file and transaction file - both have an LRECL of 300.
Code: |
DATA DIVISION.
FILE SECTION.
*
FD I-TRAN
LABEL RECORDS ARE STANDARD.
01 I-TRAN-REC PIC X(300).
*
FD I-MASTER
LABEL RECORDS ARE STANDARD.
01 WS-MASTER-RECORD PIC X(300)
|
You may have to define item-level variables under I-TRAN-REC Group variable to define the individual fields. You can define this either in working-storage section under a new 01 Group variable or have it defined in FD section itself.
Procedure Division:
Code: |
*----- Open all files ----------*
OPEN INPUT I-TRAN
I-O I-MASTER
*----- Read input Tran file -----*
PERFORM 1000-READ-TRAN-FILE THRU
1000-EXIT UNTIL WS-TRAN-EOF
*----- Close all Files -----*
CLOSE I-TRAN
I-MASTER
STOP RUN.
1000-READ-TRAN-FILE.
* ---- Code your READ Statement here ---- *
* ---- Check for End-of-File Condition. If not EOF then go to ---- *
* ---- 2000-process-para -----*
1000-EXIT.
EXIT.
2000-PROCESS-PARA.
*------ Move data from Transaction file to Key field of MASTER ---- *
*------ READ Master file ------ *
READ I-MASTER
INVALID KEY
Display ' Key Not Found ....'
*------ Insert New Record into Master - From Transaction file ----*
*------ Move all fields to corresponding Master file fields ----- *
WRITE WS-MASTER-RECORD
*------ Check if File-status = 0, Else Display Error Msg -------*
NOT INVALID KEY
*----- Update Master file contents if Key Matches -----*
*----- Move/Update/Compute values in master file -----*
REWRITE WS-MASTER-RECORD
*------ Check if File-status = 0, Else Display Error Msg -------*
END-READ.
2000-EXIT.
EXIT.
|
Now, you have to build on this and complete the coding.
Hope this helps,
Thanks,
Phantom |
|
Back to top |
|
 |
ANIL SARATHY Beginner

Joined: 30 Aug 2005 Posts: 88 Topics: 3 Location: Syracuse,New york
|
Posted: Thu Sep 22, 2005 3:15 am Post subject: |
|
|
"hundreds of transaction files"........ is it files or records.
Phantom has given almost the code.
if flat files are used as master and transaction, sort both the files before you start and compare each record in one with other file. _________________ Anil Sarathy |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
|
|