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 / Commands and PARM


Question:

Please help a frustrated person!!! I am trying to create a command which will accept five or six parameters. One parameter is called CONO. I would like this parameter CONO to only accept two-character text strings (Z1, AB, JW etc) *OR* the special value of *ALL. The problem I have is with the length of the parameter. If I define it of type *CHAR with a length of two then it will not compile, saying that *ALL is not valid. If I compile it with a size of four then it will accept any string upto four characters (ABCD etc) and does not enforce the two-character rule. I know it can be done, as I have seen a non-IBM command do ikt (EXCAMTASK, in the JBA software) but I cannot figure it out for myself. All help very much appreciated!


Answer(s):



One way to do this is to define the parameter with a length of 2 and specifying in the special value list something like (*ALL xx), where xx is the value the CPP will receive when the command is executed using the special value *ALL. The value you assign to xx can be a value you cannot type using the keyboard (e.g. x'0000') so you don't have to reserve a two-character combination for this special value. HTH




Yep, that was the one. It was the replacement-value field I wasn't using. Many thanks,




Try this PARM KWD(CONO) TYPE(*CHAR) LEN(2) RSTD(*YES) VALUES(Z1 AB JW) SPCVAL(*ALL *A) ... When the value *ALL is entered, you receive the translated value *A in your command processing program. If you allow multiple values eg MAX(n) you should use SNGVAL(*ALL *A) Good luck!




You can specify a RANGE (e.g. from "AA" to "ZZ") in the PARM-Keyword. Just prompt with F4, then you will see it.




First thought (speaking from memory, I'm away from my AS/400), is to make sure that your PARM statement says something like SPCVAL((*ALL ' ')). Of course, you hereby lose the ability to process a CONO of all blanks (or whatever other value you are willing to give up). If this does not work, let me know and I shall be glad to look further




Try this: PARM KEYWORD(CONO) TYPE(*CHAR) LEN(2) SPCVAL((*ALL ' ')) The special values allow you to override type and length checks on a parameter with special values (imagine that?). Each special value has two values value 1 is what the user types in the command. Value 2 is the replacement value that is sent to your program. Value 2 must be of the same base type and length declared for the PARM. Special values are exempt from most of the validity checking rules and so are the replacement values. In the above example, when the user types CONO(*ALL) your program will actually see " " (blanks) See the CL programmer's guide for details




THAT LOOKS LIKE THE ONE!!!!!! I had wondered what the 'substitution value' field was for, but didn't put two and two together. I shall try it tomorrow. Many thanks,




Here's one way: PARM KWD(CONO) TYPE(*CHAR) LEN(2) RSTD(*YES) + VALUES(Z1 AB JW) SPCVAL((*ALL '**')) Here's another: PARM KWD(CONO) TYPE(*CHAR) LEN(2) RST(*YES) + SPCVAL((*ALL '**') (Z1) (AB) (JW)) Note that if the user enters *ALL, your CPP will see **.




This really does not resolve the *all option, but we have a program that accepts a parm value of '01' thru '10', or 'AL' for all values. We then have program logic that recoginizes that it needs to handle 'AL' differently. It may be a workaround for you. Good luck.





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