What is Copybook in AS/400(RPG)

370 pts.
Tags:
AS/400
RPG/400
Can any one pl explain me with an example what is copybook?.
ASKED: July 4, 2008  5:11 PM
UPDATED: May 3, 2010  6:25 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Copybook is a bunch of source code statements.
Lets take an example:

I have around 100 programs which are doing addition for two numbers.
Now in this scenario I can write logic of adding two numbers but instead of writing same code in alll programs I can create a member and put the code for adding two numbers into it and just copy that member into the programs where I want to implement this logic.
The source of this copy book can be seen into the spool file of the program in which you ha ve included it.

let me know if you stilll need any more explanation.

===========================================================

A /COPY member is a source member that contains a set of source statements that you expect to use over and over in many programs. Instead of having the same source in each of those programs, you have a single source line with a /COPY directive. The compiler then inserts the statements from the /COPY member in place of the /COPY directive.

If you need to change the statements at a future time, you only change the one source member. When you recompile all of the programs, the new source is automatically “copied” into the source that is compiled.

In earlier versions of languages, you might copy data definitions or standard subroutines. Now, with ILE, /COPY members are best suited for data structures or prototype definitions. Use prototyped procedures instead of subroutines. The only time prototype /COPY members would change would be if you had to change the parameters for the prototype.

Tom

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Gilly400
    Hi, You use the compile time directive /COPY to add the source from another source member into your program. These days it would be more advisable to use a module instead of a copybook. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following