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



Comments in line. Solution at bottom.


Gary Guthrie


MWalter@hanoverwire.com wrote:
> 
> If I understand your question, you'll have to create a logical file over
> the physical in order to do random I/O (ie. setll/read, chain). 


Actually, you need a FORMAT file, and that can be either physical or
logical. This file is created without even a member.


> You can order your physical file with an OPNQRYF but that really should be 
>used
> only for sequential processing.


Why are you of this opinion? You should access the results of the
OpnQryF however you want to, sequentially or randomly.


> The access path (Keyfield(s)) has to exist over the file for your RPG program 
>to compile.


Not quite right. The definition of the key structure must exist, not an
access path. This is the format file's role - to define the key
structure. The format file is simply a shell - it contains neither data
nor access path. It is a memberless file.


Muralidhar.N@blr.hpsglobal.com wrote:
> 
> I ve a file DAHDRT00(which doesnt ve keyfield) ,Iam doing opnqry by taking
> 3fields frm the file as  3keyfields) mentioned in ascending order on this
> file in my CL ,from there iam calling RPG ...Can i mention Record address
> type "k" on this file in my rpg prog? and do chain or use setll and read
> ?kindly suggest me ! here the code
> 
>  OVRDBF     FILE(DAHDRT00) TOFILE(*LIBL/DAHDRT00) +
>               MBR(*LAST) SHARE(*YES)
>  OPNQRYF    FILE((*LIBL/DAHDRT00 *LAST)) +
>               KEYFLD((DAHDRFCD *ASCEND) (DAHDRGRF +
>               *ASCEND) (DAHDRHFL *ASCEND))
>  CALL       PGM(*LIBL/DAD0070) PARM(&RTCODE)
>  CLOF       OPNID(DAHDRT00)
>  DLTOVR     FILE(*ALL)


Murali,

You can accomplish your goals using a format file to define the key
structure you need. You'll need to create a format file (I've called it
DAHDRT00F for the example). Use this format file in RPG as if it were a
normally database file. You'll need to modify your CL and I've included
a sample of that along with samples for the DDS for the format file and
RPG.


Format file structure DAHDRT00F (specify source type LF):


     A          R YOURREC                 PFILE(DAHDRT00)

     A          K DAHDRFCD
     A          K DAHDRGRF
     A          K DAHDRHFL

where YOURREC is the same record format name as specified in DAHDRT00.


Then in CL:


  OVRDBF     FILE(DAHDRT00F) TOFILE(*LIBL/DAHDRT00) +
               MBR(*LAST) SHARE(*YES)
  OPNQRYF    FILE((*LIBL/DAHDRT00 *LAST)) FORMAT(*LIBL/DAHDRT00F) +
               KEYFLD((DAHDRFCD *ASCEND) (DAHDRGRF +
               *ASCEND) (DAHDRHFL *ASCEND))
  CALL       PGM(*LIBL/DAD0070) PARM(&RTCODE)
  CLOF       OPNID(DAHDRT00)
  DLTOVR     FILE(DAHDRT00F)


RPG program DAD0070 (free format version, translate to fixed-format if
necessary):

FDAHDRT00F IF   E           K Disk
                                    
 /Free                              
                                    
    SetLL *Start DAHDRT00F ;
    Read DAHDRT00F ;
    DoW Not( EOF%( DAHDRT00F ) ) ;
      .
      .
      .
      Read DAHDRT00F ;
    EndDo ;

    *InLR = *On ;      
                       
 /End-Free        

You can also use Chain.


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.