CL program to delete dependent files

400 pts.
Tags:
CL Program
Logical Files

Could any one please help me with the steps to write a CL program. I want to write a program in CL or any other language eg. RPGLE which will take physical file as an input and based on DSPDBR dependent logical files can be deleted.

Answer Wiki

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

All right,

  1. you need to ask, is filename enough, or do you need to pass in library as well.
  2. create a CL that will accept the parameters you decided on
  3. in that CL, use those parameters to run a DSPDBR command to a workfile (I prefer to put the file in QTEMP library)
  4. in the CL, loop through the workfile and use the values from the fields to run a DLTF command

Discuss This Question: 17  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
  • philpl1jb
    I would think this was available in TATool.
    50,860 pointsBadges:
    report
  • abhisheka1
    Could to help me to get the Source code please ..Thanks
    400 pointsBadges:
    report
  • BigKat
    Actually, this site exists to HELP YOU figure out your problems, not do the work for you.  We will point you in the direction to go (which you already know from your question)  We help correct syntax issues and the like.

    8,350 pointsBadges:
    report
  • abhisheka1
    BigKAT... ya I know the direction ..curious to know... how to write the code in CL for such automation ...
    400 pointsBadges:
    report
  • philpl1jb

    abhisheka1 Please show us your code and ask for specific assistance on it. 

    50,860 pointsBadges:
    report
  • ToddN2000
    Looks like you know the commands you need to use already. do your DSPDBR to a output file, read that file, then delete the logicals. What does your code look like? It should be a simple program.
    15,080 pointsBadges:
    report
  • RBDSILVA
    Good answer BigKat "Actually, this site exists to HELP YOU figure out your problems, not do the work for you". I work in Iseries since 1982 and i never saw a arrogant person like abhisheka1.  . Att; RBDSILVA

    550 pointsBadges:
    report
  • BigKat
    @RBDSILVA,
    Well, I'll give ABHISHEKA1 the benefit of the doubt and assume it is because of writing in a secondary language.  I probably do the same when I write in German.
    8,350 pointsBadges:
    report
  • abhisheka1
    @RBDISLVA : I read the question again , yes it doesn't sound smooth I agree ... @BigKAT : Thanks .. 
    400 pointsBadges:
    report
  • abhisheka1
    I changed the content of question.
    400 pointsBadges:
    report
  • ToddN2000
    If you want to pass the file/library as parameters or hard code them it's not much different. Declare 2 variables, "library" and "file". Declare a work file. DSPDBR your physical file and send the  output to your work file (the one you just defined). Then read this work file (RCVF). Change the variables of "library" and "file" using the fields in the work file. Then DLTF using the changed parameters you defined. Loop back to your RCVF and do until end of file. You can MONMSG to determine the end the job. Simple I did it in about 13 lines of code.
    15,080 pointsBadges:
    report
  • abhisheka1
    @ToddN2000 Thanks for the reply, @Bigkat thanks for the reply
    I test and let you know .....  :)

    **Can we implement the same without using DSPDBR. If we can then what would be the possible solution.Library and file we took as an input and can we check dependency by other ways.(Can we automate DSPDBR command in CL program).

    400 pointsBadges:
    report
  • BigKat
    you can code the DSPDBR command inside the CL program
    8,350 pointsBadges:
    report
  • ToddN2000
    You can probably do it another way but it would be MUCH more involved. You could do a DSPFFD over all files in all libraries to an outfile using the *ACCPTH option. Then read that file and select all files that have a physical file referenced that matches yours.
    15,080 pointsBadges:
    report
  • ToddN2000
    Sorry typo that should have been DSPFD not DSPFFD
    15,080 pointsBadges:
    report
  • abhisheka1
    Thanks all for sharing valuable information ... :)
    400 pointsBadges:
    report
  • bvining
    You asked: Can we implement the same without using DSPDBR. If we can then what would be the possible solution.Library and file we took as an input and can we check dependency by other ways.(Can we automate DSPDBR command in CL program).

    Other implementations do exist. One would be to use the List Database Relations (QDBLDBR) API within the CL program. The documentation for QDBLDBR can be found here.
    6,620 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