• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

Accessing Mutlimember Files

Using the below command as part of a CL Program

DSPFFD     FILE(*USRLIBL/*ALL) OUTPUT(*OUTFILE) +
             OUTFILE(LIBRARY/FILENAME)  

This command list all files and fields in given library list
I'm using this Outputfile (Library/Filename) in a program to change the value of a particular Common 'Field' meeting certain critera for all the files in the library(*USRLIBL/*ALL).

 
Field Partno; change the value 445 to 544 for all files with Field Partno
with out specifying all file names the above command accomplishes this.

Problem:
But the only problem I have is when it encounters a multimember file it only outputs the first member of a mutlimember file, hence I cannot update the remaining multimember files leaving the update incomplete.
             
0
Philip_Lang
Asked:
Philip_Lang
  • 4
  • 3
2 Solutions
 
SuperCCACommented:
Hi

The part of the object description output from DSPFFD is common to all members and hence the information is not provided at the memeber level.

To solve the probelm you need a second file that lists the members for each file. This can be obtained at the command (rather than API) level using DSPFD TYPE(*MBRLIST).

In your program you will need to loop through your existing processing for each member in the second output file.

Cheers
0
 
daveslaterCommented:
Hi
what you can do is use the

OVRDBF FILE(FILE) TOFILE(*FILE) MBR(*ALL)  

call mypgm

dltovr File

your program that is perfoming the update will then update all members in the file sprcified.

Dave
0
 
daveslaterCommented:
Ps
this will not work if you are using SQL.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
SuperCCACommented:
Hmmm

Dave I don't think so if I've understood the question:

1. It is unclear how the update of the value is being performed but obviously if it is SQL there is no support for *ALL member overrides.

2. If the program doing the work is using some other generic approach such as Program Described Files then it would be necessary to repetitively OPEN and CLOSE the target file within the "mypgm" for the override to take effect.

Cheers
0
 
daveslaterCommented:
Hi SuperCCA

I think it is a generic approach that is required, ie get the file, field and field position from the DSPFFD.
This can then be passed to a CL the will perform the override and then pass the field position to the RPG / Cobol program can then use a program described file to substring the relevant data check the value and perform the update.

This would lend itself to the mbr(*all) method.As all records in all members will be processed.
The override would need changing
OVRDBF FILE(FILE) TOFILE(*FILE) MBR(*ALL)  

to
OVRDBF FILE(internalfile) TOFILE(requiredfile) MBR(*ALL)  

Dave

0
 
SuperCCACommented:
Dave

Hang about, the last thing we want is for the chap to get involved with generic program described files. What if it's packed or binary data? The code is unnecessarily nasty, SQL is the way to go on this one.

Colin
0
 
daveslaterCommented:
Hi
You are of course right. I just love being techie - it’s my biggest downfall I just get carried away :-) and I do need some one to say Dave what are you thinking.

Dave
0
 
tliottaCommented:
Philip_Lang:

You apparently have nearly all of the logic you need. You now need to add the logic to process against each member.

Personally, the first thing I'd probably do is delete all records from your LIBRARY/FILENAME outfile where WHFLDE<>'PARTNO' just to keep it clean.

Then, I'd read the remaining records one at a time. Each record should give you a unique library and file name combination. I'd feed that into a command like this:

  DSPFD FILE(&WHLIB/&WHFILE) TYPE(*MBRLIST)  +
      OUTPUT(*OUTFILE) FILEATR(*PF) +
      OUTFILE(QTEMP/MBRLIST)

Now you can read from that file one record at a time. For each one that has MLNRCD>0 do:

  OVRDBF   &WHFILE  TOFILE( &WHLIB/&WHFILE )  +
      MBR( &MLNAME )

  RunSql  'update &WHFILE set Partno = 544 where...'

  DLTOVR  &WHFILE

The details of the RunSql command are up to you. A QM Query can be used or whatever technique gets you there. The point is that you want to issue the OVRDBF to point SQL to each member and then do the DLTOVR to remove the override before looping back to process the next member for that file. The MLNRCD>0 is an extra piece that says only do it for the current member if the member actually has some records in it.

Since the SQL standard has no useful concept of "members", the OS/400 non-default members are processed by using overrides before executing the SQL.

After you've processed every member for a file, read the next record from your original LIBRARY/FILENAME outfile, display its members into your second outfile, process all those members, etc.

It shouldn't be but a few more lines of code,

Tom
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now