How To
Summary
This document pertains to IBM i CL Programming.
The binary built-in function (%BINARY or %BIN) interprets the contents of a specified CL character variable as a signed binary integer.
The starting position begins at the position specified and continues for a length of 2 or 4 characters.
CL Programming built-in function %BIN works with 2 or 4 bytes signed integers.
There are certain APIs that use a BINARY(8) field in the format of the data to return and it is not obvious how to convert the value to a character.
Objective
This sample uses Retrieve Partition Information (dlpar_get_info) API to return information about configuration and CPU usage of the logical partition where this API is called. IBM Knowledge Center IBM i api dlpar_get_info
- STG(*DEFINED) - Storage: the value for this variable is specified in the variable defined in the DEFVAR parameter.
- DEFVAR(&DATA ?) - Defined on variable: specifies the variable that contains this field, and its starting position.
- %CHAR converts logical, decimal, integer, or unsigned integer data to character format.
PGM DCL VAR(&Return) TYPE(*CHAR) LEN(4) DCL VAR(&Receiver) TYPE(*CHAR) LEN(368) DCL VAR(&Format) TYPE(*INT) LEN(4) DCL VAR(&Length) TYPE(*INT) LEN(4) DCL VAR(&Message) TYPE(*CHAR) LEN(38) VALUE('DEFMEM: - ') DCL VAR(&MsgDta) TYPE(*CHAR) LEN(30) STG(*DEFINED) DEFVAR(&Message 9) DCL VAR(&DefMem) TYPE(*INT) LEN(8) STG(*DEFINED) DEFVAR(&Receiver 353) CHGVAR VAR(&Format) VALUE(1) CHGVAR VAR(&Length) VALUE(368) CALLPRC PRC('dlpar_get_info') PARM((&Receiver) (&Format *BYVAL) (&Length + *BYVAL)) RTNVAL(&Return) DMPCLPGM CHGVAR VAR(&MsgDta) VALUE(%CHAR(&DefMem)) SNDPGMMSG MSGID(CPF9898) MSGF(QSYS/QCPFMSG) MSGDTA(&Message) ENDPGM
DEFMEM: 30976.

Document Location
Worldwide
Was this topic helpful?
Document Information
More support for:
IBM i
Software version:
All Versions
Operating system(s):
IBM i
Document number:
1137904
Modified date:
19 December 2019
UID
ibm11137904