× 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.



Vinay,

Try retrieving the object's description. If the object's spelling is
not valid for an object you will receive an error. A "Not Found"
message implies the spelling is correct. If diagnostic message CPD0078
is returned then you know the spelling is incorrect.

Below is a little CL program that checks an object's spelling and if a
file member already exists. I included &objType as a parameter just in
case you want to write up something that more generically checks an
object's spelling.

PGM Parm(&fileName &libName &mbrName &objType &valid
&exists)

Dcl Var(&fileName) Type(*Char) Len(10)
Dcl Var(&libName) Type(*Char) Len(10)
Dcl Var(&mbrName) Type(*Char) Len(10)
Dcl Var(&objType) Type(*Char) Len(10)
Dcl Var(&valid) Type(*char) Len(10)
Dcl Var(&exists) Type(*char) Len(10)

Dcl Var(&msgID) Type(*Char) Len(7)
Dcl Var(&msgFile) Type(*Char) Len(10)
Dcl Var(&msgLib) Type(*Char) Len(10)
Dcl Var(&msgDtaLen) Type(*Dec) Len(5 0)
Dcl Var(&msgData) Type(*Char) Len(256)

MonMsg MsgID(CPF0000 MCH0000) Exec(Goto HandleErr)

/*--------------------------*/
/* Assume naming is correct */
/*--------------------------*/


ChgVar Var(&Valid) Value('1')
ChgVar Var(&exists) Value('1')

/*-------------------------*/
/* Check object's spelling */
/*-------------------------*/

RtvObjD Obj(&mbrName) ObjType(&objType)

MonMsg MsgID(CPFB8ED CPF2115 CPF2150 CPF2151 +

CPF2173 CPF218C CPF218D CPF2451 CPF3202
+
CPF3203 CPF36F7 CPF980B CPF9801 CPF9802
+
CPF9803 CPF9807 CPF9808 CPF9810 CPF9811
+
CPF9812 CPF9814 CPF9820 CPF9821 CPF9822
+
CPF9825 CPF9830 CPF9831 CPF9833)


/*----------------------------*/
/* Check for member existence */
/*----------------------------*/


RtvMbrD File(&libName/&fileName) MBR(&mbrName)

MonMsg MsgID(CPF9815) Exec(Do)

ChgVar Var(&exists) Value('0')

endDo



/*----------------*/
/* End processing */
/*----------------*/

GoTo PgmEnd

HandleErr:



/*------------------------------------------*/

/* Receive Diagnostic message for spelling */

/*------------------------------------------*/



RcvMsg MsgType(*DIAG) MsgDta(&msgData)
MsgDtaLen(&msgDtaLen) +
MsgID(&msgID) MsgF(&msgFile)
msgFLib(&msgLib)


MonMsg MsgID(CPF0000 MCH0000) exec(GoTo PgmEnd)



If (&msgID *EQ 'CPD0078') Then(Do)

ChgVar Var(&Valid) Value('1')

GoTo PgmEnd

EndDo


/*----------------*/
/* End processing */
/*----------------*/

GoTo PgmEnd



/*********************************************************************/
/* End the Program
*/
/*
*/
/* Purpose: End program gracefully.
*/
/*
*/
/* Procedure: 1. End program.
*/
/*
*/

/*********************************************************************/


PgmEnd:


/*-----------------*/
/* End the program */
/*-----------------*/

Return

ENDPGM

HTH,

Gary Monnier

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Vinay Gavankar
Sent: Friday, September 09, 2011 6:55 AM
To: Midrange Systems Technical Discussion
Subject: Validating a File Member Name

Hi,

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.

TIA.

Vinay
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.