project QadFinancials > class BPosting > method ValidateComponentReversingPostingDelete

Description

This method is for deleting automatic reversal entries. It marks the reversing entry for deletion.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.ValidateComponentReversingPosting


program code (program4/bposting.p)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 
/* Deleting                                                    */
/* You cannot delete from a reversing entry and when deleting  */
/* an original entry the reversing entry must also be deleted  */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* Exception Handling */
assign oiReturnStatus = -98
       viLocalReturnStatus = 0. 
       
POSTINGBLOCK: DO:

    For each btsPosting where 
             btsPosting.PostingIsAutoReversal       = true      and 
             btsPosting.tc_status                   = "D":U     and 
             btsPosting.PostingAutoReversalType     = {&POSTINGAUTOREVERSALTYPE-ORIGINAL}
             no-lock:
            
            /* Load the reversing entry so it can be marked for deletion */    
            <M-1 run DataLoad
               (input  '':U (icRowids), 
                input  btsPosting.AutoReversalPosting_ID (icPkeys), 
                input  '':U (icObjectIds), 
                input  '':U (icFreeform), 
                input  true (ilKeepPrevious), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>    
    
            if viFcReturnSuper <> 0 
            then do:
               assign vcMsgExplanation = <M-48 GetErrorExplanation
                                            (input  btsPosting.tc_Rowid (icPostingRowId), 
                                             input  ? (icPostingLineRowId), 
                                             output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
               assign viLocalReturnStatus = viFcReturnSuper. 
               if viFcReturnSuper = -4 
               then do:
                   <M-2 run SetMessage
                      (input  #T-4'The related Reversing Entry for this Journal Entry cannot be found':100(999890052)T-4# (icMessage), 
                       input  '':U (icArguments), 
                       input  'btsPosting.AutoReversalPosting_ID':U (icFieldName), 
                       input  btsPosting.AutoReversalPosting_ID (icFieldValue), 
                       input  'E':U (icType), 
                       input  1 (iiSeverity), 
                       input  btsPosting.tc_Rowid (icRowid), 
                       input  'QadFin-8806':U (icFcMsgNumber), 
                       input  vcMsgExplanation (icFcExplanation), 
                       input  '':U (icFcIdentification), 
                       input  '':U (icFcContext), 
                       output oiReturnStatus (oiReturnStatus)) in BPosting>  
                end.
              LEAVE POSTINGBLOCK.  
            end.            
            
            /* Mark the reversing entry for deletion */
            find first tPosting where
                       tPosting.Posting_ID = btsPosting.AutoReversalPosting_ID no-error.
            if available tPosting 
            then do:
               if tPosting.PostingAutoReversalType <> {&POSTINGAUTOREVERSALTYPE-REVERSING}
               then do:
                  assign viLocalReturnStatus  = -1
                  vcMessage            =   trim(substitute(#T-17'Posting: &1/&2/&3':255(64076)T-17#,string(tPosting.PostingYear),tPosting.tcJournalCode,string(tPosting.PostingVoucher))).   
                  vhFcComponent        = ?.
                  <M-16 run CreateCorruption
                     (input  'Posting':U (icTableName), 
                      input  btsPosting.AutoReversalPosting_ID (icKey), 
                      input  vcMessage (icDescription), 
                      input  false (ilSkipMessage), 
                      output viFcReturnSuper (oiReturnStatus)) in BCorrLog> 
               end. /* tPosting.PostingAutoReversalType <> {&POSTINGAUTOREVERSALTYPE-REVERSING} */
               else do:
                   <M-3 run SetMessage
                      (input  #T-5'This journal entry has a related reversing entry which will also be deleted':100(999890051)T-5# (icMessage), 
                       input  '':U (icArguments), 
                       input  'tPosting.AutoReversalPosting_ID':U (icFieldName), 
                       input  tPosting.AutoReversalPosting_ID (icFieldValue), 
                       input  'W':U (icType), 
                       input  1 (iiSeverity), 
                       input  tPosting.tc_Rowid (icRowid), 
                       input  'QadFin-8807':U (icFcMsgNumber), 
                       input  '':U (icFcExplanation), 
                       input  '':U (icFcIdentification), 
                       input  '':U (icFcContext), 
                       output oiReturnStatus (oiReturnStatus)) in BPosting>  
                    create t_sPosting.
                    buffer-copy tPosting to t_sPosting.
                    assign t_sPosting.tc_Status = "D":U.
                    assign viLocalReturnStatus = 1.
                    LEAVE POSTINGBLOCK.    
                end.        
            end. /* available tPosting */
            else do:
                assign vcMsgExplanation = <M-80 GetErrorExplanation
                                             (input  btsPosting.tc_Rowid (icPostingRowId), 
                                              input  ? (icPostingLineRowId), 
                                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                <M-18 run SetMessage
                   (input  #T-19'The related Reversing Entry for this Journal Entry cannot be found':100(999890052)T-19# (icMessage), 
                    input  '':U (icArguments), 
                    input  'btsPosting.AutoReversalPosting_ID':U (icFieldName), 
                    input  btsPosting.AutoReversalPosting_ID (icFieldValue), 
                    input  'E':U (icType), 
                    input  1 (iiSeverity), 
                    input  btsPosting.tc_Rowid (icRowid), 
                    input  'QadFin-8987':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output oiReturnStatus (oiReturnStatus)) in BPosting>  
                   assign viLocalReturnStatus = -1.
                   LEAVE POSTINGBLOCK.
            end.          
    end. /* For each btsPosting where */

END. /* POSTINGBLOCK */

/* Exception Handling */
assign oiReturnStatus = viLocalReturnStatus.