Call callb callp call (data migration)

Source: Internet
Author: User
Tags prototype definition

Original article: http://qlcc.blog.163.com/blog/static/44939773200785103536753/

About as400 call [transfer]

Http://www.blogone.net/user52/ccpcd/blog/36839855.html

Rpgiv provides three types of calls:

Call (call a program) calls a program, which is also called a dynamic call.

Callp (call a protoyped procedure or program) calls the prototype process or prototype sub-process. You can use dynamic or static calls.

Call a bound module calls a binding module, which is also called a static call.

The main difference between callp and callb is that callp provides better parameter type checks. It also provides richer functions such as passing Parameters Using values or constants.

Callp is used to replace callb and call. When using callp, a process prototype must be defined in the D specification table. In the prototype declaration, you can define static or dynamically bound call connections. The keyword Extproc is used to specify the static call connection, while extpgm is used to specify the dynamic call connection (static binding by default ).

We recommend that you use callp instead of call or callb during rpg iv programming. The biggest benefit is that the program's parameter check is performed during compilation, so that many parameter types and quantities are checked during compilation, in actual calls, problems with calling program parameters will be reduced. Second, you can use static calls to improve operation efficiency.

You can use nested built-in functions in complex process calls. You can omit callp and directly use the process name return value in the program.

By defining a prototype, callp can be easily used to call a program that currently uses call or callb call methods. You only need to check the type of the variable defined in * entry plist and define a prototype with the parameter of the corresponding type. However, if you want to pass variable-length arguments or array parameters, You need to specify the options (* varsize) option. If some parameters are optional, You need to specify * ptions (* omit) or options (* nopass.

 

1. callp sub-process in the program

1. Process prototype definition: D. process name PR like (XX)

Process Parameter Definition

2. Call process: rc = process name (parameter 1: parameter 2 ...)

3. Process content: p process name B (the process starts and can be called externally)

D process name PI like (XX)

Process Parameter definition (same as the preceding Parameter definition)

Process body

P process name E (process ended)

4. PDM Option 14

Ii. External process call

1. External Process Writing (Module 1 ):

Process prototype definition: D process name PR like (XX)

Process Parameter Definition

Process content: p process name B Export (the process starts and can be called externally)

D process name PI like (XX)

Process Parameter definition (same as the preceding Parameter definition)

Process body

P process name E (process ended)

2. compilation process: PDM Option 15 or crtrpgmod

3. Call process: D. process name PR like (xx) (process prototype definition)

(Module 2) Process Parameter Definition

Rc = process name (parameter 1: parameter 2 ...)

4. PDM Option 15 or crtrpgmod

Crtpgm PGM (module 2) module (module 2 Module 1) actgrp (* caller)

(Module 2 is the main module, Module 2 calls Module 1, and the generated program name is the same as that of the main module)

Iii. Call the callb binding module

1. Writing in the called module (Module 1 ):

Process prototype definition: D process 1 PR

D process 2 PR

Process content: p process 1 B Export

D process 1 PI like (xx) (can be omitted)

Process Parameter definition (omitted)

Process body

P process 1 E

P process 2 B Export

D process 2 PI like (xx) (can be omitted)

Process Parameter definition (omitted)

Process body

P process 2 E

2. Compilation module: PDM Option 15 or crtrpgmod

3. Call module writing: * entry plist

Parm variable name

Callb' process 1'

Parm variable name

Or: callb' module 1'

Parm variable name

4. Compilation module: PDM Option 15 or crtrpgmod

5. Program Generation: crtpgm program name module (Module 1 module 2) actgrp (* caller) 6. Run: Call program name ('process 1 ')...

Iv. Use of callp:

1. Writing in the called module (Module 1 ):

* Entry plist

Parm variable name

Module body

2. Compilation module: PDM Option 15 or crtrpgmod. Module 1 is generated.

3. Call module writing (module 2 ):

Variable definition

Prototype definition: D module name pr extproc ('module 1 ')

Parameter definition (this parameter definition is consistent with the above variable definition and can be like)

Call: callp Module name (parameter 1: parameter 2 ...)

4. Compilation module: PDM Option 15 or crtrpgmod. Module 2 is generated. Or PDM Option 14

5. Generate the program: crtpgm program name lib (module 2 Module 1) (module 2 is the main module, and the program name can be the same as module 2)

Let's talk about the differences between the three:

Http://www-900.ibm.com/cn/support/viewdoc/detail? Docid = 1222070000009

You can use call, callb, and callp methods to call programs in cl.

Call calls OPM's old-fashioned RPG program and uses the dynamic memory call Method

Callb calls the pep (primary entry procedure) in the module. This procedure does not need to be declared in advance.

Callp calls procedure in the module. This procedure must be stated in advance in the D specification of the program, also known as the original call method. It has a similar memory call method as callb, however, the call parameters are checked in advance before the call.

Currently, callp is recommended for calling internal and external procedure in Ile RPG.

Call programs and processes

You can call the program or call the process in the Ile program. The Ile language identifies whether the calling target is a program or a process by calling the statement call, callp, or callb.

1. dynamic program call

Calling the * PGM program using call is actually converting the called program into an address when the program is running. Therefore, this method can be called dynamic call. Dynamic program calls include:

A. The OPM program can call an OPM program or a ile program.

B. Ile program can call one OPM program or another Ile Program

C. The service program can call the OPM program or the Ile program.

2. Static Process call

Using callp to call procedure is to convert the called program into a bit address during binding, so it can be called static call. Static calls are more efficient than dynamic calls. You can call any of the following items using a static process:

A. Objects in the same module

B. Process in a separate module of the same Ile program or service program

C. Process in a separate Ile Service Program

 

Differences between call, callb and callp:

Call can only call * PGM, which is a dynamic call and has low program running efficiency. Both callb and callp can only call procedure (suspect !), Most of the time is static calls. Only procedure in the pointer variable is called dynamically. However, callb does not participate in the interface validity check, that is, no prototype description is required, therefore, some errors may occur during running. Both call and callb can only pass real parameters in a fixed format, that is, use plist.

Global and local variables in rpg iv:

Each OPM program has only one unique program entry, but each procedure in the Ile program can have one entry. In the OPM program, each internal subroutine variable is a global variable, but all variables declared in the procedure of the Ile program are local variables, and all other variables used are global variables. If the variables declared in procedure have the same name as a global variable, the two variables will use different spaces in the memory, that is, the two variables will not affect each other, the global variable with the same name will not be used by procedure. Local variables will also be released after this procedure is executed.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.