× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 09-Sep-2011 06:55 , Vinay Gavankar wrote:

What would be the most efficient way of validating that an input
provided on Screen is a value that can be used to add as a Physical
File Member later in the job stream (i.e. it starts with alphabet or
specific special characters, no embedded blanks, etc.)

I feel that it should be possible using some system commands and
MONSG etc. instead of writing RPG code to check, but cannot figure
out what it should be.


Very possible. The Check Command Syntax (QCMDCHK) API suffices.

The most obvious though perhaps not generally the most efficient would be to use the command that will eventually be utilized. For example, if the value will be used in ADDPFM, then generate and pass a valid command string with the MBR() parm value concatenated. For an idea of how, some command-line examples:

/* .........+.........+.........+.........+.. */
call qcmdchk ('*nlvlibl/addpfm literal/literal tenbytenam' 42)
call qcmdchk ('*nlvlibl/addpfm literal/literal 9bbadname ' 42)
Value '9BBADNAME ' for parameter MBR not a valid name.
Errors occurred in command.

Somewhat more efficient since the command is minimalist... Using the same means above but with a simpler user-created command such as CHKNAM:

//data /* mbr(chknam) */ endchar('//')
PARM KWD(MBR) TYPE(*NAME) LEN(10) MIN(1) MAX(1)
//
crtcmd chknam

call qcmdchk ('chknam validname ' 25) /* no errors logged */
call qcmdchk ('chknam *errname ' 25)
Value '*ERRNAME ' for parameter MBR not a valid name.
Errors occurred in command.

In the error cases, validation for CPF0001 as the *ESCAPE and then thee preceding diagnostic being CPD0078 giving the invalid value in replacement text variable &3. When no errors, the value in the string can be assumed to be correct when concatenated to the eventual complete ADDPFM command string.

Regards, Chuck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.