project QadFinancials > class BJournal > method ValidateComponent

Description

Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.

Validations:
run PreValidateComponent
Ancestor Code
run ValidateDeactivation
Journal can not be deleted or set inactive if it is used in 'default daybook maintenance'.
Check if a new journal code is not the same as an existing Number Range Sequence ID.
Update or delete of a journal that is used in Sales orders is not allowed.
Update of journal code, type, layer and journalcontrol is not allowed when the journal is used in postings.
Check if the journaltype that is selected for the journal is active and that more than one journal can be defined for the journaltype.
The selected layer should be active and the journal type should allow this type of layers.
A transient layer is not allowed for journals of type JournalEntry and logistic control.
Some journaltypes can only be used for financial (or financial and external) journal control.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bjournal.p)

<M-10 run PreValidateComponent  (output viPreValidateStatus (oiReturnStatus)) in BJournal>
if viPreValidateStatus < 0
then do:
    if oiReturnStatus = 0 or 
       oiReturnStatus = ?
    then assign oiReturnStatus = viPreValidateStatus.
    return.
end.

<ANCESTOR-CODE>

if oiReturnStatus < 0 or
   viPreValidateStatus <> 0
then do:
    if oiReturnStatus = 0 or 
       oiReturnStatus = ?
    then assign oiReturnStatus = viPreValidateStatus.
    return.
end.

<M-53 run ValidateDeactivation  (output viFcReturnSuper (oiReturnStatus)) in BJournal>
if(viFcReturnSuper <> 0 and oiReturnStatus = 0) then oiReturnStatus = viFcReturnSuper.

<Q-11 run JournalTypeByNothing (all) (Read) (NoCache)  (output dataset tqJournalTypeByNothing) in BJournalType >

assign vcJOURNALTYPES ={&JOURNALTYPES}.
for each t_sJournal where
         t_sJournal.tc_Status <> "":U:
    
    if t_sJournal.tc_Status <> "N":U 
    then do:
        find first t_iJournal where
                   t_iJournal.tc_Rowid = t_sJournal.tc_Rowid
                   no-error.
        if not available t_iJournal
        then next. /* error raised by ancestor-code */ 
    end. /* t_sJournal.tc_Status <> "N":U */ 
    
    if t_sJournal.tc_Status = "C":U or
       t_sJournal.tc_Status = "D":U
    then do:
        if ((t_sJournal.tc_Status = "C":U and not t_sJournal.JournalIsActive) or 
            t_sJournal.tc_Status = "D":U) and
           t_sJournal.JournalControl = {&JOURNALCONTROL-LOGISTIC}
        then do:        
            <Q-45 run DomainBySharedSetDomain (all) (Read) (NoCache)
               (input t_sjournal.SharedSet_ID, (SharedSetId)
                input 0, (DomainID)
                input '':U, (DomainCode)
                output dataset tqDomainBySharedSetDomain) in BDomain >
            for each tqDomainBySharedSetDomain:
                assign vlFcQueryRecordsAvailable = false.
                <Q-50 assign vlFcQueryRecordsAvailable = DaybookDftByTransDocTypeCode (NoCache)
                   (input tqDomainBySharedSetDomain.tcDomainCode, (Domain)
                    input '':U, (TransactionType)
                    input '':U, (DocumentType)
                    input '':U, (DaybookEntity)
                    input t_sjournal.JournalCode, (DaybookCode)) in BMfgDaybookDefault >
                    
                if vlFcQueryRecordsAvailable <> false 
                then do:
                   assign vcMessage = (if t_sJournal.tc_Status = "C":U then
                                       trim(#T-48'The daybook is referenced by Default Daybook Maintenance in Domain $1 and cannot be made Inactive.':255(64935)T-48#)
                                       else
                                       trim(#T-49'The daybook is referenced by Default Daybook Maintenance in Domain $1 and cannot be deleted.':255(64936)T-49#))
                           oiReturnStatus = -1.
                    <M-47 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  tqDomainBySharedSetDomain.tcDomainCode (icArguments), 
                        input  'tJournal.JournalIsActive':U (icFieldName), 
                        input  t_sjournal.JournalIsActive (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sjournal.tc_Rowid (icRowid), 
                        input  'QadFin-6854':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BJournal>       
                end. /* if vlFcQueryRecordsAvailable then do */                           
            end. /* for each tqDomainBySharedSetDomain */    
        end. /* if t_sJournal.tc_Status = "C":U ..... then do */
    end. /* if t_sJournal.tc_Status = "C":U or D */
    
    /* New mode: During Daybook Create check to ensure that DaybookCode is not an existing NRM sequence defined in MFG/PRO */
    else do:
        <I-43 {bFcOpenInstance
             &CLASS           = "Session"}>
        /* Determine if replication of data to MFG/PRO is enabled. */
        <M-42 run GetLogicalValue
           (input  'ReplicationEnabled':U (icName), 
            output vlReplicationEnabled (olValue), 
            output viFcReturnSuper (oiReturnStatus)) in Session>
        <I-44 {bFcCloseInstance
             &CLASS           = "Session"}>
        /* Execute validation only when Replication to MFG/PRO is enabled */
        if vlReplicationEnabled <> false 
        then do:    
            <Q-41 run DomainByDomainSharedSet (all) (Read) (NoCache)
               (input ?, (DomainID)
                input t_sjournal.SharedSet_ID, (SharedSetID)
                input ?, (SharedSetCode)
                input ?, (SharedSetType)
                output dataset tqDomainByDomainSharedSet) in BDomain >
            for each tqDomainByDomainSharedSet:    
                assign vlFcQueryRecordsAvailable = false.
                <Q-38 assign vlFcQueryRecordsAvailable = NumberRangeBySequenceID (NoCache)
                   (input tqDomainByDomainSharedSet.tcDomainCode, (DomainID)
                    input t_sjournal.JournalCode, (SequenceID)) in BMfgNRM >
                if vlFcQueryRecordsAvailable <> false 
                then do:
                    assign vcMessage = trim(#T-39'The journal code cannot be the same as an existing Number Range Sequence ID. You must enter a different journal code':255(63897)T-39#)
                           oiReturnStatus = -1.
                    <M-40 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tJournal.JournalCode':U (icFieldName), 
                        input  t_sjournal.JournalCode (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '':U (icRowid), 
                        input  'QadFin-6532':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BJournal>       
                    return.
                end. /* if vlFcQueryRecordsAvailable <> false */
            end. /* for each tqDomainByDomainSharedSet */   
        end. /* if vlReplicationEnabled <> false then do */ 
    end. /* else do: this means new-mode */

    /* Check is Journal Codes are used by Sales Orders.        */
    /* First find if Journal Codes are used by DaybookSets,    */
    /* then check if the Daybooksets are used by Sales Orders. */    
    if t_sJournal.tc_Status      <> "N":U                      and 
       t_iJournal.JournalControl  = {&JOURNALCONTROL-LOGISTIC} and
       (t_sJournal.tc_Status = "D":U    or
        (t_sJournal.tc_Status = "C":U and
         (t_sJournal.JournalIsActive           <> t_iJournal.JournalIsActive           or
          t_sJournal.JournalTypeCode           <> t_iJournal.JournalTypeCode           or
          t_sJournal.JournalIsProjectProvision <> t_iJournal.JournalIsProjectProvision or
          t_sJournal.JournalControl            <> t_iJournal.JournalControl            or
          t_sJournal.Layer_ID                  <> t_iJournal.Layer_ID)))
    then do:
        <Q-33 run DaybookExists (all) (Read) (NoCache)
           (input t_sJournal.JournalCode, (Journal)
            input vcMfgDomain, (Domain)
            output dataset tqDaybookExists) in BMfgDaybookSet >
        for each tqDaybookExists no-lock:
            <Q-34 run SalesOrderForDaybookSet (all) (Read) (NoCache)
               (input tqDaybookExists.tcdybs_code, (DaybookSet)
                input vcMfgDomain, (Domain)
                output dataset tqSalesOrderForDaybookSet) in BMfgSalesOrder >
            if can-find(first tqSalesOrderForDaybookSet)
            then do:
                assign vcMessage  = trim(substitute(#T-35'Daybook Code &1 is used by Sales Orders.':41(70399)T-35#, trim(t_sJournal.JournalCode) )) + chr(10) +
                                    trim(#T-57'Update or delete of this daybook is not allowed.':255(70400)T-57#)
                       oiReturnStatus = -1.
                <M-36 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '' (icArguments), 
                    input  '' (icFieldName), 
                    input  '' (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'QadFin-5024':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BJournal>.
                return.
            end. /* if can-find( */
        end. /* for each tqDaybookExists no-lock: */
    end. /* if t_sJournal.tc_Status <> "N":U and */

    /*PostingExists*/
    assign vlPostingExists = false.
    <Q-2 assign vlFcQueryRecordsAvailable = PostingByJournalID (NoCache)
       (input t_sjournal.Journal_ID, (Journal_ID)
        input viCompanyId, (CompanyId)) in BPosting >    
    if vlFcQueryRecordsAvailable = true or
       vlFcQueryRecordsAvailable = ?
    then assign vlPostingExists = true.
    
    /*Error: cannot Modify JournalCode, JournalType, Layer, Control if a Posting exists*/
    if available t_iJournal and
       vlPostingExists      and      
       t_sJournal.tc_Status       = "C":U and
      (t_sJournal.JournalCode    <> t_iJournal.JournalCode or
       t_sJournal.JournalType    <> t_iJournal.JournalType or
       t_sJournal.Layer_ID       <> t_iJournal.Layer_ID or
       t_sJournal.JournalControl <> t_iJournal.JournalControl)
    then do:
        assign vcMessage = "":U.
        if t_sJournal.JournalCode <> t_iJournal.JournalCode
        then assign vcMessage = vcMessage + " ":U + right-trim (#T-12'Daybook Code':100(247)T-12#).
        if t_sJournal.JournalType <> t_iJournal.JournalType
        then assign vcMessage = vcMessage + " ":U + right-trim (#T-13'Daybook Type':20(3915)T-13#).
        if t_sJournal.Layer_ID    <> t_iJournal.Layer_ID
        then assign vcMessage = vcMessage + " ":U + right-trim (#T-14'Layer':40(69683)T-14#).
        if t_sJournal.JournalControl <> t_iJournal.JournalControl
        then assign vcMessage = vcMessage + right-trim (#T-23'Control':20(31622)T-23#).
        assign vcMessage      = right-trim (vcMessage, ",":U)
               vcMessage      = trim(#T-15'Cannot change the following attribute(s):':200(2717)T-15#) + " ":U  + 
                                trim(vcMessage) + " ":U +
                                trim(substitute(#T-16'The &1 daybook is already used in a posting.':200(2718)T-16#, trim(t_sJournal.JournalCode))) + chr(10) + 
                                (if program-name(1) = ? then "":U else program-name(1))
               oiReturnStatus = if oiReturnStatus  < 0
                                then oiReturnStatus
                                else -1.
        <M-3 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QADFIN-13':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BJournal>
    end. /* if available t_iJournal and */
    
    /*Error: cannot Delete Journal if a Posting exists (DB restriction)*/    
    /*Journal Type validations*/
    find first tqJournalTypeByNothing 
               no-error.
    if not available tqJournalTypeByNothing
    then do:
        assign vcMessage      = trim(substitute(#T-37'Internal error: no journal types available.':255(63339)T-37#,t_sJournal.JournalTypeCode)) + chr(10) + (if program-name(1) = ? then "":U else program-name(1))
               oiReturnStatus = -1.
        <M-9 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'D':U (icType), 
            input  1 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QADFIN-22':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BJournal>
        return.
    end. /* if not available tqJournalTypeByNothing */
    
    if (t_sJournal.tc_Status       = "N":U or
       t_sJournal.tc_Status        = "C":U) and
       t_sJournal.JournalTypeCode <> "":U   and
       t_sJournal.JournalTypeCode <> "?":U  and
       t_sJournal.JournalTypeCode <> ?
    then do:    
        find first tqJournalTypeByNothing where 
                   tqJournalTypeByNothing.tcJournalTypeCode = t_sJournal.JournalTypeCode no-error.
        /*Error: JournalType not available (DB restriction)*/
        /*Error: JournalType must be Active and AllowExternalJournal*/
        if available tqJournalTypeByNothing and          
          (tqJournalTypeByNothing.tlJournalTypeIsActive       = false or
           tqJournalTypeByNothing.tlJournalTypeIsMultiJournal = false)
        then do:
            assign viIndexPosition = lookup(t_sJournal.JournalTypeCode,vcJOURNALTYPES,chr(2)) no-error.
            if viIndexPosition MODULO 2 = 0 
            then assign viIndexPosition = viIndexPosition - 1 no-error.
            assign vcJournalTypeCodeTr = entry(viIndexPosition,vcJOURNALTYPES,chr(2)) no-error.    
            assign vcMessage = "":U.
            if tqJournalTypeByNothing.tlJournalTypeIsActive = false
            then assign vcMessage = vcMessage + trim(#T-17'This daybook type is not active.':100(2719)T-17#).
            if tqJournalTypeByNothing.tlJournalTypeIsMultiJournal = false
            then assign vcMessage = vcMessage + trim(#T-18'This daybook type is not valid for daybooks.':100(2720)T-18#).
            assign vcMessage      = right-trim(vcMessage, ",":U)
                   vcMessage      = trim(substitute(#T-19'The daybook type &1 is invalid for the following reasons:':200(2721)T-19#, trim(vcJournalTypeCodeTr))) + 
                                    vcMessage + chr(10) + 
                                    (if program-name(1) = ? then "":U else program-name(1))
                   oiReturnStatus = if oiReturnStatus  < 0
                                    then oiReturnStatus
                                    else -1.
            <M-5 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QADFIN-14':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BJournal>
        end. /* if available tqJournalTypeByNothing and  */
    end. /* if (t_sJournal.tc_Status       = "N":U or */
    
    /* Layer validations*/
    if (t_sJournal.tc_Status = "N":U or
       t_sJournal.tc_Status  = "C":U) and
       t_sJournal.Layer_ID  <> 0   and
       t_sJournal.Layer_ID  <> ?  and
       t_sJournal.JournalTypeCode <> "":U   and
       t_sJournal.JournalTypeCode <> "?":U  and
       t_sJournal.JournalTypeCode <> ?       
    then do:    
        find first tqJournalTypeByNothing where 
                   tqJournalTypeByNothing.tcJournalTypeCode = t_sJournal.JournalTypeCode no-error.        
        <Q-7 run LayerById (all) (Read) (NoCache)
           (input t_sjournal.Layer_ID, (LayerId)
            output dataset tqLayerById) in BLayer >
        /*Error: Layer not available (DB restriction) */
        /*Error: Layer must be active and must respect the settings of the JournalType*/
        find first tqLayerById no-error.
        if available tqJournalTypeByNothing and
           available tqLayerById and          
          (tqLayerById.tlLayerIsActive  = false or
          (tqLayerById.tcLayerTypeCode  = {&LAYERTYPECODE-OFFICIAL} and
           tqJournalTypeByNothing.tlJournalTypeIsAllowOfficial = false) or
          (tqLayerById.tcLayerTypeCode  = {&LAYERTYPECODE-MANAGEMENT} and
           tqJournalTypeByNothing.tlJournalTypeIsAllowMgt = false) or
          (tqLayerById.tcLayerTypeCode  = {&LAYERTYPECODE-TRANSIENT} and
           tqJournalTypeByNothing.tlJournalTypeIsAllowTrans = false))
        then do:
            assign viIndexPosition = lookup(tqLayerById.tcLayerTypeCode,{&LAYERTYPECODES},chr(2)) no-error.
            if viIndexPosition MODULO 2 = 0 
            then assign viIndexPosition = viIndexPosition - 1 no-error.
            assign vcLayerTypeCodeTr = entry(viIndexPosition,{&LAYERTYPECODES},chr(2)) no-error.
    
            assign viIndexPosition = lookup(tqJournalTypeByNothing.tcJournalTypeCode,vcJOURNALTYPES,chr(2)) no-error.
            if viIndexPosition MODULO 2 = 0 
            then assign viIndexPosition = viIndexPosition - 1 no-error.
            assign vcJournalTypeCodeTr = entry(viIndexPosition,vcJOURNALTYPES,chr(2)) no-error.
    
            assign vcMessage = "":U.
            if tqLayerById.tlLayerIsActive = false
            then assign vcMessage = vcMessage + trim (#T-20'The layer is not active.':100(2722)T-20#).

            if (tqLayerById.tcLayerTypeCode  = {&LAYERTYPECODE-OFFICIAL} and
                tqJournalTypeByNothing.tlJournalTypeIsAllowOfficial = false) or
               (tqLayerById.tcLayerTypeCode  = {&LAYERTYPECODE-MANAGEMENT} and
                tqJournalTypeByNothing.tlJournalTypeIsAllowMgt = false) or
               (tqLayerById.tcLayerTypeCode  = {&LAYERTYPECODE-TRANSIENT} and
                tqJournalTypeByNothing.tlJournalTypeIsAllowTrans = false)
            then assign vcMessage = vcMessage + trim (substitute(#T-21'The layer &1 is not valid for the daybook type &2.':200(2723)T-21#, trim(vcLayerTypeCodeTr), trim(vcJournalTypeCodeTr))).
                        
            assign vcMessage      = right-trim(vcMessage, ",":U)
                   vcMessage      = trim(substitute(#T-22'The layer &1 is invalid for the following reasons:':200(2724)T-22#, trim(tqLayerById.tcLayerCode)))  + 
                                    vcMessage + chr(10) + 
                                    (if program-name(1) = ? then "":U else program-name(1))
                   oiReturnStatus = if oiReturnStatus  < 0
                                    then oiReturnStatus
                                    else -1.
            <M-6 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QADFIN-15':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BJournal>
        end.
        /* JournalEntry type could not be in Transient layer in operational control */
        if available tqLayerById  
        then do:
            if t_sJournal.JournalTypeCode   = {&JOURNALTYPE-JOURNALENTRY} and
                t_sJournal.JournalControl   = {&JOURNALCONTROL-LOGISTIC} and 
                tqLayerById.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT}
            then do:
                assign vcMessage      = trim(substitute(#T-56'You cannot use layer '&1' for '&2' daybook type in '&3' daybook control.':200(68414)T-56#,
                                                   tqLayerById.tcLayerCode, {&JOURNALTYPE-JOURNALENTRY-TR}, {&JOURNALCONTROL-LOGISTIC-TR}))
                       oiReturnStatus = if oiReturnStatus  < 0
                                           then oiReturnStatus
                                           else -1.
                <M-55 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-7666':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BJournal>
            end. /* if t_sJournal.JournalTypeCode   = {&JOURNALTYPE-JOURNALENTRY} and ... */
        end. /*  if available tqLayerById   */
    end. /* if (t_sJournal.tc_Status = "N":U or */

    /* JournalIsInternal for JournalType Validations */
    if (t_sJournal.tc_Status = "N":U or
       t_sJournal.tc_Status  = "C":U)
    then do:
         case t_sJournal.JournalTypeCode:
            when {&JOURNALTYPE-CIREC} or
            when {&JOURNALTYPE-REVALCREDITORDOC} or
            when {&JOURNALTYPE-REVALCREDITOR} or
            when {&JOURNALTYPE-REVALDEBTOR} or
            when {&JOURNALTYPE-REVALDEBTORDOC} or
            when {&JOURNALTYPE-REVALGL} or
            when {&JOURNALTYPE-REVALINTERCO} or
            when {&JOURNALTYPE-REVALINVENTORY} or
            when {&JOURNALTYPE-REVALVAT}  or
            when {&JOURNALTYPE-REVERSINGENTRY} or
            when {&JOURNALTYPE-YEARLYCLOSING} or
			when {&JOURNALTYPE-DEDUCTION} 
            then do:
                 if t_sJournal.JournalControl <> {&JOURNALCONTROL-FINANCIAL} then do:
                    assign viIndexPosition = lookup(t_sJournal.JournalTypeCode,vcJOURNALTYPES,chr(2)) no-error.
                    if viIndexPosition MODULO 2 = 0 
                        then assign viIndexPosition = viIndexPosition - 1 no-error.
                    assign vcJournalTypeCodeTr = entry(viIndexPosition,vcJOURNALTYPES,chr(2)) no-error.
                    assign vcMessage =  trim(substitute(#T-24'The daybook type &1 is for Financial use only':100(31626)T-24#,trim(vcJournalTypeCodeTr),"CHARACTER":U))
                        oiReturnStatus = if oiReturnStatus  < 0
                            then oiReturnStatus
                            else -1.
                    <M-25 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  '':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '':U (icRowid), 
                        input  'QadFin-4737':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BJournal>
                end.
            end.
            when {&JOURNALTYPE-BANKINGENTRY} or 
            when {&JOURNALTYPE-CASHENTRY} or
            when {&JOURNALTYPE-CONSOLIDATION} or
            when {&JOURNALTYPE-CREDITORPAYMENT} or
            when {&JOURNALTYPE-DEBTORPAYMENT} or
            when {&JOURNALTYPE-CREDITORADJUSTMENT}
            then do:
                 if t_sJournal.JournalControl <> {&JOURNALCONTROL-FINANCIAL} and
                    t_sJournal.JournalControl <> {&JOURNALCONTROL-EXTERNAL} 
                 then do:
                    assign viIndexPosition = lookup(t_sJournal.JournalTypeCode,vcJOURNALTYPES,chr(2)) no-error.
                    if viIndexPosition MODULO 2 = 0 
                        then assign viIndexPosition = viIndexPosition - 1 no-error.
                    assign vcJournalTypeCodeTr = entry(viIndexPosition,vcJOURNALTYPES,chr(2)) no-error.
                    assign vcMessage =  trim(substitute(#T-29'The daybook type &1 is for Financial or External Use only':100(31635)T-29#,vcJournalTypeCodeTr,"CHARACTER":U))
                        oiReturnStatus = if oiReturnStatus  < 0
                            then oiReturnStatus
                            else -1.
                    <M-28 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  '':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '':U (icRowid), 
                        input  'QadFin-4861':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BJournal>
                end.
            end.
            when {&JOURNALTYPE-JOURNALENTRY} or
            when {&JOURNALTYPE-CREDITORCREDITNOTECORRECT} or
            when {&JOURNALTYPE-CREDITORCREDITNOTE} or
            when {&JOURNALTYPE-CREDITORINVOICE} or
            when {&JOURNALTYPE-CREDITORINVOICECORRECT} or 
            when {&JOURNALTYPE-DEBTORADJUSTMENT} or
            when {&JOURNALTYPE-DEBTORCREDITNOTECORRECT} or
            when {&JOURNALTYPE-DEBTORCREDITNOTE} or
            when {&JOURNALTYPE-DEBTORINVOICE} or 
            when {&JOURNALTYPE-DEBTORFINANCECHARGE} or
            when {&JOURNALTYPE-DEBTORINVOICECORRECT} or
            when {&JOURNALTYPE-PERIODICCOSTING}
            then do:
                 if t_sJournal.JournalControl <> {&JOURNALCONTROL-FINANCIAL} and
                    t_sJournal.JournalControl <> {&JOURNALCONTROL-LOGISTIC} and
                    t_sJournal.JournalControl <> {&JOURNALCONTROL-EXTERNAL} 
                 then do:
                    assign viIndexPosition = lookup(t_sJournal.JournalTypeCode,vcJOURNALTYPES,chr(2)) no-error.
                    if viIndexPosition MODULO 2 = 0 
                        then assign viIndexPosition = viIndexPosition - 1 no-error.
                    assign vcJournalTypeCodeTr = entry(viIndexPosition,vcJOURNALTYPES,chr(2)) no-error.
                    assign vcMessage =  trim(substitute(#T-31'The daybook type &1 is for Financial, Operational, or External Use only':100(31637)T-31#,vcJournalTypeCodeTr,"CHARACTER":U))
                        oiReturnStatus = if oiReturnStatus  < 0
                            then oiReturnStatus
                            else -1.
                    <M-30 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  '':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '':U (icRowid), 
                        input  'QadFin-4862':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BJournal>
                end.
            end.
        end case.
    end.

end. /* for each t_sJournal where */

<M-71 run ValidateComponentPostRole  (output viFcReturnSuper (oiReturnStatus)) in BJournal>
if viFcReturnSuper < 0 or oiReturnStatus = 0 and viFcReturnSuper > 0 then assign oiReturnStatus = viFcReturnSuper.