When you call a program, the OS/400 system locates the corresponding executable code and performs the instructions found in the program.
Note: Only programs can run independently. Service programs or other bound procedures must be called from a program that requires their services.
There are several ways to call a program:
In addition, you can run a program using:
Calling a Program Using the TFRCTL Command
You can run an application from within a CL program that transfers control to your program using the Transfer Control (TFRCTL) command. This command:
In the following example, the TFRCTL command in a CL program RUNCP calls a C++ program XRUN2, which is specified on the TFRCTL command. RUNCP transfers control to XRUN2. The transferring program RUNCP is removed from the call stack.
Figureillustrates the call to the CL program RUNCP, and the transfer of control to the C++ program XRUN2.
Calling Program XRUN2 Using the TFRCTL Command
To create and run programs RUNCP and XRUN2, follow the steps below:
Program RUNCP uses the TFRCTL command to pass control to the ILE C++ program XRUN2, which does not return to RUNCP.
Program XRUN2 receives a null terminated character string from the CL program and prints the string.
The output from program XRUN2 is:
Running a Program from a User-Created CL Command
You can also run a program from your own CL command. To create a command:
The CRTCMD command definition includes the command name,parameter
descriptions, and validity-checking information,and identifies the program that performs the function requested by the command.
The program called by your CL command is run.
The following example illustrates how to run a program from a user-created CL command:
A newly created command COST prompts for and accepts user input values. It then calls a C++ program CALCOST and passes it the input values. CALCOST accepts the input values from the command COST, performs calculations on these values, and prints results. Figure illustrates this example.
Calling Program CALCOST from a User-Defined Command COST
To create and run the example, follow the steps below:
Use the CL command prompt COST to enter item name, price, and quantity for the ILE C++ program CALCOST.
This program receives the incoming arguments from the CL command COST, calculates a cost, and prints values. All incoming arguments are pointers.
Type the data shown below into COST:Hammers
The output of program CALCOST is:
IBM-ILE Related Interview Questions
|IBM - RPG Interview Questions||IBM DB2 Interview Questions|
|DB2 Using SQL Interview Questions||IBM Mainframe Interview Questions|
|IBM AIX 7 Administration Interview Questions||AS400 Interview Questions|
|Automatic Storage Management (ASM) Interview Questions||Mainframe DB2 Interview Questions|
|Rpgle Interview Questions|
Introduction To The Ile C/c++ Compiler
Creating A Program
Working With Exports From Service Programs
Example - Creating A Sample Ile C Application
Running A Program
Debugging A Program
Using Stream And Record I/o Functions With Iseries Data
Using Ile C/c++ Stream Functions With The Iseries Integrated File System
Using Externally Described Files In Your Programs
Using Database Files And Distributed Data Management Files In Your Programs
Using Device Files In Your Programs
Handling Exceptions In Your Program
Using Iseries Pointers In Your Program
Using Packed Decimal Data In Your C Programs
Internationalizing Your Program
International Locale Support
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.