Cobol question

cobol interview questions

Moderator: Moderator Group

Post Reply
st_vineela
Member
Posts: 3
Joined: Sun Nov 13, 2011 6:04 pm

Cobol question

Post by st_vineela » Sun Nov 13, 2011 7:41 pm

There is a PS file that gets created everyday with one record and with a character 'A' in it in different positions. How to write a cobol logic to find it's position in the file?

st_vineela
Member
Posts: 3
Joined: Sun Nov 13, 2011 6:04 pm

Post by st_vineela » Sun Nov 13, 2011 7:42 pm

The character 'A' occurs only once per record but it's position changes everyday..

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Nov 13, 2011 8:35 pm

You could use a loop starting at the first byte and counting the positions until the A is found or the end of record is reached.
or
You could use INSPECT/TALLYING. Read here:
http://publibz.boulder.ibm.com/cgi-bin/ ... r50/6.2.21
Have a good one

st_vineela
Member
Posts: 3
Joined: Sun Nov 13, 2011 6:04 pm

Post by st_vineela » Sun Nov 13, 2011 9:49 pm

Thanks for the reply. INSPECT works on string right.. How should it be used for the whole record?

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Nov 13, 2011 9:52 pm

COBOL does not have data "strings" - it has fields.

If you want to inspect an entire record, refer to the 01 level name (field).
Have a good one

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