|
Sorry, I forgot to add some definitions that you'll need to use some of that code. Here's a more complete version. -----Original Message----- From: Mike Haston ** Data Sent: Thursday, April 03, 2003 8:08 AM To: RPG programming on the AS400 / iSeries Subject: RE: Dynamic embedded OPNQRYF in RPG Hopefully this will help. You can use scan & replace a little differently, but this is the general idea of OPNQRYF in an RPGLE program. -----Original Message----- From: heba refaie [mailto:heba_refaie@xxxxxxxxxxx] Sent: Tuesday, April 01, 2003 5:04 AM To: RPG400-L@xxxxxxxxxxxx Subject: Dynamic embedded OPNQRYF in RPG Hi Group, I need an example to show how to use Dynamic embedded OPNQRYF in RPGLE program, if possible. For example, if I have FileA which is a holding file and I would like to select all the expired orders where ExpDat = :Today's date . I searched in the archives but could not find a published example, although the question was asked before. Thanks beyond measures, All the best. Heba
h bnddir( 'QC2LE' )
h dftactgrp( *no )
fSUS100AL uf e disk usropn
d @qcmdexc pr 10i 0 extproc( 'system' )
d command * value options( *string )
d cmd s 3000a
d string s 80a dim(2) ctdata perrcd(1) varying
d today s d inz(*job)
d today# s 8s 0
c move today today#
/free
// OVRDBF
@qcmdexc( 'OVRDBF FILE(SUS100AL) SHARE(*YES)' );
// OPNQRYF
cmd = string(1) + ' ' + string(2);
cmd = %replace( %editc(today# : '4') : cmd : %scan('########' : cmd) );
@qcmdexc( cmd );
if not %open( SUS100AL );
open SUS100AL;
endif;
// read thru file and flag all records which have been pulled in via
// the OPNQRY.
read SUS100AL;
dow not %eof( SUS100AL );
%subst( PA_XT2 : 1 : 1 ) = 'P';
update PA_REC;
read SUS100AL;
enddo;
// CLOF and DLTOVR
@qcmdexc( 'CLOF OPNID(SUS100AL)' );
@qcmdexc( 'DLTOVR FILE(*ALL)' );
*inlr = *on;
/end-free
**
OPNQRYF FILE((SUS100AL)) OPTION(*ALL) QRYSLT('PA_ERROR = "Y"
*AND PA_PDATE = ########')
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.