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



Thank you very much for ScottFor this program, it worked like a charm

On Thu, Apr 2, 2009 at 2:18 AM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>wrote:

Hello Ashish,

HiI have a about 15 members in SRC-PF QDDSSRC in library MYLIB,
i want to write a RPGLE program to loop through all the 15 members, and
check if a object exist for this member, if not then use CRTPF to create
a
physical file if the type is PF or CRTLF if the type of file is logical

Let's see if I have this straight:

a) You want to get a list of members.
b) For each member, you want to check if a file exists that has the same
name as the member name.
c) If the file doesn't exist, you want to create it.

You don't actually want to read the contents of the members, then? And
you're not concerned with the chances that the member name might not
match the object name?

That being the case, I'd do this purely in CL. I wouldn't use RPG at
all. I'd just do something like the following:

PGM

DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) VALUE('MYLIB')
DCL VAR(&OBJLIB) TYPE(*CHAR) LEN(10) VALUE('MYLIB')
DCL VAR(&EOF) TYPE(*LGL) VALUE('0')
DCLF FILE(QAFDMBRL)

DLTF FILE(QTEMP/MBRLIST)
MONMSG CPF2105

DSPFD FILE(&SRCLIB/QDDSSRC) TYPE(*MBRLIST) OUTPUT(*OUTFILE) +
OUTFILE(QTEMP/MBRLIST)
OVRDBF FILE(QAFDMBRL) TOFILE(QTEMP/MBRLIST)

LOOP: RCVF
MONMSG CPF0864 EXEC(CHGVAR VAR(&EOF) VALUE('1'))

IF (&EOF *EQ '0') DO

CHKOBJ OBJ(&OBJLIB/&MLNAME) OBJTYPE(*FILE)
MONMSG MSGID(CPF9801) EXEC(DO)
IF (&MLSEU2 *EQ 'LF') DO
CRTLF FILE(&OBJLIB/&MLNAME) +
SRCFILE(&SRCLIB/QDDSSRC)
ENDDO
ELSE IF (&MLSEU2 *EQ 'PF') DO
CRTPF FILE(&OBJLIB/&MLNAME) +
SRCFILE(&SRCLIB/QDDSSRC)
ENDDO
ELSE IF (&MLSEU2 *EQ 'DSPF') DO
CRTDSPF FILE(&OBJLIB/&MLNAME) +
SRCFILE(&SRCLIB/QDDSSRC)
ENDDO
ELSE IF (&MLSEU2 *EQ 'PRTF') DO
CRTPRTF FILE(&OBJLIB/&MLNAME) +
SRCFILE(&SRCLIB/QDDSSRC)
ENDDO
ENDDO

GOTO LOOP
ENDDO

DLTOVR FILE(QAFDMBRL)
DLTF FILE(QTEMP/MBRLIST)

ENDPGM

Good luck
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-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.