Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Accessing Mutlimember Files

Posted on 2004-09-01
10
Medium Priority
?
453 Views
Last Modified: 2012-06-21
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
Comment
Question by:Philip_Lang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
10 Comments
 
LVL 1

Accepted Solution

by:
SuperCCA earned 500 total points
ID: 11950974
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
 
LVL 14

Expert Comment

by:daveslater
ID: 11954456
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
 
LVL 14

Expert Comment

by:daveslater
ID: 11954503
Ps
this will not work if you are using SQL.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 1

Expert Comment

by:SuperCCA
ID: 11954737
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
 
LVL 14

Expert Comment

by:daveslater
ID: 11955498
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
 
LVL 1

Expert Comment

by:SuperCCA
ID: 11956443
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
 
LVL 14

Expert Comment

by:daveslater
ID: 11957972
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
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 500 total points
ID: 11959467
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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question