DDS with temporary name for Physical file

115 pts.
Tags:
CL programs
DDS
Logical File
Physical File
Good day all ! On AS400 I have a CL program that creates a temporary Physical file with variable name. File name is created with "user_id + job_name + time". How can I create a logical file, specifying in DDS for logical file that my PFILE is temporary and has variable name ? Thanks !
ASKED: April 9, 2009  1:41 PM
UPDATED: January 19, 2010  12:28 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

I’d say you have 2 possibilites for this :-

1. Update your DDS source with the new temporary name. You could write a program to update the source before you compile the logical.

2. Use SQL to create a VIEW over the physical file. You could use RUNSQLSTM to do this.

Regards,

Martin Gilbert.
///////////////////////////////////
Martin’s right – always.
Here’s a number 3 for the list –
3. use OPNQRYF

Phil

//////////////////////////////////
Martin will probably improve this answer in the morning.
1. If you create a view, it will work great with subsequent SQL commands
but I don’t know what other processes it will work with, or what you want to do.
A logical and a view only seem the same, they are very different things.

2. I think the source has to be altered — which will require a program to put the view
name and the from table name into the view source before you can create it.

3. The code to change the source of the view is about the same as the code to change
the source of the logical so you may not gain anything by going with the view over the logical.

alternatively
4. In RPGLE you could build the charater string that represents the view and do the stuff to run a dynamic SQL
command – prepare a statement and run it…

5. And then user_id + job_name + time seems too long – our object names can only be 10 char’s long

Here is an easy alternative .. although we haven’t talked about how you will use it – so this might be better or useless – physical files and logical files can have more than one member just as source does.

1. create the generic pf and lf – either in your CL or they could be permanent objects

2. add a member to the generic PF addpfm — the member name can be your variable (10 char max)

3. add a member to the generic LF addlfm
you fill in the part of addlfm that identifies the physical file and the member name

4. ovrdbf generic to specific members
or
4sql. for SQL use create an alias for the specific member
5. use files
6. dltovr or drop the alias
7. rmvlfm, rmvpfm

Phil

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Lenny2113
    Martin, Phil : Thank you for your help. My background is mainframe where JCL is used instead of CL... I am not sure how this can be done. Please pardon my ignorance. If in my CL program I do RUNSQLSTM command should the source for CREATE VIEW be in a specific file type? This is a code from my CL program which defines physical file called &WKPF: CRTPF FILE(QS36F/&WKPF) SRCFILE(LENNYTEST/QDDSSRC) + SRCMBR(G4TENSWK) OPTION(*NOSRC *NOLIST) + LVLCHK(*NO) RUNSQLSTM SRCFILE(LENNYTEST/QDDSSRC) SRCMBR(CRTQRY1) /* CRTLF FILE(QS36F/&WKLF) SRCFILE(LENNYTEST/QDDSSRC) + SRCMBR(G4TENSLF) */ /* */ /* */ In CREATE VIEW statement can I code symbolic parameters which are given value in my CL program? CREATE VIEW &WKLF -- (parameter is supplied from CL) AS SELECT COMPNY, PROJNO, BLDNUM, UNTNUM FROM &WKPF ; This is my logical file that I need to replace by "create view" A R G4TENSR PFILE(G4TENSWK) A* A K COMPNY A K PROJNO A K BLDNUM A K UNTNUM Thank you ! Lenny
    115 pointsBadges:
    report
  • Supriyob2
    Can this be done using CPYF...I mean once the temporary PF is created ,if we copy the data from the temporary file to a permanant PF using a CL pgm by CPYF..and then create a LF on this PF.. I assume that the strucrure is temporary file is known. Please correct me if wrong. Regards, Supriyo
    165 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following