tnt400.com - AS/400 Tips And Techniques

Sponsored by news400.com

This page is a discussion on the mentioned topic.
Most of the answers are in their original posted form, including any technical/spelling/grammatical errors.
No guarantees are expressed or implied. :-)
Comments, corrections, concerns about this tip?

Got another AS/400 question? Ask it here


What's New?
See what's new at Tips-N-Tech.

AS/400 Tips-N-Tech
AS/400 tips, techniques, and FAQ. Updated frequently.
CODEPage/400
All the code samples you can eat! RPG, CL, DDS, etc. etc.
AS/400 FAQs
The official news400.com FAQs.






All AS/400 Tip Categories / AS/400 Programming / Zoned parameter in ILE RPG


Question:

Hello all!

I have a serviceprogram built in ILE/RPG with 2 numeric (packed) parameters. These programs is being called from both RPG/400 programs and other ILE/RPG programs in our application. These calling programs have sometimes zoned and sometimes packed fields used as parameters sent to the service program. My problem is that I get a decimal data error in the service program when I send a zoned field as a parameter. How can I make my serviceprogram understand both datatypes? I have tried the FIXNBR(*ZONED) parameter with no luck. I do not want to change all of my calling programs since they come in hundreds.

Any suggestions?


Answer(s):



If it's straightforward to tell which programs call with zoned parameters and which with packed, I recommend creating a second program that expects zoned parameters and have it call through to the other program with a packed version of the parameter.

If that's not possible, you'll have to change the called program to handle either packed or zoned parameters:

1. Declare the parameter as a data structure, and declare another standalone field to hold the value. Example for numeric field of 5 digits:
   D  numparmDS         DS
   D    zonedparm             1     5S 0
   D    packedparm            1     5p 0
   D  numparm           S           5p 0


2. Set the value of the standalone field this way:
   C        testn               zonedparm      10   (lo indicator)
   C        if      *in10
   C        z-add   zonedparm   numparm
   C        else
   C        z-add   packedparm  numparm
   C        endif


-- Barbara Morris IBM Toronto Lab RPG Compiler Development




If you do not use the parameters as I/O parameters you may also try to declare the parameters passed as CONST or passed by value since the compiler (or runtime???) will take care for the correct format, then. What I do not know at the moment is if there is a need for compiling the calling programs again.

Last but not least a question of mine. If it is really a service program (CRTSRVPGM, EPM), how do you call it from a RPG/400 program (OPM)?




Sorry but I don't mean a service program in that way. It's a program that any application can use to accomplish something. It's an ordinary CRTBNDRPG. A thought is to go back to RPG/400 which can handle both datatypes?

By the way, we're at V4R3!




Although RPG/400 allows you to supress decimal data errors for both packed and zoned values, that won't fix your problem. If you declare the parameter in the called program as packed, and pass a zoned value, the program may run without an exception, but the value used in the called program would never be the same as the value that was passed.

I wish IGNDECERR had never been allowed - it causes terrible to go unnoticed. Consider this pair of programs. P1 calls P2 with a zoned parameter. P2 is compiled with IGNDECERR(*YES). P2 assigns its parameter to 2 different fields, one set to zero and the other set to -13579. After the "assignment", the two fields still have their original values.

  ----------------------    P1   --------------------
IDS          DS
I                                        1   50ZONED
C                     Z-ADD12345     ZONED
C                     CALL 'S2'
C                     PARM           ZONED
C                     SETON                     LR
  ----------------------    P2   --------------------
C           *ENTRY    PLIST
C                     PARM           P       50
 *
C                     Z-ADDP         TEMP1   50
C                     Z-ADD-13579    TEMP2
C                     Z-ADDP         TEMP2   50
 *
C           TEMP1     DSPLY          TEMP2
C                     SETON                     LR
-- Barbara Morris IBM Toronto Lab RPG Compiler Development





Other tips in this category:

Click here to see all categories.

Socket Programming And Timeout Issues
Deleting Duplicate Records From A Table
What are data queues and how to use
Retrieving SMTP Name
RPGLE example for Dynamic Screen Manager API
Calling APIs from CL - with examples!
Compare two strings in RPG character by character
How to search all pgms in QCLSRC for a keyword
Retrieve Database File Description (QDBRTVFD) API
How to redirect the output to STDERR from RPG-IV
Using Multiformat Logical To Join 2 Identical File
D-Spec *LIKE DEFN
RPG: Converting Character to Decimal
Example of ILE RPG CGI Program
Handling ILE RPG Numeric Overflow
Help with Subfile Programming in RPG III
Zoned parameter in ILE RPG
What's the best way to do modulus in CL?
RPG Nesting Source Print Utility
More on changing the SIGNON screen
A silly ILE RPG question
Calling Validation List API From ILE RPG
Soft Coding Module Names
RPG Multidimensional Arrays in Action
Build a Page-Equals-Size Lookup Window
Procedures within an ILE RPG program
Break msg from RPG
Source Debugger for batch jobs
RPGLE debugging
Timing out display sessions in DDS
Building Dynamic Stored Procedures
Put Message in System Log
Dynamic RPGSQL
Randomize function for the AS/400
What's the fastest way to do a simple RPG lookup?
First time Data queue application in RPG
Print file overflow in ILE RPG
Mapping Fields To Arrays in ILE RPG
Named inidicators
STRQMQRY: comparision operator '=' isn't correct?!
DSPDTAARA to an outfile - possible?
PCL ESC codes in RPG
Sharing DB files between two AS/400s
Help: AS/400 subfiles
How do you change the signon screen?
Determining Even/Odd Values in queries
Get day of the week in RPG
Convert UPPERCASE to lowercase
RPG IV help using APIs
Help with data area API
Detecing IFS Files from RPG
SQL in a CL program
Calling AS/400 APIs from ILE RPG
CVTDAT command to convert an *MDY to a *LONGJUL
CPYSPLF Automation
Subfile Window background problem
Using IFS APIs w/ ILE RPG
Packed or unpacked fields?
QRYDFN to source and back
What does the "optimize" parm do?
Determining the calling program
Sockets in RPG?
Sorting a user space
OVRDBF and SECURE() keyword in an ILE environment
RPG record locking
RPG Differences: V2R3 to V3R2 upgrade
Getting the relative record number (RRN)
What is the longest parameter usable in RPG?
A C function that returns a string to an RPG pgm
Problems with ZADD *ZEROS
Can you highlight code in SEU?
Reusing deleted records - OK?
Is there an easy way to change edit codes?
Help - Windowed Subfiles
Logical Files and DDS
AS/400 'machine language' - MI Programming
Library lists and performance
How to use ERRSFL
Updating in CL
Record lock wait time
Message subfile problem
Physical File Joins
CL: Copying User Profiles
Commands and PARM
ILE RPG, RPG IV, vs. RPG/400
RPG and subfiles
Multiple subfiles
Field masking for passwords
SFLMODE keyword in an ILE program
Subfile size
Color coding records in a subfile
MSGLINE in windows
Controlling cursor movement on a display file
API returns error! Why?
Put an RPG Program on the Web
Variable length records in RPG
Differences Between RPG400, RPG IV, and ILE RPG


You are at a news400.com site.
Contact Us | Report Bugs | Submit Comments/Suggestions | Read Site Use Agreement | Read Privacy Policy
Copyright © 2000 Duke Communications International.
This site is best viewed with the latest versions of Netscape or Internet Explorer, 800 x 600 resolution (or higher), and at least 256 colors.
Duke Communications   NEWS/400 | 29th Street Press | Business Finance | DominoPro | Selling AS/400 Solutions | SQL Server Magazine | Windows NT Magazine