Solved

Accessing Mutlimember Files

Posted on 2004-09-01
10
418 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

21 Experts available now in Live!

Get 1:1 Help Now