Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Calling DB2 subroutine from online COBOL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Tue Oct 16, 2012 9:23 pm    Post subject: Calling DB2 subroutine from online COBOL program
Reply with quote

Hi,

Please help me in resolving this issue.
From an online COBOL program (having type as CO3C), I am calling a subroutine that has DB2 statements (compiled as CO3C2 with COBOL-DB2-CICS compiler).
Since it threw abend 4068 at the time the subroutine is called, I have added the address / pointer to the main program and then made the call. However the main program was not able to make the addressability.

Main program

Code:
WORKING STORAGE SECTION.

COPY <map copybook>
01 WS-MAP REDEFINES ZZMAPI.   <= Mapset

01  WS-LENGTH       PIC S9(9)     COMP-4.           
01  WS-LOW-VALUE        PIC X(1)      VALUE LOW-VALUES.
01  WS-ADDR-COMP        PIC S9(08)    COMP.             
01  WS-ADDR-PNTR        REDEFINES WS-ADDR-COMP         
                        USAGE IS POINTER.               

LINKAGE SECTION.

01  DFHCOMMAREA             PIC X(3000).
01  LS-COMMAREA REDEFINES DFHCOMMAREA.
    05  COMM-AREA.
       ...
       10 COMM-MAP-ADDRESS     PIC S9(8) COMP.
       10 COMM-MAP-LENTH       PIC S9(4) COMP.


PROCEDURE DIVISION
   EXEC CICS HANDLE CONDITION ERROR (9999-RETURN) END-EXEC.           
   MOVE LENGTH OF ZZMAPI TO WS-LENGTH.   
   MOVE WS-LENGTH TO WS-MAP-LENGTH.       
   EXEC CICS GETMAIN SET (ADDRESS OF ZZMAPI)
                         INITIMG (WS-LOW-VALUE)   
                         LENGTH (WS-MAP-LENGTH)   
   END-EXEC.                 
   SET WS-ADDR-PNTR   TO ADDRESS OF ZZMAPI. 
   MOVE WS-ADDR-COMP  TO COMM-MAP-ADDRESS.         <= Errors as ASRA (PROTECTION EXCEPTION) at this statement
   MOVE WS-MAP-LENGTH TO COMM-MAP-LENGTH. 

   CALL <subroutine>  USING DFHEIBLK,                 
                            DFHCOMMAREA,             
                            WS-DSNTIAR,               
                            WS-ACCOUNT.



Subroutine

Code:
LINKAGE SECTION

01 WS-DSNTIAR.
     ...

01 WS-ACCOUNT          PIC 9(6).

PROCEDURE DIVISION USING WS-DSNTIAR,               
                         CIUCDRCA-IU-CDR-COMMAREA,
                         WS-ACCOUNT.



Thanks
Vinu
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Oct 16, 2012 9:30 pm    Post subject: Reply to: Calling DB2 subroutine from online COBOL program
Reply with quote

Quote:
From an online COBOL program (having type as CO3C), I am calling a subroutine that has DB2 statements (compiled as CO3C2 with COBOL-DB2-CICS compiler).


please refrain from using local jargon, it adds nothing to the info You provide
we do not belong to Your organization, so we do not what compilation process is used by types CO3c/CO3C2 ( endevor/changeman jargon)

the abend occurs before the <subroutine> is called,
what happens if You eliminate all the references to the <subroutine>
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Oct 16, 2012 9:33 pm    Post subject:
Reply with quote

The first time you invoke the transaction, there is no DFHCOMMAREA associated with the transaction. Hence any attempt to reference LINKAGE SECTION items will fail with a storage violation since you don't have access to that storage (since it does not exist). Only after you have done START TRANSID(xxxx) COMMAREA(3000-byte WORKING-STORAGE variable) and the program does EXEC CICS RETURN will you be able to reference DFHCOMMAREA the second time the program runs.

Many CICS programs start IF EIBCALEN = 0 to test for this condition and proceed from there.
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Tue Oct 16, 2012 9:35 pm    Post subject:
Reply with quote

Sorry for that.
The main program is compiled with COBOL CICS compiler
The sub routine is compiled as COBOL-DB2-CICS compiler eventhough no CICS statement is used.

Initially I tried to execute the subroutine without any reference to subroutine. At this scenario, IF EIBCALEN works fine and it only abends at the call statement of subroutine as Error - LE/370 4038.



Thanks
Vinu
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Tue Oct 16, 2012 9:43 pm    Post subject:
Reply with quote

Initially the main program was like this when I called subroutine without any reference to it. The abend occured at the point where the subroutine was called.

Code:
WORKING STORAGE SECTION.

01  WS-COMMAREA
     COPY <map communication area>

COPY <map copybook>
01 WS-MAP REDEFINES ZZMAPI.   <= Mapset

LINKAGE SECTION.

01  DFHCOMMAREA             PIC X(3000).

PROCEDURE DIVISION
   IF EIBCALEN = 0                                       
       call the screen map
   ELSE                                                 
       MOVE DFHCOMMAREA (1:EIBCALEN)       TO WS-COMMAREA
   END-IF.                                               

   CALL <subroutine>  USING DFHEIBLK,                 
                                DFHCOMMAREA,             
                               WS-DSNTIAR,               
                               WS-ACCOUNT.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Oct 16, 2012 9:54 pm    Post subject:
Reply with quote

Hello,

Suggest you look for a similar process that is already workking on your system and then see what was done differently in the one that works.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Oct 16, 2012 10:04 pm    Post subject: Reply to: Calling DB2 subroutine from online COBOL program
Reply with quote

once in a while I do not blame or beat up the TS, he is just the victim

of the morons in the command/planning/design/support chain in his organization

looks like they do not know how to prototype the infrastructure

discover the most common situations of the development process
and for each one define the standards, the code snippets the <build> procedures

and above all the DOCUMENTATION
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Tue Oct 16, 2012 10:34 pm    Post subject:
Reply with quote

Ok Thanks. I will check that.

Can I know whether the subroutine that has only DB2 statements should be compiled with COBOL-DB2 compiler instead of COBOL-DB2-CICS compiler. I am trying to understand the difference it makes when this subroutine is called from COBOl-CICS main modules ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Oct 16, 2012 10:47 pm    Post subject:
Reply with quote

There is only ONE compiler (that you need worry about) - the COBOL compiler. The CICS an DB2 stuff is done by pre-compilers which, as the name suggests, execute before the compiler.

Quote:
Since it threw abend 4068

no it did not THROW an abend, it abended with such-and-such a message or it issued or displayed a message. It did not 'throw' anything.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Oct 16, 2012 11:07 pm    Post subject: Reply to: Calling DB2 subroutine from online COBOL program
Reply with quote

If your sub-program (not sub-routine) doesn't have any CICS API's, then compile it as if it were DB2 "Batch". Then remove DFHEIBLK and DFHCOMMAREA from the Caller's CALL parameters and only use WS-DSNTIAR and WS-ACCOUNT and change your sub-program's PROCEDURE DIVISION "USING" Statement to comply with the Caller's changes.
Back to top
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Wed Oct 17, 2012 10:27 pm    Post subject:
Reply with quote

Thanks for the guidance.

I have this sub program compiled with COBOL-CICS-DB2 compiler and that is working fine since it is called from 10 other online programs.

However in this particualar main online program (compiled with COBOL-CICS compiler), I just removed all the addressability codings and added just one dummy SQL statement and compiled with COBOL-CICS-DB2 compiler and it is calling the subrprogram successfully. Eventhough I got it working by adding one dummy DB2 statement, I am now puzzled with the way it worked.

Thanks
Vinu
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us