Undo a delete transaction

K4sh

Member
Here is my pb.
I have a transaction that can delete the whole contents of two tables.
But in this transaction an error may occur and raise in some environment test.

In this case the delete of the two tables contents should for me undo but it doesn't.

Here is my code

Code:
traitement:
DO ON ERROR UNDO traitement, LEAVE traitement:

    ...
    Code
    ...
    

    
    FOR EACH refmsg EXCLUSIVE-LOCK:
        DELETE refmsg.
    END.

    FOR EACH dicomsg EXCLUSIVE-LOCK:
        DELETE dicomsg.
    END.

    /*----------------------------------------------------------------------*/
    /*  4 - Remise en forme des msges de référence par ordre alphabétique  */
    /*----------------------------------------------------------------------*/
    
    FOR EACH tt_refmsg WHERE TRIM(tt_refmsg.msgori) NE "" 
                          AND TRIM(tt_refmsg.msgori) NE " " 
                          AND TRIM(tt_refmsg.msgmaj) NE "" 
                        NO-LOCK BY tt_refmsg.msgmaj:
        i = i + 1.
    
        FOR EACH tt_dicomsg WHERE tt_dicomsg.codmsg = tt_refmsg.codmsg:
            ASSIGN tt_dicomsg.nouvcodmsg = i.
        END.
    
        /* Création du message de référence */
        CREATE refmsg. /* Pour debuggage (refmsg) */
        ASSIGN                                                     <==== An error may occur with this assign
            refmsg.codmsg         = i
            refmsg.msgmaj         = tt_refmsg.msgmaj
            refmsg.msgori         = tt_refmsg.msgori
            NO-ERROR. 
    END.
    ... 
    Code
    ...
END.
 
Top