|
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
/free
// OVRDBF
@qcmdexc( 'OVRDBF FILE(EDISLSL6) SHARE(*YES)' );
// OPNQRYF
// looks ugly, but this code replaces the 'tags' with
// the start and end date for the date range.
cmd = string(1) + ' ' + string(2);
cmd = %replace( %editc( beginDate# : '4')
: cmd
: %scan('##STRT##' : cmd) );
cmd = %replace( %editc( endDate# : '4')
: cmd
: %scan('@@@END@@' : cmd) );
@qcmdexc( cmd );
if not %open( EDISLSL6 );
open EDISLSL6;
endif;
// read thru file and flag all records which have been pulled in via
// the OPNQRY.
read EDISLSL6;
dow not %eof( EDISLSL6 );
#wrtToWork();
read EDISLSL6;
enddo;
// CLOF and DLTOVR
@qcmdexc( 'CLOF OPNID(EDISLSL6)' );
@qcmdexc( 'DLTOVR FILE(*ALL)' );
/end-free
**
OPNQRYF FILE((EDISLSL6)) OPTION(*ALL) QRYSLT('ALPHF2 = "P "
*AND NUMF2 = %RANGE(##STRT## @@@END@@)')
OPNQRYF FILE((EDIINVL6)) OPTION(*ALL) QRYSLT('INPROC = "P"
*AND INPRDT = %RANGE(##STRT## @@@END@@)')
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.