Please provide logic to read only header and trailer record from input file and write into Output File.
Step 1: Read Header record (Always first record is header)
Step 2: For Header record Process the logic
Step 3: Write all Detail records as it is into Output File without processing any logic
Step 4: For Trailer Record Process the logic, and write the count into the Output File as one field in Output Trailer record (Note: Output Trailer record layout is different from Input Trailer record Layout)
Please any one help me on this where we have to process only first and last records only
Read only Header and Trailer record from Input File
Moderators: dbzTHEdinosauer, Moderator Group
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Please provide the count logic0 for reading the last record
Thank you for reply. Please send me count logic or let me know whether the below logic works:
READ INPUT-FILE INTO INPUT-REC
AT END
MOVE 'Y' TO EOF
ADD 1 TO COUNT1
MOVE COUNT-1 TO TOTAL-COUNT
NOT AT END
ADD 1 TO COUNT -1
IF EOF AND COUNT-1 = TOTAL-COUNT
PERFORM PROCESS-LAST-RECORD-PARA
ELSE
PERFORM WRITE-RECORD-PARA
END-IF
READ INPUT-FILE INTO INPUT-REC
AT END
MOVE 'Y' TO EOF
ADD 1 TO COUNT1
MOVE COUNT-1 TO TOTAL-COUNT
NOT AT END
ADD 1 TO COUNT -1
IF EOF AND COUNT-1 = TOTAL-COUNT
PERFORM PROCESS-LAST-RECORD-PARA
ELSE
PERFORM WRITE-RECORD-PARA
END-IF
Please anyone help me on this
William Collins wrote:Take a "normal" program which processes header, details and trailer. In the "process details" simply write the record out. Remembering that I assume you count the records anyway.
Please any one help me on this
William Collins wrote:Take a "normal" program which processes header, details and trailer. In the "process details" simply write the record out. Remembering that I assume you count the records anyway.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
AT END/NOT AT END are slovenly to use. Use the FILE STATUS on the SELECT and test that field.
Do that as an evaluate. Or do exactly what I said earlier.
Code: Select all
IF Header
do header stuff
ELSE
IF Trailer
do trailer stuff
OTHERWISE
count the data records
END-OF-IFS
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page