|
Odds and Ends
Hey, Ted:
Question:
I have defined a logical file with the following record
selection specifications:
A S ISTOR CMP(EQ 'W101')
A S IACTV CMP(EQ 0)
When I access this file, I get records with a
warehouse number other than W101. Can you tell me why?
Answer:
The record selection specifications are OR'ed. That is,
the system will select any record that satisfies either
criterion. Your system is selecting records where
warehouse is W101 or activity code is zero, or both.
To fix your problem, remove the S from the second
specification. This will AND the two lines. That is, the
system will select records that satisfy both conditions.
A S ISTOR CMP(EQ 'W101')
A IACTV CMP(EQ 0)
For more information about selection and omission of
records in logical files, see iSeries Information
Center's DB2 UDB for iSeries Database Programming V5R1
manual, Selecting and Omitting Records Using Logical
Files .
Question:
I am writing an RPG program to print Interleaved 2 of 5
barcodes. The specifications require me to convert pairs
of decimal digits into single characters. For example,
the number 12 becomes hexadecimal 2D. I can convert the
numbers to the hex pairs, but how do I convert a hex pair
to a single character with the appropriate hex value?
Answer:
Use the cvtch function. It converts a two-byte string of
hex digits to a single character with the same hex value.
For example, C1 is converted to a capital A.
Here is some example code from which you can start.
CharVal contains five hex pairs, which are converted to
five characters in HexVal:
H bnddir('QC2LE') dftactgrp(*no) actgrp('QILE')
d cvtCharToHex pr extproc('cvtch')
D Hex * value
D Char * value
D CharSize 10i 0 value
D CharVal s 10 inz('A72D4359A8')
D HexVal s 5
C callp cvtCharToHex
(%addr(HexVal):
C
%addr(CharVal):
C
%size(CharVal))
C eval *inlr = *on
If you ever need to convert in the opposite direction, use the cvthc function:
H bnddir('QC2LE') dftactgrp(*no) actgrp('QILE')
D cvtHexToChar pr extproc('cvthc')
D Char * value
D Hex * value
D CharSize 10i 0 value
D HexVal s 5 inz(x'A72D4359A8')
D CharVal s 10
C callp cvtHexToChar
(%addr(CharVal):
C
%addr(HexVal):
C
%size(CharVal))
C eval *inlr = *on
Question:
How do I print part of a source member?
Answer:
Use the LLP command within SEU. Key LLP over the first
and last lines to be printed. Any lines within that range
that are excluded with the X or XX commands will not be
printed.
-- Ted
|