0 pts.
 Query in CL programming
Im trying to get the following details within a CL program. Pointers to achieve the same would be highly appreciated. 1. Obtain the number of members in a given Physical file. 2. Facility to override a particular member in a multiple member physical file using a reference instead of member name. i.e. if i want to override the 4th member (i dont know its name) how do i do it? Thanks in advance. C

Software/Hardware used:
ASKED: November 23, 2004  9:23 AM
UPDATED: November 24, 2004  5:15 PM

Answer Wiki:
Bottom line, you need the member name in order to override to it (unless it is the only member or it is the first/last member). So you need to generate a list of the member names and choose from this. To get the number of members of a physical file simply use the command: DSPFD &library/&file TYPE(*MBRLIST) OUTPUT(*OUTFILE) OUTFILE(qtemp/&outfile) This will generate an outfile with a record for each member of the physical file containing all the details of the member. You will find that there is a field MLNOMB on each record which has the total number of members in the file. To determine which is say the 4th member depends whether you mean the 4th member alphabetically or the 4th member by date. If it is the 4th listed member alphabetically just read the outfile 4 times to get the member name then you can perform the override using OVRDBF specifying the member name in the record. If it is the 4th member by date this is a little trickier since the DSPFD only lists members in alphabetical order. It is possible to pick up the first member by date using: RTVMBRD &library/&file MBR(*FIRST) RTNMBR(&member) as opposed to: RTVMBRD &library/&file MBR(*FIRSTMBR) RTNMBR(&member) which picks up the first member by name. However, you can't then get the next member by date using: RTVMBRD &library/&file MBR(&member *NEXT) RTNMBR(&member) because the *NEXT option only gets the next member by name. Oddly there is no equivalent *NEXT option to retrieve by date! You only solution in this case is to list the members to an outfile as before and perform a sort by the create date field perhaps using a logical file. I suspect you are probably only interested in the alphabetical scenario so go with the first method.
Last Wiki Answer Submitted:  November 24, 2004  5:15 pm  by  Deadleaves   0 pts.
All Answer Wiki Contributors:  Deadleaves   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _