Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overriding a file to use in Cobol program (AS400 CL and Cobol)

Status
Not open for further replies.

NVSbe

Programmer
Sep 9, 2002
153
BE
I need to override the logical file EDIAFRLE so it only contains a few records. It's important that this is done in the CL, so we don't need to pass all the parameters to the cobol program. Here's what I got:

cl
--
OPNQRYF FILE(EDIAFR) QRYSLT(&COMM) -
FORMAT(EDIAFRLE) OPNID(TST)
OVRDBF FILE(EDIAFRLE) TOFILE(TST)
CALL PGM(PTEST2)
DLTOVR FILE(*ALL)030211
CLOF TST


And in COBOL, I declare my file as follows:

PTEST2
INPUT-OUTPUT SECTION.
*---------------------
FILE-CONTROL.
SELECT EDIAFR ASSIGN TO DATABASE-EDIAFRLE
ORGANIZATION SEQUENTIAL.

However, when I try to open the file, I get a file status 42. Any thoughts? --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
Sorry, the file status I get is 35, file not present. It should be there though, OPNQRYF should create it. --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
Tofile had to be EDIAFR and SHARE(*Yes) had to be specified. If only I had thought of that yesterday, it'd saved me loads of searching... :D --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
I have used a logical file before, but I think I had to comple the DD file description. Might be more difficult if the files are not all in the same library. I think the files use also have to have dd file description compiled.
Why not just make a new logical file description??? If you do not like my post feel free to point out your opinion or my errors.
 
In this case, we had Logical E (LE) compiled, and it showed all records from EDIAFR in a certain order. However, we did not need ALL records from the file, just the onces that met a criteria. The OPNQRYF filters from EDIAFR the records that don't meet the criteria, and the OVRDBF command temporarily makes EDIAFRLE point to that Query File. This is convenient, because now, in the print program we only have to sequentially read records and print them. This way, the same print program can be used for all kinds of printing options on the EDIAFR file, depending on which file override was used. --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
By the way, if you're interested, this is the final CL code:

Code:
CHGVAR     VAR(&COMM) VALUE('AFEVERW=" " & AFEKODE="ORDERR"')  
OVRDBF     FILE(EDIAFRLE) TOFILE(EDIAFR) SHARE(*YES)           
OPNQRYF    FILE((EDIAFR)) OPTION(*ALL) FORMAT(EDIAFRLE) -      
             QRYSLT(&COMM) OPNID(TST)-                         
             KEYFLD(AFEKL AFEKODE AFEWERK AFEDOCK AFEWIEL -    
                    AFEAFRNR AFENRV AFEVLGNR)                  
OVRDBF     FILE(EDIAFRLE) TOFILE(EDIAFR) SHARE(*YES)           
CALL       PEDI100N                                            
DLTOVR     FILE(EDIAFRLE)                                      
CLOF       TST
--------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top