Solved

Accessing Mutlimember Files

Posted on 2004-09-01
10
406 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
  • 4
  • 3
10 Comments
 
LVL 1

Accepted Solution

by:
SuperCCA earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Ps
this will not work if you are using SQL.
0
 
LVL 1

Expert Comment

by:SuperCCA
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 14

Expert Comment

by:daveslater
Comment Utility
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
Comment Utility
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
Comment Utility
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 125 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now