Update duplicate record in rpgle

55 pts.
Tags:
Duplicate records
RPGLE
Update
I have a file where in filed1, field2 and field3 are key fields. Now these key fields are not unique, I need to update field 4, 5 and 6 based on the selection by user via subfile. To say f1 f2 f3 f4 f5 f6 A0123 A0123A *FILE CLM/D07 D07 1 A0123 A0123A *FILE CLM/D08 D08 2 A0123 A0123A *FILE CLM/D05 D05 1 A0123 A0123A *FILE CLM/D05 D05 2 Now i need to change the 4th record's f6 to 3. Whenever i do Chain its picking 3rd record that is fine by definition of chain, please help me to build logic to update 4th record when user selects option '2' against 4th record and to update 3rd record when user selects '2' against 3rd record. Please help..

Answer Wiki

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

You have various options:

1. Create a new LF where the key would be unique.

2. Instead of using a Chain, use Setll and Reade. When you write the subfile records include more fields as “H”idden fields. Then on the ReadE, compare those fields to the data in the file to get the record you need.

Discuss This Question: 9  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
  • nasrunisar
    Thank you Charlie, 1. Create a new LF where the key would be unique. = In this option what would be my key fields. Are the same field1, 2 and 3 will be the key fields? 2. In the hidden fields only the record will be available right? Could you please send me some sample code?  
    55 pointsBadges:
    report
  • Splat
    This is why I use logical views for display sequencing and physical RRN for updating.
    7,215 pointsBadges:
    report
  • TomLiotta
    Since there are no unique fields between the 3rd and 4th records except for F6, you would need all six fields as your key for any LF that you create. A possible better choice would be to grab the RRN of each row and store it as a 'H'idden field in the subfile. When you are ready to update, use the RRN to CHAIN to the PF record, and update that record. Tom
    125,585 pointsBadges:
    report
  • nasrunisar
    Thank you Tom and all, its updating correctly thru RRN.
    55 pointsBadges:
    report
  • graybeard52
    Another option is to use SQL to update the record using criteria that makes it unique.
    3,115 pointsBadges:
    report
  • philpl1jb
    And that means putting the original field value into a hidden field or the relative record # into a hidden field. Also you can change the Chain to a SETLL and read until all fields match the original values... then you have the record you want to update...unless someone else updates it before you get to it.  
    49,930 pointsBadges:
    report
  • nasrunisar
    Subfile Rrn and PF Rrn is not matching while comparing after deleting any record, therefore giving errror update without prior input operation. Could any one suggest how to solve this issue.?  
    55 pointsBadges:
    report
  • TomLiotta
    Subfile Rrn and PF Rrn is not matching...   The subfile RRN is not the same as the PF RRN unless your program logic makes them the same.   You must retrieve the PF RRN (DB_RRN) from the device-specific-feedback area at the time the PF record is retrieved. You would store each DB_RRN in a 'H'idden subfile field so your program knows which PF record to access later.   Tom
    125,585 pointsBadges:
    report
  • nasrunisar
    Thank you very much Tom, Got DB Rrn during each read operation thru INFDS and written into subfile 'H'idden field (HRRN) and for update, used Chain with HRRN and update working fine. And for delete, pointer at *start setll and the file processed within Dow Not %EOF and compared delete screen fields with file fields, and the matching record deleted.                            Everything works fine till now as far as write, update and delete is concern. Now got some validations to perform. Once again I thank you vey much for your quick response.
    55 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