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
 

 

2 DCLGEN's in the same program - duplicate variables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
acrajesh

New User


Joined: 31 May 2007
Posts: 15
Location: Bangalore

PostPosted: Wed Aug 27, 2008 1:29 pm    Post subject: 2 DCLGEN's in the same program - duplicate variables
Reply with quote

I am trying to use two DCLGEN's in the same program where two of the variables used is ambigous, ie; they are used in both the dclgen's. how to fix this issue?

Ex: The variable STL-CODE is used in both the DCLGEN's
Back to top
View user's profile Send private message

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 1:52 pm    Post subject: Reply to: 2 DCLGEN's in the same program - duplicate variabl
Reply with quote

acrajesh,

Quote:
am trying to use two DCLGEN's in the same program where two of the variables used is ambigous, ie; they are used in both the dclgen's.


Not a problem and you can use it even when the names are same.

Quote:
how to fix this issue?


Have both the dclgen's INCLUDEd in the program and when it comes to differentiate the variables code as shown below

Say if the field X is in DCLGEN Y and Z

Code:
MOVE X OF Y TO X OF Z
Back to top
View user's profile Send private message
acrajesh

New User


Joined: 31 May 2007
Posts: 15
Location: Bangalore

PostPosted: Wed Aug 27, 2008 2:09 pm    Post subject:
Reply with quote

Hi Aaru,

The code is as follows

EXEC SQL
INSERT INTO MTW.STK_MRKT_DTL(
STK_CODE,
DMAT_ACCT,
DMAT_ACCT_NAME,
DMAT_ACCT_ADDR,
STK_BUY_PRC,
STK_SELL_PRC,
TOT_STK_BOUGHT,
TOT_STK_SOLD,
STOP_LOSS_PRC,
STK_HLD_FROM,
LST_TXN_DATE,
CRT_USER_ID,
CRT_TMSTMP)
VALUES (
:STK-CODE,
:DMAT-ACCT,
:DMAT-ACCT-NAME,
:DMAT-ACCT-ADDR,
:STK-BUY-PRC,
:STK-SELL-PRC,
:TOT-STK-BOUGHT,
:TOT-STK-SOLD,
:STOP-LOSS-PRC,
:STK-HLD-FROM,
:LST-TXN-DATE,
CURRENT SQLID,
CURRENT TIMESTAMP)
END-EXEC

EXEC SQL
INSERT INTO MTW.STK_MRKT_HDR(
STK_CODE,
COMP_NAME,
COMP_ADDR,
CURR_STK_PRC,
CURR_YR_LOW,
CURR_YR_HIGH,
TOT_PUB_STK,
CRT_USER_ID,
CRT_TMSTMP )
VALUES (
:STK-CODE,
:COMP-NAME,
:COMP-ADDR,
:CURR-STK-PRC,
:CURR-YR-LOW,
:CURR-YR-HIGH,
:TOT-PUB-STK,
CURRENT SQLID,
CURRENT TIMESTAMP)
END-EXEC

where STK-CODE appears in both of the INSERT's. How to fix this issue as the compilation throws the following error:

DSNH314I E DSNHSMUD LINE 246 COL 0 REFERENCE TO HOST VARIABLE STK-CODE IS AMBIGUOUS
DSNH314I E DSNHSMUD LINE 300 COL 0 REFERENCE TO HOST VARIABLE STK-CODE IS AMBIGUOUS

I even tried like STK-CODE OF STK-MRKT-HDR and STK-MRKT-HDR.STK-CODE but both went in vain.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Aug 27, 2008 2:23 pm    Post subject:
Reply with quote

reference qualification in COBOL is via the 'IN' or 'OF' keyword.

the format for qualifying columns in db2 is a little different.

it is either qualifier.column_name

or column_name.qualifier

i don't remember,
either refer to the documentation or try both ways and see which works
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Aug 27, 2008 2:25 pm    Post subject:
Reply with quote

an amendment to the previous post.

it is host variable and not column that is qualified.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 2:26 pm    Post subject: Reply to: 2 DCLGEN's in the same program - duplicate variabl
Reply with quote

acrajesh,

This is how it should be done when the same field is there in 2 DCLGEN's.

Say the DCLGEN's are Y and Z

In the DCLGEN you would have 2 things

- DECLARE TABLE
- COBOL declaration for the TABLE

In the cobol declaration of the table make sure that the 01 level has the DCLGEN name.

Code:
01 X.
              10 field one  pic x(10)
              10 field two  pic x(20)


In the DCLGEN Y have it as

Code:
01 Y.
              10 field one pic x(10)


then in the query use as shown below

Code:
EXEC SQL
                  INSERT
                  INTO TABLE
                     ....
                      ....
                   VALUES(FIELD EIGHT
                             ,:X.FIELD ONE)
           END-EXEC   


Similarly in the next query use it with the prefix Y.

Hope this helps
Back to top
View user's profile Send private message
acrajesh

New User


Joined: 31 May 2007
Posts: 15
Location: Bangalore

PostPosted: Wed Aug 27, 2008 2:48 pm    Post subject:
Reply with quote

Not working icon_sad.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Aug 27, 2008 2:55 pm    Post subject:
Reply with quote

only thing that is not working is you.

sorry if you are offended (yes the sarcasm was intended)
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 3:09 pm    Post subject: Reply to: 2 DCLGEN's in the same program - duplicate variabl
Reply with quote

acrajesh,

Quote:
Not working


Which part of the code do you think is not working? Did you try ?
Back to top
View user's profile Send private message
Cristopher

New User


Joined: 31 Jul 2008
Posts: 53
Location: NY

PostPosted: Wed Aug 27, 2008 5:40 pm    Post subject: Reply to: 2 DCLGEN's in the same program - duplicate variabl
Reply with quote

If nothing is working and standards permit , U may try this (not tested)

Move STK-CODE of STK-MRKT-DTL to WS-CODE-DTL
Move STK-CODE of STK-MRKT-HDR to WS-CODE-HDR

Make sure the data types exactly match and use these these variables in your SQl insert query.

Hope This helps.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts Compiling program in endeavor for tra... RALAKKAL Compuware & Other Tools 4 Mon Jun 05, 2017 8:27 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm


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