ILE C/C++ Programmer's Guide
You can pass packed decimal arguments with interlanguage calls to RPG or
COBOL.
Example:
The following example shows an ILE C program that calls an OPM COBOL
program and then passes a packed decimal data.
Figure 283. ILE C Source for an ILE C Program that Passes Packed Decimal Data
#include<stdio.h>
#include <decimal.h>
void CBLPGM(decimal(9,7));
#pragma datamodel(p128)
#pragma linkage(CBLPGM,OS)
#pragma datamodel(pop)
int main(void)
{
decimal(9,7) arg=12.1234567d;
/* Call an OPM COBOL program and pass a packed */
/* decimal argument to it. */
CBLPGM(arg);
printf("The COBOL program was called and passed a packed decimal value\n");
}
|
The following example shows COBOL source for passing a packed decimal
variable to an ILE C program.
Figure 284. COBOL Source that Receives Packed Decimal Data from an ILE C Program
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLPGM.
*************************************************************************
* Packed decimals: This is going to be called by an ILE C *
* program to pass packed decimal data. *
*************************************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-AS400.
OBJECT-COMPUTER. IBM-AS400.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
77 PAC-DATA PIC X(30) VALUE "PROGRAM START".
77 PACK-IN-WS PIC 99.9999999.
LINKAGE SECTION.
01 PACK-DATA PIC 9(2)V9(7) PACKED-DECIMAL.
PROCEDURE DIVISION USING PACK-DATA.
MAIN-LINE SECTION.
MOVE PACK-DATA TO PACK-IN-WS.
DISPLAY "**** PACKED DECIMAL RECEIVED IS: " PACK-IN-WS.
GOBACK.
|
The output is as follows:
+--------------------------------------------------------------------------------+
| **** PACKED DECIMAL RECEIVED IS: 12.1234567 |
| Press ENTER to end terminal session. |
+--------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------+
| The COBOL program was called and passed a packed decimal value. |
| Press ENTER to end terminal session. |
+--------------------------------------------------------------------------------+
[ Top of Page | Previous Page | Next Page | Table of Contents ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.