Parent/Child/Related File updating 
Author Message
 Parent/Child/Related File updating

I have the following files and their relationship:

Parent (Invoice field = BalanceDue) -----------------> Customer
File(AccountBalance)
  |__ Child (Detail field = QtyOrdered)
            |__  (Inventory field = QtyInStock)

The Invoice and Detail files are defined in the Data Dictionary as
Cascade for both update and deletes.  The Detail record adjusts the
inventory level (Qty in Stock) as you add to the invoice. The Customer
file AccountBalance is related to the Invoice BalanceDue field.  Now the

problem:

As expected, when you delete the Invoice from a standard browse, the RI
also deletes the associated Child Detail records.  However, you want to
re-adjust the Inventory levels for each of the Detail records deleted
and adjust the Customer File with a new AccountBalance.  I've tried to
use the LOGOUT command and adjust the inventory levels and Customer file

BEFORE the call to the delete procedure and then on return, if
RequestCancelled is returned, do a ROLLBACK.  This gives an ERROR(56)
because
apparently the delete procedure  is also doing a LOGOUT (only 1 LOGOUT
can be active).
I ended up saving the necessary Detail record information in a local
queue, and then if the delete
procedure returns a RequestCompleted, I update the Inventory levels and
Customer file.
There must be a better way to do this in C4/C5 ABC, but I'm at a loss.
Any sugestions?



Sun, 05 Aug 2001 03:00:00 GMT  
 Parent/Child/Related File updating
Quote:

> I ended up saving the necessary Detail record information in a local
> queue, and then if the delete
> procedure returns a RequestCompleted, I update the Inventory levels and
> Customer file.
> There must be a better way to do this in C4/C5 ABC, but I'm at a loss.
> Any sugestions?

The way your doing it isnt bad but I suppose the ideal would be to get
the inventory adjustment stuff into the logout frame. So what I did was
go to the primary file to be deleted which was 'job' in my case and
pressed the global embeds button and when to the relate, job, delete
embed and typed in hand code to handle the logout with just the files I
wanted in the logout and just the code I wanted. I didnt call any of the
abc code. When you put code in the embed there it gets generated as:
Hide:Relate:job.Delete PROCEDURE(BYTE Query=1)

ReturnValue          BYTE,AUTO

  CODE
  !Job Delete embed - put my code here then return
  !Return
  ReturnValue = PARENT.Delete(Query)
  RETURN ReturnValue

  If you put your code in the embed and follow it with a return, the abc
code never gets called so you can customize to your hearts content.

  The other one that's handy to rewrite at times is autoinc.

---
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com



Sun, 05 Aug 2001 03:00:00 GMT  
 Parent/Child/Related File updating
In your Global Properties, head over to File Control Flags and uncheck
'Enclose RI code in Transaction frame'. This will allow you to put in
your own COMMIT and LOGOUT code. This will also avoid locking the files
when you are doing mass updates and deletes.

HTH!

Quote:

> I have the following files and their relationship:

> Parent (Invoice field = BalanceDue) -----------------> Customer
> File(AccountBalance)
>   |__ Child (Detail field = QtyOrdered)
>             |__  (Inventory field = QtyInStock)

> The Invoice and Detail files are defined in the Data Dictionary as
> Cascade for both update and deletes.  The Detail record adjusts the
> inventory level (Qty in Stock) as you add to the invoice. The Customer
> file AccountBalance is related to the Invoice BalanceDue field.  Now
> the problem:

> As expected, when you delete the Invoice from a standard browse, the
> RI also deletes the associated Child Detail records.  However, you
> want to re-adjust the Inventory levels for each of the Detail records
> deleted and adjust the Customer File with a new AccountBalance.  I've
> tried to use the LOGOUT command and adjust the inventory levels and
> Customer file BEFORE the call to the delete procedure and then on
> return, if RequestCancelled is returned, do a ROLLBACK.  This gives an
> ERROR(56) because apparently the delete procedure  is also doing a
> LOGOUT (only 1 LOGOUT can be active).
> I ended up saving the necessary Detail record information in a local
> queue, and then if the delete
> procedure returns a RequestCompleted, I update the Inventory levels
> and Customer file.
> There must be a better way to do this in C4/C5 ABC, but I'm at a loss.
> Any sugestions?



Mon, 06 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CW4 Writing to a parent file from child file's update form

2. I have Update Form (parent file) with Browse List (child file)

3. Updating parent file when child edited

4. Update Parent/Child files

5. Listing all parents relating to child list??

6. Probleme for update parents and children

7. View Parent changes made in Child Update

8. Update parent value from child form

9. C4 Losing data on update to a child from parent

10. Update parent field from child?

11. Update of Parent Form from Child

12. Adding Child Record to a Child file during Update

 

 
Powered by phpBB® Forum Software