tDDocumentStatusChange | input | temp-table | Input temporary table which contains details needed for change of status/bank number and/or payment format of debtor document. This temporary table is retreived using method ApiGetDDocumentStatusChange method. Currently only change of following fields of debtor documents is supported. Change of other fields is not recommended. - tcDDocumentStatus - tcBankNumber - tcGLCode List of fields in temporary table: - tlChangeFlag this field is not used - tdOriginalDebitTC original debit of debtor's document (this value cannot be changed) - tdOriginalStatus original status of debtor's document (this value cannot be changed) - Initial - Accepted - Portfolio - For collection - Disconto - Bounced - Paid - Paid conditionally - tcOriginalBankNumber original own bank number of debtor's document (this value cannot be changed) - tcOriginalGLCode original G/L account code of own bank number (this value cannot be changed) - tcBankNumber own bank number of payment document from which payment goes out. If this value is changed, during execution of method ApiSetDDocumentStatus new own bank number is assigned. - tiBankNumber_ID ID of own bank number from which payment goes out - tiBankPayFormat_ID ID of bank payment format (defines both own bank number and payment format) - tiBusinessRelation _ID ID of debtor's business relation - tcBusinessRelationCode Code of debtor's business relation - tiCompany_ID ID of company where debtor document was created - tiCurrency_ID ID of debtor document's currency - tcCurrencyCode Code of debtor document's currency - tiDDocument_ID ID of debtor document - ttDDocumentCreationDate Creation date of debtor document - ttDDocumentDueDate Due date of debtor document - tcDDocumentIncassoSelectCode Incasso selection code of debtor document - tlDDocumentIsOpen Debtor document is open - ttDDocumentLastPrintDate Last print date of debtor document - tiDDocumentNumber Debtor document number - tdDDocumentOriginalDebitLC Original debit amount in local currency - tdDDocumentOriginalDebitTC Original debit amount in transactional currency - tcDDocumentReference Reference of debtor document - tcDDocumentStatus Status of debtor document - Initial - Accepted - Portfolio - For collection - Disconto - Bounced - Paid - Paid conditionally - tcDDocumentSubType Indication of way, debtor document was created - Automatic - Manual - tiDDocumentTimesPrinted Number of times document was printed - tcDDocumentType Type of debtor document - Check - Direct debit - Draft - Promissory note - Summary statement - Credit card - tiDDocumentValueDays Value days - tiDDocumentYear Debtor document year - tiDebtor_ID ID of debtor - tcGLCode G/L code linked to company's bank number - tcPayFormatTypeCode Payment format code - ti_sequence Sequence record (internal usage) - tc_rowid Unique row identification withing a table |
itPostingDate | input | date | Posting date of status change of debtor document |
icFileFormat | input | character | Not used |
oiReturnStatus | output | integer | Return status of the method. |
if not can-find(first tDDocumentStatusChange) then return. assign vcRowId = "":U viDPaySelSequence = -1 viPaySelCodeHeaderSequence = -1 vlStart1 = false vcValidatedNewSelCodes = "":U vcValidatedNewSelCodeDetails = "":U vcDPaySelRecordsIDChanged = "":U. for each tDDocumentStatusChange where tDDocumentStatusChange.tcDDocumentStatus <> tDDocumentStatusChange.tcOriginalStatus or tDDocumentStatusChange.tcBankNumber <> tDDocumentStatusChange.tcOriginalBankNumber or tDDocumentStatusChange.tcGLCode <> tDDocumentStatusChange.tcOriginalGLCode or tDDocumentStatusChange.tcPayFormatTypeCode <> tDDocumentStatusChange.tcOriginalPayFormatTypeCode or tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> tDDocumentStatusChange.tcOriginalIncassoSelectCode: assign vcDDocumentType = <M-1 GetDDocumentTypeTranslation (input tDDocumentStatusChange.tcDDocumentType (icType)) in BDDocument>. if not vlStart1 then do: <Q-2 run DDocumentById (Start) in BDDocument > assign vlStart1 = true. end. <Q-3 run DDocumentById (all) (Read) (NoCache) (input tDDocumentStatusChange.tiCompany_ID, (CompanyId) input tDDocumentStatusChange.tiDDocument_ID, (DDocumentId) output dataset tqDDocumentById) in BDDocument > find first tqDDocumentById no-error. if not available tqDDocumentById then do: <M-4 run SetMessage (input trim(#T-12'$1 $2 $3 cannot be updated because another user has deleted it.':250(914)T-12#) (icMessage), input vcDDocumentType + chr(2) + string(tDDocumentStatusChange.tiDDocumentYear) + chr(2) + string(tDDocumentStatusChange.tiDDocumentNumber) (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QADFIN-2562':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BDDocument> assign oiReturnStatus = -1. next. end. /* Check to see if the document is to be added to a new selection code */ if (tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> tDDocumentStatusChange.tcOriginalIncassoSelectCode and tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> ? and tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> "") then do: /* first check to see if it's alreay been validated, and if so skip this validation */ if lookup(tDDocumentStatusChange.tcDDocumentIncassoSelectCode, vcValidatedNewSelCodes, ",":U) = 0 then do: if vcValidatedNewSelCodes <> "":U then assign vcValidatedNewSelCodes = vcValidatedNewSelCodes + ",":U vcValidatedNewSelCodeDetails = vcValidatedNewSelCodeDetails + ",":U. assign vcValidatedNewSelCodes = vcValidatedNewSelCodeDetails + entry(1, tDDocumentStatusChange.tcDDocumentIncassoSelectCode) vcValidatedNewSelCodeDetails = vcValidatedNewSelCodeDetails + entry(1, tDDocumentStatusChange.tcDDocumentIncassoSelectCode + chr(2) + tDDocumentStatusChange.tcBankNumber + chr(2) + tDDocumentStatusChange.tcGLCode + chr(2) + tDDocumentStatusChange.tcPayFormatTypeCode). /* validate selection code uniqueness, status and type */ <M-34 run IsNewSelectionCodeValid (input tDDocumentStatusChange.tcDDocumentIncassoSelectCode (icSelectionCode), input tDDocumentStatusChange.tcDDocumentStatus (icDocumentStatus), input tDDocumentStatusChange.tcPayFormatTypeCode (icFileFormat), output oiReturnStatus (oiReturnStatus)) in BDDocument> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. end. /* if lookup */ else do: /* check to see if all records with this code have the same bank details */ if lookup(tDDocumentStatusChange.tcDDocumentIncassoSelectCode + chr(2) + tDDocumentStatusChange.tcBankNumber + chr(2) + tDDocumentStatusChange.tcGLCode + chr(2) + tDDocumentStatusChange.tcPayFormatTypeCode, vcValidatedNewSelCodeDetails, ",":U) = 0 then do: assign oiReturnStatus = -1 vcMsg = #T-55'The combination of the bank number ($1) and the payment format ($2) must be the same for all records assigned to selection code $3.':255(819375154)T-55#. /* vcMsg = substitute(vcMsg, tDDocumentStatusChange.tcBankNumber, tDDocumentStatusChange.tcPayFormatTypeCode). */ <M-72 run SetMessage (input vcMsg (icMessage), input tDDocumentStatusChange.tcBankNumber + chr(2) + tDDocumentStatusChange.tcPayFormatTypeCode + chr(2) + tDDocumentStatusChange.tcDDocumentIncassoSelectCode (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'qadfin-467541':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BDDocument> next. end. /* if lookup */ end. /*else do */ end. /* tDDocumentStatusChange.tcDDocumentIncassoSelectCode */ if tDDocumentStatusChange.tcOriginalStatus <> tqDDocumentById.tcDDocumentStatus or tDDocumentStatusChange.tdDDocumentOriginalDebitTC <> tqDDocumentById.tdDDocumentOriginalDebitTC then do: <M-5 run SetMessage (input trim(#T-13'$1 $2 $3 cannot be updated because another user has modified its status or amount.':250(915)T-13#) (icMessage), input vcDDocumentType + chr(2) + string(tDDocumentStatusChange.tiDDocumentYear) + chr(2) + string(tDDocumentStatusChange.tiDDocumentNumber) (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QADFIN-2563':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BDDocument> assign oiReturnStatus = -1. next. end. /* Check existence of combination of Bank Number and Payment Format */ if tDDocumentStatusChange.tcBankNumber <> tDDocumentStatusChange.tcOriginalBankNumber or tDDocumentStatusChange.tcGLCode <> tDDocumentStatusChange.tcOriginalGLCode then do: if not vlStart2 then do: <Q-26 run BankPayFormatByID (Start) in BBankPayFormat > assign vlStart2 = true. end. /* if not vlStart2 */ <Q-23 run BankPayFormatByID (all) (Read) (NoCache) (input tDDocumentStatusChange.tiBankPayFormat_ID, (BankPayFormatId) input viCompanyId, (CompanyId) output dataset tqBankPayFormatByID) in BBankPayFormat > find first tqBankPayFormatByID where tqBankPayFormatByID.tiBankPayFormat_ID = tDDocumentStatusChange.tiBankPayFormat_ID no-error. if not available tqBankPayFormatByID then do: assign oiReturnStatus = -1 vcMsg = #T-40'The combination of the bank number ($1) and the payment format ($2) is not defined.':255(70370)T-40#. /* vcMsg = substitute(vcMsg, tDDocumentStatusChange.tcBankNumber, tDDocumentStatusChange.tcPayFormatTypeCode). */ <M-39 run SetMessage (input vcMsg (icMessage), input tDDocumentStatusChange.tcBankNumber + chr(2) + tDDocumentStatusChange.tcPayFormatTypeCode (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QadFin-8307':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BDDocument> next. end. /* if not available tqBankPayFormatByID */ end. /* if tDDocumentStatusChange.tcBankNumber <> tcOriginalBankNumber or */ if vcRowId <> "":U then assign vcRowId = vcRowId + ",":U. assign vcRowId = vcRowId + entry(1, tDDocumentStatusChange.tc_rowid). end. if vlStart1 then do: <Q-6 run DDocumentById (Stop) in BDDocument > end. /* if vlStart1 */ if vlStart2 then do: <Q-27 run BankPayFormatByID (Stop) in BBankPayFormat > end. /* if vlStart2 */ if oiReturnStatus < 0 then return. <M-7 run DataLoad (input vcRowId (icRowids), input '':U (icPkeys), input '':U (icObjectIds), input '':U (icFreeform), input false (ilKeepPrevious), output viFcReturnSuper (oiReturnStatus)) in BDDocument> if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. for each tDDocumentStatusChange where tDDocumentStatusChange.tcDDocumentStatus <> tDDocumentStatusChange.tcOriginalStatus or tDDocumentStatusChange.tcBankNumber <> tDDocumentStatusChange.tcOriginalBankNumber or tDDocumentStatusChange.tcGLCode <> tDDocumentStatusChange.tcOriginalGLCode or tDDocumentStatusChange.tcPayFormatTypeCode <> tDDocumentStatusChange.tcOriginalPayFormatTypeCode or tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> tDDocumentStatusChange.tcOriginalIncassoSelectCode: find tDDocument where tDDocument.DDocument_ID = tDDocumentStatusChange.tiDDocument_ID no-error. if not available tDDocument then do: assign vcMsg = trim(#T-48'Previously loaded document with ID $1 not found.':255(71500)T-48#). <M-8 run SetMessage (input vcMsg (icMessage), input tDDocumentStatusChange.tiDDocument_ID (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QADFIN-2564':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BDDocument> assign oiReturnStatus = -1. return. end. /* vlPayFormatCodeChange = true when only Payment Format Type Code is changed */ if tDDocumentStatusChange.tcBankNumber = tDDocumentStatusChange.tcOriginalBankNumber and tDDocumentStatusChange.tcGLCode = tDDocumentStatusChange.tcOriginalGLCode and tDDocumentStatusChange.tcPayFormatTypeCode <> tDDocumentStatusChange.tcOriginalPayFormatTypeCode then assign vlPayFormatCodeChange = true. assign tDDocument.ttPostingDate = itPostingDate tDDocument.tc_Status = "C":U. /* Status change */ if tDDocumentStatusChange.tcDDocumentStatus <> tDDocumentStatusChange.tcOriginalStatus then do: assign tDDocument.DDocumentStatus = tDDocumentStatusChange.tcDDocumentStatus. end. /* if tDDocumentStatusChange.tcDDocumentStatus <> tcOriginalStatus */ /* Own bank number change */ if tDDocumentStatusChange.tcBankNumber <> tDDocumentStatusChange.tcOriginalBankNumber or tDDocumentStatusChange.tcGLCode <> tDDocumentStatusChange.tcOriginalGLCode or tDDocumentStatusChange.tcPayFormatTypeCode <> tDDocumentStatusChange.tcOriginalPayFormatTypeCode then do: if tDDocument.DDocumentType <> tDDocumentStatusChange.tcDDocumentType and tDDocument.DDocumentNumber <> 0 then do: assign vhFcComponent = ?. <M-90 run GetNumber (input viCompanyId (iiCompanyId), input tDDocument.DDocumentYear (iiNumbrYear), input 'D':U + tDDocumentStatusChange.tcDDocumentType (icNumbrType), output tDDocument.DDocumentNumber (oiNumber), input viFcCurrentInstanceId (iiInstanceId), input vcFcComponentName (icClassName), output viFcReturnSuper (oiReturnStatus)) in BNumber> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFCReturnSuper. if oiReturnStatus < 0 then return. end. /* if tDDocument.DDocumentType <> tDDocumentStatusChange.tcDDocumentType and */ assign tDDocument.GL_ID = tDDocumentStatusChange.tiGL_ID tDDocument.tcGLCode = tDDocumentStatusChange.tcGLCode tDDocument.DDocumentType = tDDocumentStatusChange.tcDDocumentType viOriginalBankNumberID = tDDocument.BankNumber_ID. /* Check if the bank number has defined for the customer */ if not vlStart3 then do: <Q-29 run BankNumberByPayFormatParentObj (Start) in BBankNumber > assign vlStart3 = true. end. /* if not vlStart3 */ <Q-17 run BankNumberByPayFormatParentObj (all) (Read) (NoCache) (input tDDocumentStatusChange.tiBankPayFormat_ID, (PaymentFormatID) input tDDocument.Debtor_ID, (ParentObjectID) input ?, (CompanyId) output dataset tqBankNumberByPayFormatParentObj) in BBankNumber > find first tqBankNumberByPayFormatParentObj where tqBankNumberByPayFormatParentObj.tiBankPayFormat_ID = tDDocumentStatusChange.tiBankPayFormat_ID and tqBankNumberByPayFormatParentObj.tiParentObject_ID = tDDocument.Debtor_ID no-error. if available tqBankNumberByPayFormatParentObj and vlPayFormatCodeChange then do: assign tDDocument.BankNumber_ID = tqBankNumberByPayFormatParentObj.tiBankNumber_ID. end. else do: find first tqBankNumberByPayFormatParentObj where tqBankNumberByPayFormatParentObj.tiBankPayFormat_ID = tDDocumentStatusChange.tiBankPayFormat_ID and tqBankNumberByPayFormatParentObj.tiParentObject_ID = tDDocument.Debtor_ID and tqBankNumberByPayFormatParentObj.tcBankNumber = tDDocument.tcDebtorBankNumber no-error. /* Create the bank number for customer if it does not exist before */ if not available tqBankNumberByPayFormatParentObj then do: if viBBankNumber2ID = 0 or viBBankNumber2ID = ? then do: <I-41 {bFcStartAndOpenInstance &ADD-TO-TRANSACTION = "true" &CLASS = "BBankNumber"}> end. /* if viBBankNumber2ID = 0 or viBBankNumber2ID = ? */ else do: <I-42 {bFcOpenInstance &CLASS = "BBankNumber"}> end. /* else do: */ <M-85 run CreateCDBankNumberAsCopy (input tDDocument.BankNumber_ID (iiOriginalBankNumberID), input tDDocumentStatusChange.tiBankPayFormat_ID (iiNewPayFormatID), output tDDocument.BankNumber_ID (oiNewBankNumberID), output viFcReturnSuper (oiReturnStatus)) in BBankNumber> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then do: <I-44 {bFcCloseInstance &CLASS = "BBankNumber"}> if vlStart3 then do: <Q-45 run BankNumberByPayFormatParentObj (Stop) in BBankNumber > end. /* if vlStart3 */ return. end. /* if viFcReturnSuper < 0 */ end. /* if not available tqBankNumberByPayFormatParentObj */ else do: assign tDDocument.BankNumber_ID = tqBankNumberByPayFormatParentObj.tiBankNumber_ID. <Q-94 assign vlFcQueryRecordsAvailable = BankNumberByIDAllInfo (NoCache) (input viOriginalBankNumberID, (BankNumber_ID) input true, (BankNumberIsDefault)) in BBankNumber> if vlFcQueryRecordsAvailable = true then do: if viBBankNumber2ID = 0 or viBBankNumber2ID = ? then do: <I-50 {bFcStartAndOpenInstance &ADD-TO-TRANSACTION = "true" &CLASS = "BBankNumber"}> end. /* if viBBankNumber2ID = 0 or viBBankNumber2ID = ? */ else do: <I-53 {bFcOpenInstance &CLASS = "BBankNumber"}> end. /* else do: */ <M-51 run ChangeDefaultBankNumber (input tqBankNumberByPayFormatParentObj.tiBankNumber_ID (iiNewDefaultBankNumberID), output viFcReturnSuper (oiReturnStatus)) in BBankNumber> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then do: <I-59 {bFcCloseInstance &CLASS = "BBankNumber"}> if vlStart3 then do: <Q-836 run BankNumberByPayFormatParentObj (Stop) in BBankNumber> end. /* if vlStart3 */ return. end. /* if viFcReturnSuper < 0 */ end. /* if tqBankNumberByPayFormatParentObj.tlBankNumberIsDefault = true */ end. /* else do: */ end. /* else do: */ /* Find linked invoices and store to temp-table. Bank number of these invoices need to to updated also */ for each tDDocumentInvoiceXref where tDDocumentInvoiceXref.DDocument_ID = tDDocument.DDocument_ID: create tUpdateDInvBankNumber. assign tUpdateDInvBankNumber.tiDInvoiceId = tDDocumentInvoiceXref.DInvoice_ID tUpdateDInvBankNumber.tiNewBankNumberId = tDDocument.BankNumber_ID tUpdateDInvBankNumber.tiOldBankNumberId = viOriginalBankNumberID tUpdateDInvBankNumber.tdDInvoiceBankToPayTC = 0 tUpdateDInvBankNumber.tlPayFormatChanged = false. end. /* for each tDDocumentInvoiceXref where */ end. /* if tDDocumentStatusChange.tcBankNumber <> tcOriginalBankNumber or */ /* Set or regroup Payment Selection */ if tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> tDDocumentStatusChange.tcOriginalIncassoSelectCode then do: /* has this been created - if not create it */ find first tDPaySelRefDDoc where tDPaySelRefDDoc.DPaySelCode = tDDocumentStatusChange.tcDDocumentIncassoSelectCode no-error. if not available tDPaySelRefDDoc then do: create tDPaySelRefDDoc. assign tDPaySelRefDDoc.tc_Rowid = string(viDPaySelSequence) tDPaySelRefDDoc.tc_status = 'N':U tDPaySelRefDDoc.Company_ID = viCompanyId tDPaySelRefDDoc.DPaySelStatus = tDDocumentStatusChange.tcDDocumentStatus tDPaySelRefDDoc.tcPayFormatTypeCode = tDDocumentStatusChange.tcPayFormatTypeCode tDPaySelRefDDoc.GL_ID = tDDocumentStatusChange.tiGL_ID tDPaySelRefDDoc.tcGLCode = tDDocumentStatusChange.tcGLCode tDPaySelRefDDoc.BankPayFormat_ID = tDDocumentStatusChange.tiBankPayFormat_ID tDPaySelRefDDoc.DPaySelCode = tDDocumentStatusChange.tcDDocumentIncassoSelectCode tDPaySelRefDDoc.tiBankNumber_ID = tDDocumentStatusChange.tiBankNumber_ID tDPaySelRefDDoc.DPaySelDate = today viDPaySelSequence = viDPaySelSequence - 1. /* add the header fields */ find first tDPaySelPayCodeRefDDoc where tDPaySelPayCodeRefDDoc.tc_ParentRowid = tDPaySelRefDDoc.DPaySelCode no-error. if available tDPaySelPayCodeRefDDoc and tDPaySelPayCodeRefDDoc.tc_ParentRowid = tDPaySelRefDDoc.DPaySelCode then do: for each tDPaySelPayCodeRefDDoc where tDPaySelPayCodeRefDDoc.tc_ParentRowid = tDPaySelRefDDoc.DPaySelCode: assign tDPaySelPayCodeRefDDoc.tc_ParentRowid = tDPaySelRefDDoc.tc_Rowid. if tDPaySelPayCodeRefDDoc.tcPayFormatCode <> ? and tDPaySelPayCodeRefDDoc.tcPayFormatCode <> "":U then do: <Q-92 run PayFormatCodebyGroupID (all) (Read) (NoCache) (input ?, (PayFormatCodeID) input tDPaySelPayCodeRefDDoc.tcPayFormatCode, (PayFormatCode) input tDPaySelPayCodeRefDDoc.PayFormatGroup_ID, (PayFormatGroupID) output dataset tqPayFormatCodebyGroupID) in BPaymentFormat> find first tqPayFormatCodebyGroupID no-error. if available tqPayFormatCodebyGroupID then assign tDPaySelPayCodeRefDDoc.PayFormatCode_ID = tqPayFormatCodebyGroupID.tiPayFormatCode_ID tDPaySelPayCodeRefDDoc.DPaySelPayCodeValue = '':U. else assign tDPaySelPayCodeRefDDoc.PayFormatCode_ID = 0 tDPaySelPayCodeRefDDoc.DPaySelPayCodeValue = tDPaySelPayCodeRefDDoc.tcPayFormatCode. end. /* tDPaySelPayCodeRefDDoc.tcPayFormatCode defined */ else do: assign tDPaySelPayCodeRefDDoc.PayFormatCode_ID = 0 tDPaySelPayCodeRefDDoc.DPaySelPayCodeValue = "":U. end. /* tDPaySelPayCodeRefDDoc.tcPayFormatCode not defined */ end. /* for each tDPaySelPayCodeRefDDoc */ end. /* if available tDPaySelPayCodeRefDDoc */ else do: /* headers not set in UI so create them here */ <Q-71 run PayFormatCodeByDefault (all) (Read) (NoCache) (input tDDocumentStatusChange.tcPayFormatTypeCode, (PayFormatTypeCode) input ?, (PayFormatGroupSequence) input true, (PayFormatGroupIsActive) input true, (PayFormatCodeIsActive) input true, (PayFormatCodeIsDefault) output dataset tqPayFormatCodeByDefault) in BPaymentFormat> for each tqPayFormatCodeByDefault where tqPayFormatCodeByDefault.tcPayFormatGroupLevel = {&PAYFORMATGROUPLEVEL-HEADER}: create tDPaySelPayCodeRefDDoc. assign tDPaySelPayCodeRefDDoc.PayFormatGroup_ID = tqPayFormatCodeByDefault.tiPayFormatGroup_ID tDPaySelPayCodeRefDDoc.PayFormatCode_ID = tqPayFormatCodeByDefault.tiPayFormatCode_ID tDPaySelPayCodeRefDDoc.tcPayFormatGroupCode = tqPayFormatCodeByDefault.tcPayFormatGroupCode tDPaySelPayCodeRefDDoc.tcPayFormatGroupDescription = tqPayFormatCodeByDefault.tcPayFormatGroupDescription tDPaySelPayCodeRefDDoc.tcPayFormatCode = tqPayFormatCodeByDefault.tcPayFormatCode tDPaySelPayCodeRefDDoc.tcPayFormatCodeDescription = tqPayFormatCodeByDefault.tcPayFormatCodeDescription tDPaySelPayCodeRefDDoc.tcPayFormatGroupDataType = tqPayFormatCodeByDefault.tcPayFormatGroupDataType tDPaySelPayCodeRefDDoc.tcPayFormatGroupInputOption = tqPayFormatCodeByDefault.tcPayFormatGroupInputOption tDPaySelPayCodeRefDDoc.tlPayFormatGroupIsMandatory = tqPayFormatCodeByDefault.tlPayFormatGroupIsMandatory tDPaySelPayCodeRefDDoc.tc_ParentRowid = tDPaySelRefDDoc.tc_Rowid tDPaySelPayCodeRefDDoc.tc_Rowid = string(viPaySelCodeHeaderSequence) tDPaySelPayCodeRefDDoc.tc_status = 'N':U viPaySelCodeHeaderSequence = viPaySelCodeHeaderSequence - 1. end. /* for each tqPayFormatCodeByDefault */ end. /* else do */ end. /* if not available tDPaySelRefDDoc */ /* If the ddocument is already part of a selection then add that selection to comma delimited list - if selection has no more documents attached it will be deleted in the post save */ if tDDocument.DPaySel_ID <> ? and tDDocument.DPaySel_ID <> 0 then do: if lookup(string(tDDocument.DPaySel_ID), vcDPaySelRecordsIDChanged, ",":U) = 0 then do: if vcDPaySelRecordsIDChanged <> "":U then assign vcDPaySelRecordsIDChanged = vcDPaySelRecordsIDChanged + chr(4). assign vcDPaySelRecordsIDChanged = vcDPaySelRecordsIDChanged + entry(1, string(tDDocument.DPaySel_ID)). end. /* if lookup(tDDocument.tc_ParentRowid */ end. /* if tDDocument.tc_ParentRowid */ assign tDDocument.tc_ParentRowid = tDPaySelRefDDoc.tc_Rowid tDDocument.DDocumentIncassoSelectCode = tDDocumentStatusChange.tcDDocumentIncassoSelectCode. end. /* if tDDocumentStatusChange.tcDDocumentIncassoSelectCode <> */ end. if vlStart3 then do: <Q-32 run BankNumberByPayFormatParentObj (Stop) in BBankNumber > end. /* if vlStart3 */ if viBBankNumber2ID <> 0 and viBBankNumber2ID <> ? then do: <M-47 run ValidateBCAndAdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BBankNumber> /* ========================================================================================================= */ /* Normally we would here close BBankNumber but we will not do it for performance */ /* reasons as this way the Commit of the transaction does not have to re-open the instance to commit it. */ /* And in all other scenario's the instance of the class ill be closed by the de-activiate procedure of the */ /* appserver that is executed after each call to the appserver */ /* ========================================================================================================= */ if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. end. /* if viBBankNumber2ID <> 0 and viBBankNumber2ID <> ? */ <M-9 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BDDocument> if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. <M-10 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BDDocument> if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. <M-11 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BDDocument> if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return.
define temp-table ttContext no-undo field propertyQualifier as character field propertyName as character field propertyValue as character index entityContext is primary unique propertyQualifier propertyName index propertyQualifier propertyQualifier. define dataset dsContext for ttContext. define variable vhContextDS as handle no-undo. define variable vhExceptionDS as handle no-undo. define variable vhServer as handle no-undo. define variable vhInputDS as handle no-undo. define variable vhInputOutputDS as handle no-undo. define variable vhOutputDS as handle no-undo. define variable vhParameter as handle no-undo. /* Create context */ create ttContext. assign ttContext.propertyName = "programName" ttContext.propertyValue = "BDDocument". create ttContext. assign ttContext.propertyName = "methodName" ttContext.propertyValue = "ApiSetDDocumentStatusChange". create ttContext. assign ttContext.propertyName = "applicationId" ttContext.propertyValue = "fin". create ttContext. assign ttContext.propertyName = "entity" ttContext.propertyValue = "1000". create ttContext. assign ttContext.propertyName = "userName" ttContext.propertyValue = "mfg". create ttContext. assign ttContext.propertyName = "password" ttContext.propertyValue = "". /* Create input dataset */ create dataset vhInputDS. vhInputDS:read-xmlschema("file", "xml/bddocument.apisetddocumentstatuschange.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::itPostingDate = <parameter value> vhParameter::icFileFormat = <parameter value>. vhParameter = vhInputDS:get-buffer-handle("tDDocumentStatusChange"). vhParameter:buffer-create(). assign vhParameter::<field-name-1> = <field-value-1> vhParameter::<field-name-2> = <field-value-2> ... /* Connect the AppServer */ create server vhServer. vhServer:connect("-URL <appserver-url>"). if not vhServer:connected() then do: message "Could not connect AppServer" view-as alert-box error title "Error". return. end. /* Run */ assign vhContextDS = dataset dsContext:handle. run program/rpcrequestservice.p on vhServer (input-output dataset-handle vhContextDS by-reference, output dataset-handle vhExceptionDS, input dataset-handle vhInputDS by-reference, input-output dataset-handle vhInputOutputDS by-reference, output dataset-handle vhOutputDS). /* Handle output however you want, in this example, we dump it to xml */ if valid-handle(vhExceptionDS) then vhExceptionDS:write-xml("file", "Exceptions.xml", true). if valid-handle(vhOutputDS) then vhOutputDS:write-xml("file", "Output.xml", true). /* Cleanup */ vhServer:disconnect(). assign vhServer = ?. if valid-handle(vhInputDS) then delete object vhInputDS. if valid-handle(vhOutputDS) then delete object vhOutputDS. if valid-handle(vhExceptionDS) then delete object vhExceptionDS.