Page 1 of 1

Copy and Include copybook

PostPosted: Fri Jun 15, 2012 7:20 pm
by sinmani
Hi Friends,

I have a Copybook.

Now I have to write a several files with the same layout as that of the copybook. So I Copy it in my FD section.

For this I define Copybook with field names prefixed by say suppose :AC: and use
Copy <Copybook Name >
Replacing ==:AC:== by ==AC-== for each file.

Now I also want to use this copybook in my embedded SQL statements so for that I must Include this copybook in my Working storage section.

but the variables in Working storage section would be like :AC: Field name

is there anyway we can use replace while Incuding???

Re: Copy and Include copybook

PostPosted: Fri Jun 15, 2012 7:33 pm
by Akatsukami

Re: Copy and Include copybook

PostPosted: Fri Jun 15, 2012 7:59 pm
by Ed Goodman
You lost me.

You have an FD style copybook, and you want to include it inside the procedure division EXEC SQL statements?

Re: Copy and Include copybook

PostPosted: Fri Jun 15, 2012 8:14 pm
by Robert Sample
My understanding is that INCLUDE cannot use REPLACING. Your options are to place the code in the program, or create a different copy book with the :AC: replaced with valid COBOL syntax, then INCLUDE that copy book instead of the one with :AC:.

Re: Copy and Include copybook

PostPosted: Sat Jun 16, 2012 1:25 pm
by sinmani
Ed Goodman wrote:You lost me.

You have an FD style copybook, and you want to include it inside the procedure division EXEC SQL statements?


Yes, you got it right Ed.

Re: Copy and Include copybook

PostPosted: Mon Jun 18, 2012 7:01 pm
by Anuj Dhawan
I agree with Robert. REPLACING phrase can be used with COPY statement. All this is "under COBOL". INCLUDE is a DB2 dialect.

Here are 8.1.4.3 Replacement and comparison rules for COPY statement with REPLACING and they don't talk about INCLUDE at all.