CPYF alternative

525 pts.
Tags:
AS/400
AS/400 jobs
CPYF
Hi, One of out Auto start job is locking a file (A). (triggers are used and it is designed like that only) And another program which copies the file (B) in to (A) by CPYF is going to MSGW, telling the object is locked. How we can overcome this...are there any alternate solutions to copy that file?

Software/Hardware used:
AS400

Answer Wiki

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

Discuss This Question: 30  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
  • TomLiotta
    A trigger doesn't make much sense for a file that will be the target for a CPYF. Please show the CPYF command so we have a little better understanding of the process. . Tom
    125,585 pointsBadges:
    report
  • Anu143
    Thanks Tom, " UAT1992 ***ATM: (******) 13/05/06 22:42:10 AT588 UAT1992 ATMP Cutover, sequence number 035, program ******, job A***** - Send ATM/Debit card to As400, ended abnormally. " This is the error we are getting in production. This is failing at the copy command. " CPYF FROMFILE(A*)TOFILE(A**) + MBROPT(*REPLACE) FMTOPT(*NOCHK) " (A**)- is the file locked. As I told before about the autostart job... which is always locking this file.. this is the existing design, we cant make any change to this.. Is there any other way to copy the records to A** file. Please advice .. Many thanks.. Anu
    525 pointsBadges:
    report
  • TomLiotta
    What kind of trigger is it? INSERT, UPDATE or DELETE? Is it BEFORE or AFTER? . As long as a lock exists that prevents the clearing of the file for *REPLACE, it will never work. CPYF can require a lock similar to *EXCL. No other locks can exist at that time. . You're using FMTOPT(*NOCHK) which is bizarre if this is production code. Why is *NOCHK needed? If it's needed, there might be no alternative except to write a program to do the work and give up on CPYF. . Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    And what does the trigger have to do with any of this? It shouldn't make any difference. -- Tom
    125,585 pointsBadges:
    report
  • Anu143
    I will come again. there are two jobs. 1. Auto start job ( application for tracking the customer data) 2. Our job which is failing at CPYF command. The auto start job is designed in such a way that what ever changes happened to the files ( there are almost 40 file , with Insert,update,delete After-trg added) It will be written to a common trigger file and records are processed from there. All the 40 files will be locked , when the subsystem is started. like given below A**** MBR *SHRRD HELD *JOB MBR *SHRRD HELD *JOB DATA *SHRRD HELD *JOB DATA *SHRRD HELD *JOB Now here we got two different systems ATM and banking sys. Files from ATM is send to Banking system using the second job. using the copy file command. so what should be the alternate way to copy the files from ATM to banking system..(as the file at banking system is always locked) Can we use SQL RPGLE.. ?? Or any other logic we can use Please advice.. Thanks Anu
    525 pointsBadges:
    report
  • Anu143
    Any body pls advice...its little bit urgent :(
    525 pointsBadges:
    report
  • CharlieBrowne
    You can use SQL Delete to delete the records. Then use CPYF mbropt(*ADD) to put in the new records. Be sure the set the attribute of the PF to be REUSEDLT(*YES)
    41,370 pointsBadges:
    report
  • Anu143
    Thanks a lot! Will confirm once this is accepted by our team...thanks a lot again
    525 pointsBadges:
    report
  • Anu143
    But one more issue...to change the PF attribute, we need to do CHGPF after that right?
    525 pointsBadges:
    report
  • Anu143
    And is it possible to do a CHGPF on a locked file ...this file is locked 24x7!!!
    525 pointsBadges:
    report
  • CharlieBrowne
    No, you cannot do a CHGPF on a locked object. You would have to end the other job and and any other jobs using the file, then make the change and start the other job again.
    41,370 pointsBadges:
    report
  • Anu143
    Charlie.. The thing is that we cant bring down the other job..as it is a highly critical job. Do we have any other way..to do this.. Sorry if I'm asking too much..
    525 pointsBadges:
    report
  • Anu143
    Else we need to wait until..the subsystem is down
    525 pointsBadges:
    report
  • CharlieBrowne
    No problem asking the questions. Yes, you will need to wait untile the subsystem is down to make the changed. But depending on the size of this file, you could start the other process of using SQL DELETE and then CPYF wiht *ADD, right now. You would need watch disk space and then in addition to do the CHGPF command later, you would also want to do a CLRPFM or RGZPFM command because you have a largeer number of deleted records in the fiel.
    41,370 pointsBadges:
    report
  • BigKat
    when you do this SQL delete, you are going to fire the trigger for EVERY record in the file. Depending on how many records there are and how complex the trigger is, this could add up to a significant amount of time
    8,060 pointsBadges:
    report
  • Anu143
    Thank you all! I will check it. I hope the file is not added a delete trigger but I'm not sure. Thank you all for your valuable support.
    525 pointsBadges:
    report
  • ToddN2000
    Why would you do a CHGPF? That would only be if the file layout is changing. Then it would need to be done on both sides, the from and to files. I assume you are not adding or removing fields from a record definition. They could impact other software/programs if the formats no longer match.
    9,700 pointsBadges:
    report
  • Anu143
    Todd, just marking an attribute as *yes as it will act like doing RGZPFM
    525 pointsBadges:
    report
  • BigKat
    Hi ToddN2000 You can use CHGPF without specifying the source files to change other attributes of the file - in this case REUSEDLT(*YES) - you just leave the default value SRCFILE(*NONE)
    8,060 pointsBadges:
    report
  • Anu143
    Yeah...right Big Cat
    525 pointsBadges:
    report
  • TomLiotta
    It will be written to a common trigger file and records are processed from there.
    .
    Why not just journal the file? Use the journal images instead of a "common trigger file". What is the purpose of the "common trigger file"?
    .
    Can we use SQL RPGLE.. ??
    .
    You can, but I don't see any way yet to guarantee that it won't give the same result. It is still likely to result in CLRPFM if you're going to delete all rows before adding the new ones. You could READ each row and then DELETE each one individually with native I/O.
    .
    And it's not clear yet why *NOCHK is needed. It seems that you might be wanting to copy multiple different physical files into a single program-described target file.
    .
    Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    If you want to do a CHGPF REUSEDLT(*YES), you only have to do it once. It will only take a few seconds. -- Tom
    125,585 pointsBadges:
    report
  • Anu143
    Guys.. we got a problem here.. our file is associated with Inser and delete trigger. so will an SQL delete query execution will trigger the job attached ?
    525 pointsBadges:
    report
  • Anu143
    awaiting your quick reply...
    525 pointsBadges:
    report
  • TomLiotta
    Actually, come to think of it, I don't know you can run a 'clear' type of operation against a table that has a DELETE trigger. If you use SQL DELETE statements, it should work. . There have been a few oddities related to 'clear' operations in different releases. I need to go back and read the Memo to Users documents for a few releases to remember what the details are for each release. . A 'clear' operation is something that causes all rows to become effectively deleted at once, for example, a CLRPFM or CPYF *REPLACE. If a DELETE statement has no WHERE clause, it can also be run by DB2 as a 'clear' operation. . Tom
    125,585 pointsBadges:
    report
  • Anu143
    So instead of doing the clear operation.. as I told these are two different systems.. and is there any other way .. that we can compare both the two files.. and do insert, delete, update accordingly ? Any way of using DDM ??
    525 pointsBadges:
    report
  • TomLiotta
    There are two files that you have mentioned: file (A) and file (B). The way that you have described the problem, only file (A) is causing a problem. If file (B) is being locked, then please explain why its lock needs to be *EXCL since that's the only lock state that could be any problem, and a trigger should not be involved in an *EXCL lock on its own file. Any lock state less than *EXCL won't stop you from copying from the file. In any case, it doesn't matter if it's one system or two systems. It doesn't matter if DDM is used. If a lock prevents the copy, it will be prevented no matter what. . As far as your description goes, the problem comes from the *REPLACE option. You can't use that if you have a DELETE trigger on the file even if their is no lock at all. You must either remove the DELETE trigger, disable the DELETE trigger, or use a different method to clear the existing records from the file. . To clear the existing records, you can use a SQL DELETE that deletes each record that needs to be removed or you can write a program that reads through the file and deletes the records. . Tom
    125,585 pointsBadges:
    report
  • Anu143
    yes Tom, we thought of using SQL delete before as to clear the file.. but it cannot be done as the file is added with delete trigger. I thought of using the DDM and to create a new file by adding trigger in that.. As the data from ATM is copied to the new file using DDM, and to add all three after trigger in the file.. which will call RPG program,,as to compare the new file with the file in banking system. and if a record is not there the trigger program will delete that record from the banking system.like wise for update and delete...here clearing is not done.. but all the triggers will work ..as correctly.. I hope so
    525 pointsBadges:
    report
  • TomLiotta
    ...but it cannot be done as the file is added with delete trigger.
    .
    That doesn't make sense. Why would the DELETE trigger interfere in this setup? If it did, then what's the purpose of the trigger when you need to do CPYF with *REPLACE? It should be easy to duplicate the file, data and trigger with CRTDUPOBJ; then you can test an SQL DELETE to see the result. If the trigger modifies a second file, there should be an existing test environment that can be used.
    .
    Tom
    125,585 pointsBadges:
    report
  • Anu143
    i'm really ..not getting what to do right now..
    525 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