Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Embeding DB2 in cobol program

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

New User


Joined: 12 Dec 2004
Posts: 22

PostPosted: Sun Dec 19, 2004 11:54 am    Post subject: Embeding DB2 in cobol program
Reply with quote

hi all

iam embeding DB2 in cobol program. i have pasted the program here.

ID DIVISION.
PROGRAM-ID. KANINS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE KANDCL
END-EXEC.
PROCEDURE DIVISION.
MP.
ACCEPT WS-NAME.
Accept ws-empid.

EXEC SQL
INSERT INTO jpk98.KAN1 (NAME, EMPID)
VALUES (:WS-NAME, :WS-EMPID)

END-EXEC.
STOP RUN.
DCL Gen
=====

EXEC SQL DECLARE JPK98.KAN1 TABLE
( NAME CHAR(20),
EMPID INTEGER
) END-EXEC.
******************************************************************
* COBOL DECLARATION FOR TABLE LEM0U98.KAN1 *
******************************************************************
01 WS-EMP.
* *************************************************************
* NAME
10 WS-NAME PIC X(20).
* *************************************************************
* EMPID
10 WS-EMPID PIC S9(9) USAGE COMP.
******************************************************************
* INDICATOR VARIABLE STRUCTURE *
******************************************************************
01 IKAN1.
10 INDSTRUC PIC S9(4) USAGE COMP OCCURS 2 TIMES.
******************************************************************
* THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 2 *
******************************************************************

error is

116 IGYPA3018-S Identifier "WS-EMPID (BINARY INTEGER)" was used in an "ACCEPT" statement. The statement was discarded.

can anyone tell me how to overcome this
Back to top
View user's profile Send private message

ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Mon Dec 20, 2004 4:30 pm    Post subject: Due to COMP usage...
Reply with quote

Hi,

This is due to COMP usage only. You can change it as X(9) because we are not going to do anything with EMPNO. change this in DCLGEN output. We have another way declare a WS variable as PIC X(9) accept this and move value to :ws-empno. Then also this problem will be solved.

Even another way exists but its too lengthy if we go for that it looks crazy. so select any one of the above methods.

Bye,
Reddy.
Back to top
View user's profile Send private message
haiardhan

New User


Joined: 26 Jul 2008
Posts: 6
Location: india

PostPosted: Fri Oct 24, 2008 12:58 am    Post subject: Reply to: Embeded program
Reply with quote

FOR THIS IGYPA3018-S ENG--ERROR
REASON---YOU ARE DECLARED A VARIABLE IN DB2 AS INTEGER /SMALLINT
LIKE
CREATE TABLE TAB1(NO INT, ENGNAME CHAR(10));
WHILE IN HOST VARIABLES IN DCLGEN
THE DECLARATION WILL BEL LIKE
:HS-ENGNO PIC S9(9) USAGE COMP:
ANS>>>>>.
FOR THIS WE NEED TO DECLARE A VARIABLE IN WORKING -STORAGE SECTION .
AND AGAIN WE NEED TO MOVE THAT VARIABLE ACCEPTED VALUE INTO
THE HOST VARIABLE VALUE(DCLGEN VARIABLE)
WORKING-STORAGE SECTION
01 WS-ENGNO PIC S9(9).
PROCEDURE DIVISION.
ACCEPT WS-ENGNO.
MOVE WS-ENGNO TO HS-WS-ENGNO.
ACCEPT HS-WS-NAME.
Back to top
View user's profile Send private message
haiardhan

New User


Joined: 26 Jul 2008
Posts: 6
Location: india

PostPosted: Fri Oct 24, 2008 12:59 am    Post subject: Reply to: Embeded program
Reply with quote

ID DIVISION.
PROGRAM-ID. KANINS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE KANDCL
END-EXEC.
PROCEDURE DIVISION.
MP.
ACCEPT WS-NAME.
Accept ws-empid.

EXEC SQL
INSERT INTO jpk98.KAN1 (NAME, EMPID)
VALUES (:WS-NAME, :WS-EMPID)

END-EXEC.
STOP RUN.
DCL Gen
=====

EXEC SQL DECLARE JPK98.KAN1 TABLE
( NAME CHAR(20),
EMPID INTEGER
) END-EXEC.
******************************************************************
* COBOL DECLARATION FOR TABLE LEM0U98.KAN1 *
******************************************************************
01 WS-EMP.
* *************************************************************
* NAME
10 WS-NAME PIC X(20).
* *************************************************************
* EMPID
10 WS-EMPID PIC S9(9) USAGE COMP.
******************************************************************
* INDICATOR VARIABLE STRUCTURE *
******************************************************************
01 IKAN1.
10 INDSTRUC PIC S9(4) USAGE COMP OCCURS 2 TIMES.
******************************************************************
* THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 2 *
******************************************************************

error is

116 IGYPA3018-S Identifier "WS-EMPID (BINARY INTEGER)" was used in an "ACCEPT" statement. The statement was discarded.

FOR THE ABOVE PROBLEM
YOU NEED CHANGE THE ACCEPT STATMENT LIKE THIS..............................

ID DIVISION.
PROGRAM-ID. KANINS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 TEMP-EMPID PIC S9(9) COMP.------........OR 77 TEMP-EMPID PIC S9(9).
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE KANDCL
END-EXEC.
PROCEDURE DIVISION.
MP.
ACCEPT WS-NAME.
Accept TEMP-empid.
MOVE TEMP-EMPID TO WS-EMPID.
EXEC SQL
INSERT INTO jpk98.KAN1 (NAME, EMPID)
VALUES (:WS-NAME, :WS-EMPID)

END-EXEC.
STOP RUN.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10373
Location: italy

PostPosted: Fri Oct 24, 2008 1:09 am    Post subject: Reply to: Embeding DB2 in cobol program
Reply with quote

same comment ....
why resurrect a four year old topic ??
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Oct 24, 2008 9:50 am    Post subject:
Reply with quote

Besides that, a quick look at http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGY3LR10/6.2.1.1?SHELF=&DT=20020920180651 would have yielded the answer quicker than posting a question on a bulletin board. icon_smile.gif
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us