IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Calling DB2 subroutine from online COBOL program


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 179
Location: India

PostPosted: Tue Oct 16, 2012 9:23 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Oct 16, 2012 9:30 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Oct 16, 2012 9:33 pm
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: 179
Location: India

PostPosted: Tue Oct 16, 2012 9:35 pm
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: 179
Location: India

PostPosted: Tue Oct 16, 2012 9:43 pm
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

Moderator Emeritus


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

PostPosted: Tue Oct 16, 2012 9:54 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Oct 16, 2012 10:04 pm
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: 179
Location: India

PostPosted: Tue Oct 16, 2012 10:34 pm
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: 2455
Location: Hampshire, UK

PostPosted: Tue Oct 16, 2012 10:47 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Oct 16, 2012 11:07 pm
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: 179
Location: India

PostPosted: Wed Oct 17, 2012 10:27 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top