Would you like to get all the Files present in a particular Library?
Source Physical file doesnt contain the list of Files(Objects) in it. But, It will store the Source of a File or Program as Members.
If you declare Source Physical file using CL and if you try to Read the file, You can be able to get the Source details(DDS) of First Member of Source Physical file.
Instead of that, Maybe you can try DSPOBJD and store the Objects in OUTFILE.
<pre>DSPOBJD OBJ(LIBNAM/*ALL) OBJTYPE(*FILE) OUTPUT(*OUTFILE) OUTFILE(TEMP) </pre>
You can use the OUTFILE for getting the Available Files details in a Particular Library.
Pradeep.
Last Wiki Answer Submitted: December 16, 2011 10:19 am by deepu93213,370 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Actually i want to read all the files in a source physical files without declaring all the members in the F-Spec in rpgle.
For example Input src-pf consists of members A,B,C & D.(A,B,C,D are PF-DTA)
I have to read A,B,C & D without declaring them in F- Spec.
But INPUT(src-pf) can be used in F-Spec.
Do you mean, You want to Read the Data available in FIles?
I guess, you will not be able to do this. Because, Source Physical file doesnt contain the Data of the Files. But, It will just contain the Souce information as members.
Eg: If we consider There are three Files in a Source Physical file. And each file contains 100 Records.
You would have wrote the DDS Instructions for creating file. like,
R RECFMT
FLD1 10A
FLD2 20A
In this case, Source physical file will be holding the above DDS statements not the 100 records under that Physical File.
I think we cant be able to do this exactly.
Will you be little more specific about your requirement?
As, you mentioned, If you have A,B,C & D in your source physical file, You would like to Read the Data from those files.
What If you have more Files(Eg: 50 or 100)?
Mentioned more info about your requirement.
But, In Practical, Objects(*FILE) will be stored in Libraries.
So, Those cant be differenciated until you go and check for the Object Description.
The Source PF consists only Data PFs and no other object types. I want to read all those data PFs.
Read a SRCPF
then Read the Data PFs then write those datas to a Printer file .
If there are 50 Data PFs in that particular SRCPF i have to perform the read and write one by one upto the last file in that SRCPF.
Is this a possible one?
Then, Read the OUTFILE for getting the list of Files(Available under Source Physical File).
and the Read the Specified file using SQL(Defining in F – Spec is not Required) and populate the values to Printer File.
READ TEMPFL
Dow Not %EOF()
//Build Cursor on File FILENM //We are Reading FILENM from OutFile
//Fetch from Cursor and Store in Local Varables
Dow SqlCode <> 100 //SqlCod = 100 means End of File Receieved for the file Specified on Cursor.
//Perform Required Operations(Writing to Printer file
//Fetch Next from Cursor and Store in Local Varables
EndDo
READ TEMPFL
EndDo
In the above code, First Do loop will repeat till the Physical Files exist in the Outfile.
Second Do Loop will fetch the Data from the corresponding PF and will write to Printer file. It will Repeat the loop until the End of File of corresponding Physical File.
Try with the similar approach and let me know if you have any doubts in above procedure.
Above CPYF will print the Source(DDS Instructions) of the files under Source Physical file, isn’t it?
First, there is only one “file”. It can have many “members” (not “files”).
Second, I don’t know if I understand your question. If the source file contains DDS source members, then the CPYF will print the DDS source. But if it contains RPG source members, then it will print the RPG source.
If your question is about whether the CPYF command will print the DDS that defines the source file, no. It prints the content of the members, all members in the file (unless they contain some invalid data that throws an exception).
Yeah, I understood Tom. But, The Requirement of Sasi Kumar is bit different here. So, Just got confused with your answer.
You can find the Sasi Kumar’s post in Discussion for better understanding of his requirement.
During this discussion, we’ve got a bit of a clearer statement.
Print the actual data from a list of files
– the list being derrived from the member names in a source physical file
– I still doubt that the person asking this request has a clear understanding of the implications of their request. In the real world I would go back to them to discuss the issue further.
Additional spec requirements
1. What to do with rows that are wider than the printer
2. What to do with fields that are wider than the printer
3. What to do with files with millions of rows
4. What format of dates, numbers, negative numbers, what to do with large objects
then on the technical side
The CPYF to printer (of the data file) is the easist method and requires no RPG but leaves some fields in non-printing form. Works great, as Tom showed, for listing the source (all text and short lines).
The copy command CPYTOIMPF can create a readable file — doubt that it has a *PRINT option so this solution might copy the data to a “flat” file followed with a CPYF to send it to the printer. Again no RPG a few CL steps in a loop
But the RPG method contains dragons.
Somehow, between the select/fetch/write the actual field list for that file will need to be used to create a 80 or 132 character strings for printing.
Phil
Actually ERRSRC is my Source PF and it contains the files like ErrPF1, ErrPF2,…ErrPFn. All the Data PF consists of just a Common record ‘ERRDESC’. Now my requirement is i have to read all those ‘n’ PFs without declaring them using the F-spec and write the ‘ERRDESC’ to a printer file named as ‘ErrPRTF’. Is This possible or not? I had already created an outfile for DSPOBJD of that SrcPF(ERRSRC). What i have to do further?
OK
Option 1 CL program declares the outfile in a DCLF command
It uses the RCvf to get the next member name
If uses the CYPF to write the member to *print
it loops to the RCVF to get the next member
or
Rpgle has an F-spec specifing one of the files 9for compile purpuses only)
the F spec has the keywords USROPN and EXTNAME ( MyName )
and an input f spec for the file created in the out file
and a d-spec declaring MyName standalone 10 character
Program reads a record from Memberlist
sets MyFile = member name in member list
Opens file
reads each recor in file
writes each record in file
close file
loop to read record frm Memberlist
PHIL
Actually ERRSRC is my Source PF and it contains the files like ErrPF1, ErrPF2,…ErrPFn.
If ERRSRC is a source PF, then it doesn’t contain multiple files. It contains multiple “members”. But if ERRSRC is really a ‘library’, then it might contain multiple files. You need to clarify if ERRSRC is file or a library.
If it is a file, then how did you create it? What command was used to create it? That will tell us if it is a source PF or a data PF.
We need to know what ERRSRC really is in order to know how to process it.
“ErrSRC is created by the command CRTSRCPF in my library. It consists of the members like ErrPF1,ErrPF2,…..ErrPFn. All these members are of type ‘PF’.”
Is the data that you want to print in the file CRtSRCPF in the members ErrPF1 etcc
or
is the data that you want to print in the fiels ErrPF1, ErrPF2 …
— assuming the latter , that you have mulliple files NOT multiple members to work with
The files have the same record name and field structure.
The list of files could be obtained with the dspfd (mbrlst) of the sorce file
or
The list of files could be obtained with the dspobjd of objedts with names like ErrPF*
Quick and rough listing could be made in a CL program using looping throujgh DSPFD or DSPOBJD list to the cpyf each file to print.
More sophicated RPG program can loop throujgh the same file.
The ErrFile IF f-sped includes the EXTFILE( myvariable) and the USROPN keyword – we’re open this file after we’ve actually got it’s name.
The program reads a record from the DSPFD/DSPOBJD file and
sets myvariable = name from file
then it reads each record fro the file and prints a line
after all lines it reads the next record from the DSPFD/DSPOBJD file
and as long as there are records it loops.
If my assumption was wrong, then instead of using the EXTFILE keyword use he EXTMEM) keyword on the F-spec
Note: make the F-Spec refer to one of the existing files so it can compile.
Hope this helps.
And on with the game…The second baseman thows the ball to who, he catches it and throws the ball to the Catcher Tomorrow. Why did Who wait so logns?.
Phil
Ah! You are referring to the ‘Type’ column in a PDM list. You probably should learn that the PDM ‘Type’ is really only meaningful to PDM. It has nothing to do with what is contained in a member. You can put anything you want into the ‘Type’ and it won’t change anything important.
In fact, the you have described them, PF is probably not a good choice. You should change all of them to TXT or TEXT. They don’t appear to be intended as PF members. (But maybe they haven’t been explained to us completely.)
Try this program for an example:
FERRSRC ipe e disk infds( ESds )
DESds ds
D MEMBER 129 138
D PrvMbr s 10 inz
/free
if PrvMbr <> MEMBER ;
PrvMbr = MEMBER ;
dsply MEMBER ;
endif ;
/end-free
Compile it and run it to see what it does.
Then execute this command first and run the program again to see the difference:
OVRDBF FILE(ERRSRC) MBR(*ALL) OVRSCOPE(*JOB)
After you run the example program, run this command to clean up the previous override:
It’s in color when Dorothy is in Oz, but black and white in Kansas,
Thanks Tom.
Finally, it make sense, no I’m sorry it’s fading away!
What does the DSPOBJD do if the data is stored in a single file.
ErrSRC is created by the command CRTSRCPF ?
Then how does it have a record name? ERRDESC!
Actually i want to read all the files in a source physical files without declaring all the members in the F-Spec in rpgle.
For example Input src-pf consists of members A,B,C & D.(A,B,C,D are PF-DTA)
I have to read A,B,C & D without declaring them in F- Spec.
But INPUT(src-pf) can be used in F-Spec.
Do you mean, You want to Read the Data available in FIles?
I guess, you will not be able to do this. Because, Source Physical file doesnt contain the Data of the Files. But, It will just contain the Souce information as members.
Eg: If we consider There are three Files in a Source Physical file. And each file contains 100 Records.
You would have wrote the DDS Instructions for creating file. like,
In this case, Source physical file will be holding the above DDS statements not the 100 records under that Physical File.
Pradeep.
Is there any other ways to perform this task?
it will not able to do this… becoz object searching by library only… object doesn’t consider source physical file… object depend library…
I think we cant be able to do this exactly.
Will you be little more specific about your requirement?
As, you mentioned, If you have A,B,C & D in your source physical file, You would like to Read the Data from those files.
What If you have more Files(Eg: 50 or 100)?
Mentioned more info about your requirement.
But, In Practical, Objects(*FILE) will be stored in Libraries.
So, Those cant be differenciated until you go and check for the Object Description.
Pradeep.
The Source PF consists only Data PFs and no other object types. I want to read all those data PFs.
Read a SRCPF
then Read the Data PFs then write those datas to a Printer file .
If there are 50 Data PFs in that particular SRCPF i have to perform the read and write one by one upto the last file in that SRCPF.
Is this a possible one?
Then, I think you can follow the below procedure. Maybe you can be able to do it.
Get the List of Files which were stored under that Source physical file and store it to Temporary file.
Then, Read the OUTFILE for getting the list of Files(Available under Source Physical File).
and the Read the Specified file using SQL(Defining in F – Spec is not Required) and populate the values to Printer File.
In the above code, First Do loop will repeat till the Physical Files exist in the Outfile.
Second Do Loop will fetch the Data from the corresponding PF and will write to Printer file. It will Repeat the loop until the End of File of corresponding Physical File.
Try with the similar approach and let me know if you have any doubts in above procedure.
Pradeep.
If all you want to do is print them:
And it’s done.
Tom
Tom, Above CPYF will print the Source(DDS Instructions) of the files under Source Physical file, isn’t it?
Pradeep.
Above CPYF will print the Source(DDS Instructions) of the files under Source Physical file, isn’t it?
First, there is only one “file”. It can have many “members” (not “files”).
Second, I don’t know if I understand your question. If the source file contains DDS source members, then the CPYF will print the DDS source. But if it contains RPG source members, then it will print the RPG source.
If your question is about whether the CPYF command will print the DDS that defines the source file, no. It prints the content of the members, all members in the file (unless they contain some invalid data that throws an exception).
Tom
Yeah, I understood Tom. But, The Requirement of Sasi Kumar is bit different here. So, Just got confused with your answer.
You can find the Sasi Kumar’s post in Discussion for better understanding of his requirement.
Pradeep.
During this discussion, we’ve got a bit of a clearer statement.
Print the actual data from a list of files
– the list being derrived from the member names in a source physical file
– I still doubt that the person asking this request has a clear understanding of the implications of their request. In the real world I would go back to them to discuss the issue further.
Additional spec requirements
1. What to do with rows that are wider than the printer
2. What to do with fields that are wider than the printer
3. What to do with files with millions of rows
4. What format of dates, numbers, negative numbers, what to do with large objects
then on the technical side
The CPYF to printer (of the data file) is the easist method and requires no RPG but leaves some fields in non-printing form. Works great, as Tom showed, for listing the source (all text and short lines).
The copy command CPYTOIMPF can create a readable file — doubt that it has a *PRINT option so this solution might copy the data to a “flat” file followed with a CPYF to send it to the printer. Again no RPG a few CL steps in a loop
But the RPG method contains dragons.
Somehow, between the select/fetch/write the actual field list for that file will need to be used to create a 80 or 132 character strings for printing.
Phil
Actually ERRSRC is my Source PF and it contains the files like ErrPF1, ErrPF2,…ErrPFn. All the Data PF consists of just a Common record ‘ERRDESC’. Now my requirement is i have to read all those ‘n’ PFs without declaring them using the F-spec and write the ‘ERRDESC’ to a printer file named as ‘ErrPRTF’. Is This possible or not? I had already created an outfile for DSPOBJD of that SrcPF(ERRSRC). What i have to do further?
OK
Option 1 CL program declares the outfile in a DCLF command
It uses the RCvf to get the next member name
If uses the CYPF to write the member to *print
it loops to the RCVF to get the next member
or
Rpgle has an F-spec specifing one of the files 9for compile purpuses only)
the F spec has the keywords USROPN and EXTNAME ( MyName )
and an input f spec for the file created in the out file
and a d-spec declaring MyName standalone 10 character
Program reads a record from Memberlist
sets MyFile = member name in member list
Opens file
reads each recor in file
writes each record in file
close file
loop to read record frm Memberlist
PHIL
Actually ERRSRC is my Source PF and it contains the files like ErrPF1, ErrPF2,…ErrPFn.
If ERRSRC is a source PF, then it doesn’t contain multiple files. It contains multiple “members”. But if ERRSRC is really a ‘library’, then it might contain multiple files. You need to clarify if ERRSRC is file or a library.
If it is a file, then how did you create it? What command was used to create it? That will tell us if it is a source PF or a data PF.
We need to know what ERRSRC really is in order to know how to process it.
Tom
For a few minutes there, I actually thought I understood what you wanted to do.
Then I got confused again, must be age.
Abbott and Costello – “Who’s on First?” <– very funny/confusing American skit about baseball.
So what has a source file to do with the DSPOBJD command?
Abbott and Costello
WHO’s my current library, and WHAT’s a product library in my job’s library list.
Tom
ErrSRC is created by the command CRTSRCPF in my library. It consists of the members like ErrPF1,ErrPF2,…..ErrPFn. All these members are of type ‘PF’.
“ErrSRC is created by the command CRTSRCPF in my library. It consists of the members like ErrPF1,ErrPF2,…..ErrPFn. All these members are of type ‘PF’.”
Is the data that you want to print in the file CRtSRCPF in the members ErrPF1 etcc
or
is the data that you want to print in the fiels ErrPF1, ErrPF2 …
— assuming the latter , that you have mulliple files NOT multiple members to work with
The files have the same record name and field structure.
The list of files could be obtained with the dspfd (mbrlst) of the sorce file
or
The list of files could be obtained with the dspobjd of objedts with names like ErrPF*
Quick and rough listing could be made in a CL program using looping throujgh DSPFD or DSPOBJD list to the cpyf each file to print.
More sophicated RPG program can loop throujgh the same file.
The ErrFile IF f-sped includes the EXTFILE( myvariable) and the USROPN keyword – we’re open this file after we’ve actually got it’s name.
The program reads a record from the DSPFD/DSPOBJD file and
sets myvariable = name from file
then it reads each record fro the file and prints a line
after all lines it reads the next record from the DSPFD/DSPOBJD file
and as long as there are records it loops.
If my assumption was wrong, then instead of using the EXTFILE keyword use he EXTMEM) keyword on the F-spec
Note: make the F-Spec refer to one of the existing files so it can compile.
Hope this helps.
And on with the game…The second baseman thows the ball to who, he catches it and throws the ball to the Catcher Tomorrow. Why did Who wait so logns?.
Phil
All these members are of type ‘PF’.
Ah! You are referring to the ‘Type’ column in a PDM list. You probably should learn that the PDM ‘Type’ is really only meaningful to PDM. It has nothing to do with what is contained in a member. You can put anything you want into the ‘Type’ and it won’t change anything important.
In fact, the you have described them, PF is probably not a good choice. You should change all of them to TXT or TEXT. They don’t appear to be intended as PF members. (But maybe they haven’t been explained to us completely.)
Try this program for an example:
FERRSRC ipe e disk infds( ESds ) DESds ds D MEMBER 129 138 D PrvMbr s 10 inz /free if PrvMbr <> MEMBER ; PrvMbr = MEMBER ; dsply MEMBER ; endif ; /end-freeCompile it and run it to see what it does.
Then execute this command first and run the program again to see the difference:
After you run the example program, run this command to clean up the previous override:
It’s in color when Dorothy is in Oz, but black and white in Kansas,
Thanks Tom.
Finally, it make sense, no I’m sorry it’s fading away!
What does the DSPOBJD do if the data is stored in a single file.
ErrSRC is created by the command CRTSRCPF ?
Then how does it have a record name? ERRDESC!
Phil