View previous topic :: View next topic
|
Author |
Message |
purushoth_jp
New User
Joined: 12 Dec 2004 Posts: 22
|
|
|
|
hi all
how to accept the comp iems in procedure division.
eg
data division.
working-storage section.
77 empno pic s9(4) comp.
procedure division.
main-para
accept empno.
insert into emp values (empno).
This is a db2-cobol program in precompliation time it is giving the error like below.
error message is IGYPA3018-S binary integer was used in a accept statement. the statement was discarded.
whether there is any other way to accept the comp items in procedure division and assign it to the insert operation.
reply soon
bye |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
It can be done, but it's a bit complicated. Using COMP for an employee number is unusual.
Before I take the time to explainn the process why don't you explain why you're doing it that way? Why not carry it as PIC XXXX like everyone else? |
|
Back to top |
|
|
purushoth_jp
New User
Joined: 12 Dec 2004 Posts: 22
|
|
|
|
hi jack
it is a DB2 cobol program, in which iam inserting values in DB2 through cobol. i have added the DCL member in the program. iam not able to accept that variable through accept statement. in DCL member the Empid is declared as s9(9) comp in DCl member.
ok now tell me how to accept that.
regards
purushoth |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
OK so I guess you're saying "that's the way they designed it and I'm just following their lead".
I have one other question. If the pgm user wants to add an empid of decimal 26, does (s)he enter 10 or 26 in the SYSIN rec? Just want to make sure we're on the same page. |
|
Back to top |
|
|
sharan112
New User
Joined: 21 Dec 2004 Posts: 2
|
|
|
|
Comp items are for better arithmetic calculation and efficient storage purpose. For user interface (Accepet, Display) you must use the following datatypes "any group item, or an elementary alphabetic, alphanumeric,alphanumeric-edited, numeric-edited"
Use the following code, it should work.
data division.
working-storage section.
77 empno-num pic 9(4).
77 empno-comp pic s9(4) comp.
procedure division.
main-para
accept empno-num.
move empno-num to empno-comp
insert into emp values (empno-comp). |
|
Back to top |
|
|
haiardhan
New User
Joined: 26 Jul 2008 Posts: 7 Location: india
|
|
|
|
IGYPA3018-S
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
why resurrect a 4 Year old topic...
also the post is not clear,
looks like it is quoting some program and giving a solution to some error
maybe the post was posted on the wrong topic ??? |
|
Back to top |
|
|
|