Parameters
t_sPostingStatusChange | input | temp-table | |
icActivityCode | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bjournalentry.p)
if oiReturnStatus = 0
then oiReturnStatus = -98.
if not can-find (first t_sPostingStatusChange where
t_sPostingStatusChange.tlPostingSelected = true)
then do:
<M-22 run SetMessage
(input #T-24'Select at least one record.':50(59420)t-24# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5994':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign oiReturnStatus = -1.
return.
end.
<M-73 run StartPersistence
(output vhWriteDirect (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then do:
assign vcMessage = trim(substitute(#T-74'Internal error: Unable to access the persistence-layer from &1.':255(523751093)T-74#, "BPosting:GetRangeOfNewPostingIDs":U ))
oiReturnStatus = -3.
<M-83 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'qadfin-326978':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
end.
return.
end. /* if viFcReturnSuper <> 0 */
if icActivityCode = 'Approve':U or icActivityCode = 'Verify':U
then do:
assign
vcRowid = '':U
vlStatusChangeRequested = false.
for each t_sPostingStatusChange where
t_sPostingStatusChange.tlPostingSelected = true:
if icActivityCode = 'Verify':U
then assign
vcStatus = t_sPostingStatusChange.PostingVerifyStatus.
else assign
vcStatus = t_sPostingStatusChange.PostingApproveStatus.
if t_sPostingStatusChange.tcOriginalStatus <> vcStatus
then do:
/* check Creator, Verifier and Approver */
if viUsrId = t_sPostingStatusChange.CreatorUsr_ID or
(icActivityCode = 'Verify':U and viUsrId = t_sPostingStatusChange.LastApprovedUsr_ID) or
(icActivityCode = 'Approve':U and viUsrId = t_sPostingStatusChange.LastVerifiedUsr_ID)
then do:
<M-21 run SetMessage
(input #T-16'You must select a different Creator, Verifier, and Approver.':100(59419)t-16# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingStatusChange.tc_Rowid (icRowid),
input 'QadFin-5993':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign
oiReturnStatus = -1.
return.
end.
<Q-2 assign vlFcQueryRecordsAvailable = PostingByPostingId (NoCache)
(input ?, (CompanyId)
input t_sPostingStatusChange.Posting_ID, (PostingId)
input ?, (JournalTypeCode)) in BPosting >
if not vlFcQueryRecordsAvailable
then do:
<M-3 run SetMessage
(input #T-7'The posting has been deleted.':50(57344)t-7# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input t_sPostingStatusChange.tc_Rowid (icRowid),
input 'QadFin-5860':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign
oiReturnStatus = -1.
return.
end.
if icActivityCode = 'Verify':U
then do:
<Q-8 assign vlFcQueryRecordsAvailable = VerifyStatusTransByAll (NoCache)
(input t_sPostingStatusChange.Company_ID, (CompanyId)
input t_sPostingStatusChange.tcOriginalStatus, (VerifyStatusTransFrStatus)
input t_sPostingStatusChange.PostingVerifyStatus, (VerifyStatusTransToStatus)) in BVerifyStatusTransition >
end.
else do:
<Q-20 assign vlFcQueryRecordsAvailable = ApproveStatusTransByAll (NoCache)
(input t_sPostingStatusChange.Company_ID, (CompanyId)
input t_sPostingStatusChange.tcOriginalStatus, (ApproveStatusTransFrStatus)
input t_sPostingStatusChange.PostingApproveStatus, (ApproveStatusTransToStatus)) in BApproveStatusTransition>
end.
if not vlFcQueryRecordsAvailable
then do:
<M-11 run SetMessage
(input #T-15'The status change has not been defined in StatusTransition.':50(59403)t-15# (icMessage),
input '':U (icArguments),
input 't_sPostingStatusChange.tcOriginalStatus':U (icFieldName),
input t_sPostingStatusChange.tcOriginalStatus (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input t_sPostingStatusChange.tc_Rowid (icRowid),
input 'QadFin-5862':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign
oiReturnStatus = -1.
return.
end. /* if not vlFcQueryRecordsAvailable */
/* Additional GL Numbering date validation */
if icActivityCode = 'Approve':U
then do:
if t_sPostingStatusChange.PostingAddGLNbrDate <> ?
and t_sPostingStatusChange.PostingDate > t_sPostingStatusChange.PostingAddGLNbrDate
then do:
assign oiReturnStatus = -1
vcMessage = #T-58'Additional GL Numbering date cannot be earlier than posting date':255(522633188)T-58#.
vcDatetemp = <M-62 DisplayDate (input t_sPostingStatusChange.PostingDate (itDate)) in BJournalEntry>.
<M-88 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPostingStatusChange.PostingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingStatusChange.tc_Rowid (icRowid),
input 'qadfin-226680':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
return.
end.
if t_sPostingStatusChange.PostingAddGLNbrDate <> ?
and t_sPostingStatusChange.PostingAddGLNbrDate <> t_sPostingStatusChange.ttOriginalAddGLNbrDate
then do:
<Q-26 run JournalByJournalLayerType (all) (Read) (Cache)
(input t_sPostingStatusChange.Journal_ID, (JournalId)
input '':U, (JournalCode)
input t_sPostingStatusChange.Company_ID, (CompanyId)
input '':U, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal>
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tcJournalCode = t_sPostingStatusChange.tcJournalCode
no-error.
if available tqJournalByJournalLayerType and
tqJournalByJournalLayerType.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT}
then assign vlNeedCheckCorrectionPeriod = no.
else assign vlNeedCheckCorrectionPeriod = yes.
/* If the original posting is on transient layer, let user modify numbering date */
if vlNeedCheckCorrectionPeriod
then do:
if vlOpenPeriodInstance = false
then do:
<I-5 {bFcStartAndOpenInstance
&CLASS = "BPeriod"}>
assign vlOpenPeriodInstance = true.
end.
<M-92 run CheckForCorrectionPeriod
(input t_sPostingStatusChange.Company_ID (iiCompanyID),
input t_sPostingStatusChange.PostingYearPeriod (iiYearPeriod),
output vlIsCorrPeriod (olIsCorrPrd),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if not vlIsCorrPeriod
then do:
assign oiReturnStatus = -1
vcMessage = #T-75'Additional GL Numbering date cannot be changed out of a Correction Period':255(135371830)T-75#.
vcDatetemp = <M-61 DisplayDate (input t_sPostingStatusChange.PostingDate (itDate)) in BJournalEntry>.
<M-78 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPostingStatusChange.PostingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingStatusChange.tc_Rowid (icRowid),
input 'qadfin-322147':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
return.
end. /* if not vlIsCorrPeriod */
end. /* if vlNeedCheckCorrectionPeriod */
end. /* if t_sPosting.PostingAddGLNbrDate */
end. /* if icActivityCode = 'Approve':U */
assign vcRowid = t_sPostingStatusChange.tc_Rowid.
if vcRowid <> '':U
then do:
assign vcWhereClause = "for each Posting where Posting_ID = ":U + string(t_sPostingStatusChange.Posting_ID).
if icActivityCode = 'Verify':U
then assign
vcFieldListDataTypes = "t,t,i,c,c":U
vcValueList = string(today) + chr(02) + string(integer(time)) + chr(02) + string(viUsrId) + chr(02) + t_sPostingStatusChange.PostingVerifyStatus + chr(02) + t_sPostingStatusChange.PostingVerifyComments
vcFieldList = "PostingVerifiedDate,PostingVerifiedTime,LastVerifiedUsr_ID,PostingVerifyStatus,PostingVerifyComments":U.
else assign
vcFieldListDataTypes = "t,t,i,c,c,t":U
vcValueList = string(today) + chr(02) + string(integer(time)) + chr(02) + string(viUsrId) + chr(02) + t_sPostingStatusChange.PostingApproveStatus + chr(02) + t_sPostingStatusChange.PostingApproveComments + chr(02) + string(t_sPostingStatusChange.PostingAddGLNbrDate)
vcFieldList = "PostingApprovedDate,PostingApprovedTime,LastApprovedUsr_ID,PostingApproveStatus,PostingApproveComments,PostingAddGLNbrDate":U.
assign vhFcComponent = vhWriteDirect.
<M-19 run WriteDirect
(input 'Posting':U (icTableName),
input vcWhereClause (icPrepare),
input vcFieldList (icFieldList),
input vcFieldListDataTypes (icFieldListDataTypes),
input vcValueList (icAbsolute),
input '':U (icIncremental),
input {&TARGETPROCEDURE} (ihClass),
input vcUserLogin (icUserLogin),
output viFcReturnSuper (oiReturnStatus)) in Progress>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if viFcReturnSuper <> 0 */
vlStatusChangeRequested = true.
end. /* if vcRowid = '':U */
end. /* if comment or status is changed */
end. /* for each selected posting */
if vlStatusChangeRequested = false
then do:
<M-25 run SetMessage
(input #T-25'Please change the status on at least one record before commiting any changes':255(71128)T-25# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8633':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign oiReturnStatus = -1.
return.
end.
end.
if oiReturnStatus = -98
then oiReturnStatus = 0.
/* ============================================== */
/* close queries and delete buffer handle objects */
/* ============================================== */
FINALLY:
if vlOpenPeriodInstance = true
then do:
<I-32 {bFcCloseInstance
&CLASS = "BPeriod"}>
end. /* if vlOpenPeriodInstance */
END FINALLY.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
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 = "BJournalEntry".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiSetPostingStatusChange".
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/bjournalentry.apisetpostingstatuschange.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icActivityCode = <parameter value>.
vhParameter = vhInputDS:get-buffer-handle("tPostingStatusChange").
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.