cobol db2 subroutine not finding existing record

In this Mainframe Forum - You can post your queries on JCL,VSAM,COBOL,DB2,IMS Abend codes , solutions etc..

Moderator: Moderator Group

Post Reply
bjbedoe
Member
Posts: 2
Joined: Fri Oct 12, 2012 10:24 pm

cobol db2 subroutine not finding existing record

Post by bjbedoe » Fri Oct 12, 2012 10:44 pm

Code: Select all

 I'm running db2 subroutines in cobol environment.  The first time the subroutine is called the record is found.  The second time the record is not found even though it exists on the table. It doesn't matter if I'm calling the same record again or a different one. If i cancel between subroutine calls, the record is found the second time through, but there are other reasons I don't want to cancel the subroutine each time.  Any ideas on why this is happening and what can be done to correct it?  

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

Post by DikDude » Fri Oct 12, 2012 11:08 pm

Sounds like the subroutine is not working with the proper value(s) the second time thru.

How is the continuity being controlled between the calls?
Have a good one

bjbedoe
Member
Posts: 2
Joined: Fri Oct 12, 2012 10:24 pm

Post by bjbedoe » Sat Oct 13, 2012 12:24 am

I've explained this badly. What I've got is a program A, calling subprogram B which calls subprogram Z, program A also calls subprogram C which calls subprogram Z. My problem is Z appears to work correctly except that any db2 select statements return +100 when called from C.

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

Post by DikDude » Sat Oct 13, 2012 12:47 am

Suggest you put in some diagnostic code to ensure that all is as expected just before the problem call to db2.

Still sounds like there is a mixup between what B presents to Z and what C presents to Z. (i've typed this wrong 3 times so far. . . )

Are the sql return code(s) being checked after every db2 interaction in each module?
Have a good one

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

Post by William Collins » Sat Oct 13, 2012 3:31 am

Are your compile options the same for all three modules? Can you show them, please?

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Sat Oct 13, 2012 5:09 am

are your host variables in Z part of the linkage section?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

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