Guild Companies, Inc.  
 
Midrange Guru - Tech Tips
OS/400 Edition
Volume 2, Number 28 - April 12, 2002

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

Sponsored By
TRAMENCO

Learn what's over the horizon for the iSeries and AS/400, and how it will impact your career, by attending the premier training event of 2002. It's the iSeries and AS/400 Connection Conference June 16 – 19, 2002 in Naples Florida. Join 19 of the industries greatest minds including Dr. Frank Soltis, Skip Marchesani, Wayne O. Evans, Susan Gantner, Jon Paris, Marie Finnegan-Cronin, and Howard Arner, Jr. as they deliver AS/400 training and education to prepare you for the challenges of tomorrow. A full agenda of 96 sessions (including 10 hands-on labs) provide practical instruction in a full range of topics, including:

  • Understanding Websphere Development Studio

  • Accessing DB2/400 data from Linux

  • Learning how JavaBeans are used

  • Make the most of RPG IV's built in functions

  • SQL Tricks and Techniques

  • ABCs of System Management

  • And much more!
Whether you are an old pro, or just getting your feet wet, there is something for everyone during this intensive four-day conference. Best of all, your classroom is the Registry Resort and Spa, Naples Florida's premier 5-star resort. To register, or for more information, call 1 800 897.5923, or go to the web at www.tramenco.com. But hurry, you must register before May 15, 2002 to save $200 off the standard registration and be eligible for special hotel rates.

THIS ISSUE
SPONSORED BY:
SoftLanding Systems
TRAMENCO
BACK ISSUES
TABLE OF CONTENTS
Checking the Call Stack
Odds and Ends
Reader Feedback and Insights: Refreshing STRCPYSCN
  Newsletters | Subscribe | Advertise | About Us | Contact | Search | Home  
  Last Updated: 4/12/02
Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.