Topic
1 reply Latest Post - ‏2013-04-29T15:31:17Z by HBoone
SystemAdmin
SystemAdmin
3105 Posts
ACCEPTED ANSWER

Pinned topic Issue with COPY REPLACING within DB2

‏2013-04-04T20:02:27Z |
I am facing problem with COPY REPLACING Statement used within "EXEC SQL"

Code snapshot
LINKAGE SECTION.

EXEC SQL INCLUDE SQLCA END-EXEC.

EXEC SQL INCLUDE XYZ END-EXEC.

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 ABCD-REC-INFO.
COPY ABCD REPLACING ==:PFX:== BY ==RAB==.
EXEC SQL END DECLARE SECTION END-EXEC.

I am not able to compile module and variables within ABCD copybooks are not getting resolved. Those are host variables and I am getting error as "UNDEFINED OR UNUSABLE HOST VARIABLE"

When I use version of cpoybook without the :PFX: and do not use REPLACING, then it works. Example
LINKAGE SECTION.

EXEC SQL INCLUDE SQLCA END-EXEC.

EXEC SQL INCLUDE XYZ END-EXEC.

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 ABCD-REC-INFO.
COPY ABCD
EXEC SQL END DECLARE SECTION END-EXEC.

Can anybody please help to resolve this issue?
  • HBoone
    HBoone
    1 Post
    ACCEPTED ANSWER

    Re: Issue with COPY REPLACING within DB2

    ‏2013-04-29T15:31:17Z  in response to SystemAdmin

    The DB2 10 Application Programming and SQL Guide states several somewhat cryptic rules on the use of the COBOL COPY and/or COPY REPLACING statements.  The results usually depend on whether you are using the DB2 precompiler or the (newer) DB2 coprocessor.  I just read over them and I'm still not sure of what is supposed to happen.

    In the old days, you used EXEC SQL INCLUDE xxx END-EXEC for anything that might be needed by the DB2 precompiler.  I suspect that most shops felt this was too limiting and did what we did:  put a step (calling a REXX or other program) in front of the DB2 precompiler step to expand the COBOL COPY and/or COPY REPLACING statements. 

    I suspect you can find a program that'll do this for you somewhere on the internet (I don't know if I can share ours or not). 

    HTH.