Read only Header and Trailer record from Input File

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
sunitha19
Member
Posts: 4
Joined: Sat Mar 12, 2016 11:30 pm

Read only Header and Trailer record from Input File

Post by sunitha19 » Sat Mar 12, 2016 11:39 pm

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

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sun Mar 13, 2016 12:29 pm

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.

sunitha19
Member
Posts: 4
Joined: Sat Mar 12, 2016 11:30 pm

Please provide the count logic0 for reading the last record

Post by sunitha19 » Sun Mar 13, 2016 3:59 pm

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

sunitha19
Member
Posts: 4
Joined: Sat Mar 12, 2016 11:30 pm

Please anyone help me on this

Post by sunitha19 » Mon Mar 14, 2016 9:55 am

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.

sunitha19
Member
Posts: 4
Joined: Sat Mar 12, 2016 11:30 pm

Please any one help me on this

Post by sunitha19 » Tue Mar 15, 2016 6:10 pm

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.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Mar 16, 2016 12:28 pm

AT END/NOT AT END are slovenly to use. Use the FILE STATUS on the SELECT and test that field.

Code: Select all

IF Header
    do header stuff
ELSE
IF Trailer
    do trailer stuff
OTHERWISE
    count the data records
END-OF-IFS
Do that as an evaluate. Or do exactly what I said earlier.

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