From MidrangeWiki
Jump to: navigation, search

Explanation for the Program

For various reasons, to be explained in later links, Query is humongously popular at many AS/400 sites but at the same time comes with a mountain of security concerns.

Thus, IT wants to let co-workers run most any Query they please, from some Menu, but not from either command line or IBM commands, which can let them get into unwanted mischef.

Here is a simple CLP/400 program that permits users to key in what file they want to dump via Query, using whatever selection criteria, while leaving contents of the file intact.

A remaining challenge is that ideally we want people to do this stuff, then have their Query selection head off to the JOBQ for actual execution, especially when some files have millions of records. Programming that is more complex than this example.

This program is one of a set of related CLP/400 examples.

RUNQRY *N some_file_name

You can use Query to view the contents of some file, without having a pre-defined Query definition.

Here is the Source Code

/*                                                                   */ 
/* Program INVENGFILE runs RUNQRY *N for FILE of operator choice     */ 
/*                                                                   */ 
 /*                Chapter SIX of CL manual explains the rules        */ 
              RUNQRY     QRY(*NONE) ??QRYFILE((IIM)) RCDSLT(*YES)        
             MONMSG     MSGID(CPF6801) EXEC(GOTO CMDLBL(ENDIT)) /* +    
                         F3 F12 etc. allowed */                        
       ENDIT:      ENDPGM