project QadFinancials > class BBill > method SetBillDate
Description
Set bill date for input invoices.
Parameters
Internal usage
unused
program code (program3/bbill.p)
empty temp-table tDInvoiceToBillForSave.
<M-33 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BBill>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
assign vhPersistanceViaFcComponent = vhFcComponent.
for each t_sDInvoiceToBillForSave:
create tDInvoiceToBillForSave.
buffer-copy t_sDInvoiceToBillForSave to tDInvoiceToBillForSave.
end.
for each tDInvoiceToBillForSave where tDInvoiceToBillForSave.tlDInvoiceIsSelected = yes:
/* In new bill, bill date cannot be less than the invoice date. */
if tDInvoiceToBillForSave.ttDInvoiceDate > tDInvoiceToBillForSave.ttDInvoiceBillDate then
do:
<M-41 run SetMessage
(input trim(#T-35'The bill date cannot be earlier than any invoice date for that bill.':255(990032956)T-35#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'qadfin-601313':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBill>
assign oiReturnStatus = -1.
return.
end.
if tDInvoiceToBillForSave.tlBillScheduleIsUpdInvByBill then
tDInvoiceToBillForSave.ttDInvoiceDueDate = tDInvoiceToBillForSave.ttBillDueDate.
assign vcForEachClause = "for each DInvoice where DInvoice.DInvoice_ID = ":U + string(tDInvoiceToBillForSave.tiDInvoice_ID)
vcFieldList = "Bill_ID,DInvoiceDueDate,DInvoiceBillDate":U
vcFieldListDataTypes = "i,t,t":U
vcValueList = "0" + chr(02) + string(tDInvoiceToBillForSave.ttDInvoiceDueDate) + chr(02) + string(tDInvoiceToBillForSave.ttDInvoiceBillDate).
assign vhFcComponent = vhPersistanceViaFcComponent.
<M-55 run WriteDirect
(input 'DInvoice':U (icTableName),
input vcForEachClause (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.
end. /* end for each tDInvoiceToBillForSave */
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 = "BBill".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "SetBillDate".
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/bbill.setbilldate.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tDInvoiceToBillForSave").
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.