This program demonstrates some typical steps in creating a program that uses several ILE and OPM programming languages.
The program is a small transaction-processing program that takes as input the item name, price, and quantity for one or more products. As output, the program displays the total cost of the items specified on the display and writes an audit trail of the transactions to a file.
Thisshows the basic flow of the program.
Basic Program Structure
The program consists of these components:
The ILE C++ program T2123IC5 is created with the CRTPGM default for the ACTGRP parameter, ACTGRP(*NEW). When the CL program calls the ILE C++ program, a new activation group is started.
The OPM CL, COBOL, and RPG programs are activated within the OPM default activation group.
This shows the structure of this program in ILE.
Structure of the Program in ILE C++
The source code for each of the files that compose this program are an externally described file, a CL program,a CL command prompt, a C++ source file, and OPM COBOL program and an OPM RPG program.
Externally Described File T2123DD2
The file T2123DD2 contains the audit trail for the C++ program T2123IC5. The DDS source defines the fields for the audit file:
CL Program T2123CL2
The CL program T2123CL2 passes the CL variables item_name, price, quantity and user_id by reference to an ILE C++ program T2123IC5
The Retrieve Job Attributes (RTVJOBA) command obtains the user ID for the audit trail. Arguments are passed by reference. They can be changed by the receiving ILE C++ program. The variables containing the user and item names are explicitly null-terminated in the CL program.
Note: CL variables and numeric literals are not passed to an ILE C++ program with null-terminated strings. Character literals and logical literals are passed as null-terminated strings but are not widened with blanks. Numeric literals such as packed decimals are passed as 15,5 (8 bytes). Floating point constants are passed as double precision floating point values (1.2E+15).
CL Command Prompt T2123CM2
You use the CL command prompt T2123CM2 to prompt the user to enter item names, prices, and quantities that will be used by the C++ program T2123IC5.
C++ Source File T2123IC5
The C++ source file T2123IC5 contains a main() function which receives the incoming arguments from the CL program T2123CL2. These arguments have been verified by the CL command prompt T2123CM2 and null-terminated within the CL program T2123CL2. All the incoming arguments are pointers.
The main() function calls the function CalcAndFormat() which is mapped to a COBOL name. It passes the price, quantity, taxrate, formatted_cost, and a success_flag to the OPM COBOL program T2123CB1 using the extern "OS nowiden" linkage specification, because the OPM COBOL program is not expecting widened parameters.
The formatted_cost and the success_flag values are updated in the C++ program T2123IC5.If CalcAndFormat() returns successfully a record is written to the audit trail by WriteAuditTrail() in the OPM RPG program.
The main() function in program T2123IC5 calls WriteAuditTrail() which is mapped to an RPG program name, and passes the user_id, item_name, price, quantity, taxrate,and formatted_cost, using the extern "OS" linkage specification.
Note: By default,the compiler converts a short integer to an integer unless the nowiden parameter is specified on the extern linkage specification. The short integer in the C++ program is converted to an integer, and then passed to the OPM RPG program. The RPG program is expecting a 4 byte integer for the quantity variable. See “Understanding Data-Type Compatibility” for information on data-type compatibility.
OPM COBOL Program T2123CB1
The OPM COBOL program T2123CB1 receives pointers to the values of the variables price, quantity and taxrate, and pointers to formatted_cost and success_flag.
The CalcAndFormat() function in program T2123CB1 calculates and formats the total cost. Parameters are passed from the ILE C++ program to the OPM COBOL program to do the tax calculation.
OPM RPG Program T2123RP1
The OPM RPG program T2123RP1 contains the WriteAuditTrail() function which writes the audit trail for the program.Invoking the ILE-OPM Program
To nter data for the program T2123IC5 enter the command T2123CM2 and press F4 (Prompt).
You can enter this data into T2123CM2:Hammers
The output is:
The physical file T2123DD2 contains this data:SMITHE HAMMERS 0000000198500015$11,385.0007 2893
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.