hi mergeing the seqfiles in cobol.. pls help me urgent...

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
abcdef1234
Member
Posts: 6
Joined: Mon Aug 27, 2007 2:39 pm

hi mergeing the seqfiles in cobol.. pls help me urgent...

Post by abcdef1234 » Mon Aug 27, 2007 3:04 pm

hi,

i am krishna,

i have a requirement like this.
i have 9 input put files with the same recordlayout like this.

header details

details records:

trailer details

in this each input sequntial files trailer details have TOT-AMT, TOT-RECS fields

here TOT-AMT specifies total amount value of detail records
TOT_RECS specifies number of details records
here we dont want any modifications on header details

now i want to merge tht total in put files into one output file.
in this out put file i want to calculate TOT-AMT, TOT-RECS values.
so pls send me code ASAP.

User avatar
DavidatK
Active Member
Posts: 65
Joined: Tue Mar 27, 2007 8:41 am
Location: Troy, MI USA

Post by DavidatK » Mon Aug 27, 2007 6:26 pm

Since this is in the COBOL forum, I need to ask, does this need to be done through a COBOL program? If not, and you have DFSORT, ask the question in the DFSORT forum. Frank Yeager is the guru of gurus and sure to have a solution. If this needs to be accomplished via COBOL code, plesae come back.

David,

abcdef1234
Member
Posts: 6
Joined: Mon Aug 27, 2007 2:39 pm

Post by abcdef1234 » Tue Aug 28, 2007 6:51 pm

hi david,

My requirement is to do this in cobol programonly,
for this iam trying with the following logic if any one good in login pls help me.

first in jcl i concatenate the all 9 files in to one mainfile.
next i am taking this mainfile as input into my cobol program
next i will careate one output file and will open these 2 files.
next i wll read mainfile and find the total and number of records
and moved into output file

in this pls ask any doubts

abcdef1234
Member
Posts: 6
Joined: Mon Aug 27, 2007 2:39 pm

Post by abcdef1234 » Tue Aug 28, 2007 6:51 pm

hi david,

My requirement is to do this in cobol programonly,
for this iam trying with the following logic if any one good in login pls help me.

first in jcl i concatenate the all 9 files in to one mainfile.
next i am taking this mainfile as input into my cobol program
next i will careate one output file and will open these 2 files.
next i wll read mainfile and find the total and number of records
and moved into output file

in this pls ask any doubts

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Tue Aug 28, 2007 11:56 pm

Krishna,

Find below the steps and some briefing on it as how to achieve what you have asked for.

Code: Select all

STEP1
********

YOU WILL CONCATENATE ALL THE 9 FILES INTO 1 OUTPUT FILE SO NOW WE HAVE ONLY ONE OUTPUT FILE.


STEP2
********

COBOL PROGRAM -> YOU WILL READ THE ABOVE I/P FILE.

LOGIC
********

READ EACH RECORD FROM THE INPUT FILE
 
THERE SHOULD BE SOME MEANS OF IDENTIFYING THE HEADER RECORD AND TRAILER RECORD.

MAY BE BY USING THE RECORD CODE OR SOME FIELD IDENTIFIER.

 
A -> WHEN YOU READ THE FIRST HEADER RECORD WRITE INTO OUTPUT  FILE AS IT IS.

B -> WHEN YOU READ OTHER RECORDS APART FROM HEADER AND TRAILER WRITE THE RECORDS AS IT IS.
   
-> YOU DON'T WANT TO CHANGE ANYTHING IN THESE DETAIL  RECS AS PER YOUR REQUIREMENT.

C -> NOW WHEN EVER YOU READ THE FIRST TRAILER REC MOVE RECORD TOTALLY INTO SOME WORKING STORAGE VARIABLES  AND HOLD THE ENTIRE DATA FOR THE TRAILER LAYOUT. 
               
NOTE : DO NOT WRITE THE RECORD JUST HOLD THE DATA IN SOME WORKING STORAGE HERE.

D -> NOW WHEN EVER YOU READ THE REST OF TRAILER RECS ,THAT IS YOU WILL HAVE REST 8  TRAILER RECORDS WHAT YOU DO IS ADD THE TOT-AMT AND TOT-RECS OF THAT PARTICULAR TRAILER RECORDS VALUES TO THE FIRST HOLD TOT-AMT AND TOT-RECS IN THE WORKING STORAGE.
 
 
E ->  KEEP WRITING THE OTHER RECORDS APART FROM TRAILER AND HEADER UNTIL YOU REACH END OF FILE.

F ->  WHEN YOU REACH THE END OF FILE, NOW WRITE THE LAST REC THAT IS ONE TRAILER RECORD FOR THE ENTIRE FILE FROM HOLD VARIABLES FROM THE WORKING STORAGE WHICH HAS THE ENTIRE TRAIILER RECORD LAYOUT. 

( AND WE ALSO HAVE TOT-AMT AND TOT-RECS OF ALL THE 9 TRAILER RECORDS ACCUMULATED).

GET BACK TO US IF IN CASE YOU NEED SOME MORE INFO.

Thanks,
Veera.

User avatar
DavidatK
Active Member
Posts: 65
Joined: Tue Mar 27, 2007 8:41 am
Location: Troy, MI USA

Post by DavidatK » Sun Sep 02, 2007 11:00 pm

abcdef1234,

Sorry it took so long to get back to you. Looks like your logic and Veera's Pseudo logic will work fine, unless you need the detail records inside to be in order, and then you will need other, merge logic.

Does it matter the order the detail records are in? In our shop, I cannot think of an occurrence that it does not matter.

David

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others