project QadFinancials > class BMFGLegalDocument > method ApiLegalDocumentReport

Description

API Method used to return information for supplier invoices for a set of legal documents. This method returns supplier invoice information as well as the corresponding journal entry information.


Parameters


icDomaininputcharacterDomain code for the working domain.
ilLegalDocumentTypeinputlogicalLegal document type: logical value.
icLegalDocumentFrominputcharacterFiltering parameter: start value for the legal document numbers.
icLegalDocumentToinputcharacterFiltering parameter: end value for the legal document numbers.
itReceiveDateFrominputdateFiltering parameter: beginning date for the receipt dates.
itReceiveDateToinputdateFiltering parameter: ending date for the receipt dates.
icShiptoFrominputcharacterFiltering parameter: start value for the ship to addresses.
icShipToToinputcharacterFiltering parameter: end value for the ship to addresses.
ilReprintinputlogicalLogical flag - sets the mode of the report to reprint (to reprint previously printed documents).
tCInvoiceRptoutputtemp-tableOutput temp-table holding the supplier invoice information.
tCInvoicePostingLineoutputtemp-tableOutput temp-table holding the journal entry (GL transaction) information of the supplier invoices.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bmfglegaldocument.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.
       
       
<Q-79 run LegalDocByLegDocByShipToByDate (all) (Read) (NoCache)
           (input icDomain, (DomainCode)
            input ilLegalDocumentType, (Type)
            input icLegalDocumentFrom, (LegalDocumentFrom)
            input icLegalDocumentTo, (LegalDocumentTo)
            input itReceiveDateFrom, (ReceiveDateFrom)
            input itReceiveDateTo, (ReceiveDateTo)
            input icShiptoFrom, (ShipToFrom)
            input icShipToTo, (ShipToTo)
            output dataset tqLegalDocByLegDocByShipToByDate) in BMFGLegalDocument >
            
            
for each tqLegalDocByLegDocByShipToByDate where
         tqLegalDocByLegDocByShipToByDate.ttlgd_print_date = ? or 
         ilReprint = TRUE:
    
    <M-70 run getHistInvoiceComponentsByNRM
       (input  tqLegalDocByLegDocByShipToByDate.tclgd_inv_nbr (icInvoiceNumber), 
        input  tqLegalDocByLegDocByShipToByDate.tclgd_domain (icGlobalDomain), 
        output viPostingYear (oiYear), 
        output vcJournalCode (ocJournalCode), 
        output viPostingVoucher (oiVoucherNumber), 
        output viFcReturnSuper (oiReturnStatus)) in BMFGLegalDocument>
    if viFcReturnSuper < 0 then
    do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.

    <Q-4 run CInvoiceForLegalDocument (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input viPostingYear, (PostingYear)
        input vcJournalCode, (JournalCode)
        input viPostingVoucher, (PostingVoucher)
        output dataset tqCInvoiceForLegalDocument) in BCInvoice >
    
    for each tqCInvoiceForLegalDocument where
             tqCInvoiceForLegalDocument.tiCInvoicePostingYear = viPostingYear    and
             tqCInvoiceForLegalDocument.tiCInvoiceVoucher     = viPostingVoucher and
             tqCInvoiceForLegalDocument.tcJournalCode         = vcJournalCode
    no-lock:
    
        find first tCInvoiceRpt where
                   tCInvoiceRpt.tiPostingYear    = tqCInvoiceForLegalDocument.tiCInvoicePostingYear and
                   tCInvoiceRpt.tiPostingVoucher = tqCInvoiceForLegalDocument.tiCInvoiceVoucher     and
                   tCInvoiceRpt.tcJournalCode    = tqCInvoiceForLegalDocument.tcJournalCode
        no-lock no-error.
        
        if not available tCInvoiceRpt
        then do:
            create tCInvoiceRpt.
            assign tCInvoiceRpt.tiPostingYear    = tqCInvoiceForLegalDocument.tiCInvoicePostingYear
                   tCInvoiceRpt.tiPostingVoucher = tqCInvoiceForLegalDocument.tiCInvoiceVoucher 
                   tCInvoiceRpt.tcJournalCode    = tqCInvoiceForLegalDocument.tcJournalCode
                   tCInvoiceRpt.tcInvoiceNumber  = string(tqCInvoiceForLegalDocument.tiCInvoicePostingYear,'9999') + '/':U +
                                                   trim(tqCInvoiceForLegalDocument.tcJournalCode) + '/':U +
                                                   string(tqCInvoiceForLegalDocument.tiCInvoiceVoucher,'999999999')
                   tCInvoiceRpt.tlConfirmed      = NOT tqCInvoiceForLegalDocument.tlCInvoiceIsInitialStatus
                   tCInvoiceRpt.ttDueDate        = tqCInvoiceForLegalDocument.ttCInvoiceDueDate
                   tCInvoiceRpt.tcCurrencyCode   = tqCInvoiceForLegalDocument.tcCurrencyCode
                   tCInvoiceRpt.tcBatch          = tqCInvoiceForLegalDocument.tcCInvoiceBatchNumber
                   tCInvoiceRpt.tdTradeAmount    = tqCInvoiceForLegalDocument.tdCInvoiceBalanceTC
                   tCInvoiceRpt.tdInvoiceAmount  = tqCInvoiceForLegalDocument.tdCInvoiceOriginalDebitTC - tqCInvoiceForLegalDocument.tdCInvoiceOriginalCreditTC.
        end. /* if nto available tCInvoiceRpt */
    
        find first tCInvoicePostingLine where
                   tCInvoicePostingLine.tcInvoiceNumber    = tCInvoiceRpt.tcInvoiceNumber                                            and
                   tCInvoicePostingLine.tcPostingReference = string(tqCInvoiceForLegalDocument.tiPostingYear,'9999') + '/':U +
                                                             trim(tqCInvoiceForLegalDocument.tcJournalCode1) + '/':U +
                                                             string(tqCInvoiceForLegalDocument.tiPostingVoucher,'999999999')        and
                   tCInvoicePostingLine.tiPostingLine      = tqCInvoiceForLegalDocument.tiPostingLineSequence
        no-lock no-error.
        
        if not available tCInvoicePostingLine
        then do:
            create tCInvoicePostingline.
            assign tCInvoicePostingLine.tcInvoiceNumber    = tCInvoiceRpt.tcInvoiceNumber
                   tCInvoicePostingLine.tcPostingReference = string(tqCInvoiceForLegalDocument.tiPostingYear,'9999') + '/':U +
                                                             trim(tqCInvoiceForLegalDocument.tcJournalCode1) + '/':U +
                                                             string(tqCInvoiceForLegalDocument.tiPostingVoucher,'999999999')
                   tCInvoicePostingLine.tiPostingLine      = tqCInvoiceForLegalDocument.tiPostingLineSequence
                   tCInvoicePostingLine.tcTransType        = tqCInvoiceForLegalDocument.tcJournalTypeCode
                   tCInvoicePostingLine.tdBaseAmount       = tqCInvoiceForLegalDocument.tdPostingLineDebitLC - tqCInvoiceForLegalDocument.tdPostingLineCreditLC
                   tCInvoicePostingLine.tdCurrencyAmount   = tqCInvoiceForLegalDocument.tdPostingLineDebitTC - tqCInvoiceForLegalDocument.tdPostingLineCreditTC.


            <Q-46 run GLByGLCodeGLID (all) (Read) (NoCache)
               (input tqCInvoiceForLegalDocument.tiCompany_ID, (CompanyId)
                input '':U, (GLCode)
                input tqCInvoiceForLegalDocument.tiGL_ID, (GLId)
                output dataset tqGLByGLCodeGLID) in BGL >
            find first tqGLByGLCodeGLID where
                       tqGLByGLCodeGLID.tiGL_ID = tqCInvoiceForLegalDocument.tiGL_ID
            no-lock no-error.
            
            if available tqGLByGLCodeGLID then
                assign tCInvoicePostingLine.tcGlCode = tqGLByGLCodeGLID.tcGLCode.
            else do:
                assign vcMessage           = trim(substitute(#T-20'Cannot find GL Account for ID number &1':250(267232784)T-20#,tqCInvoiceForLegalDocument.tiGL_ID))
                       viLocalReturnStatus = -1.
                <M-11 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-795397':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BMFGLegalDocument>
            
            end. /* NOT if available tqGLByGLCodeGLID */
            
            if tqCInvoiceForLegalDocument.tiDivision_ID <> 0 or 
               tqCInvoiceForLegalDocument.tiDivision_ID <> ?
            then do:
                <Q-8 run DivisionByIdCodeDetails (all) (Read) (NoCache)
                   (input tqCInvoiceForLegalDocument.tiCompany_ID, (CompanyId)
                    input '':U, (DivisionCode)
                    input '':U, (DivisionDescription)
                    input ?, (DivisionIsActive)
                    input tqCInvoiceForLegalDocument.tiDivision_ID, (DivisionId)
                    output dataset tqDivisionByIdCodeDetails) in BDivision >
                    
                find first tqDivisionByIdCodeDetails where
                          tqDivisionByIdCodeDetails.tiDivision_ID = tqCInvoiceForLegalDocument.tiDivision_ID
                no-lock no-error.
                
                if available tqDivisionByIdCodeDetails then
                    assign tCInvoicePostingLine.tcDivisionCode = tqDivisionByIdCodeDetails.tcDivisionCode.
                else do:
                    assign vcMessage           = trim(substitute(#T-44'Cannot find Sub-Account for ID number &1':250(699057303)T-44#,tqCInvoiceForLegalDocument.tiDivision_ID))
                           viLocalReturnStatus = -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-410219':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BMFGLegalDocument>
                
                end. /* NOT if available tqDivisionByIdCodeDetails       */
            end.     /* if tqCInvoiceForLegalDocument.tiDivision_ID <> 0 */
            
            if tqCInvoiceForLegalDocument.tiCostCentre_ID <> 0 or
               tqCInvoiceForLegalDocument.tiCostCentre_ID <> ?
            then do:   
                <Q-48 run CostCentreByCodeID (all) (Read) (NoCache)
                   (input tqCInvoiceForLegalDocument.tiCompany_ID, (CompanyId)
                    input '':U, (CostCentreCode)
                    input tqCInvoiceForLegalDocument.tiCostCentre_ID, (CostCentreID)
                    output dataset tqCostCentreByCodeID) in BCostCentre >
                    
                find first tqCostCentreByCodeID where
                          tqCostCentreByCodeID.tiCostCentre_ID = tqCInvoiceForLegalDocument.tiCostCentre_ID
                no-lock no-error.
                
                if available tqCostCentreByCodeID then
                    assign tCInvoicePostingLine.tcCostCentreCode   = tqCostCentreByCodeID.tcCostCentreCode.
                else do:
                    assign vcMessage           = trim(substitute(#T-22'Cannot find Cost Center for ID number &1':250(436779847)T-22#,tqCInvoiceForLegalDocument.tiCostCentre_ID))
                           viLocalReturnStatus = -1.
                    <M-97 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-77519':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BMFGLegalDocument>
                
                end. /* NOT if avialable tqCostCentreByCodeID              */
            end.     /* if tqCInvoiceForLegalDocument.tiCostCentre_ID <> 0 */
            
            if tqCInvoiceForLegalDocument.tiProject_ID <> 0 or
               tqCInvoiceForLegalDocument.tiProject_ID <> ?
           then do:
                <Q-38 run ProjectByIDAllInfo (all) (Read) (NoCache)
                   (input tqCInvoiceForLegalDocument.tiCompany_ID, (CompanyId)
                    input tqCInvoiceForLegalDocument.tiProject_ID, (ProjectId)
                    output dataset tqProjectByIDAllInfo) in BProject >
                 
                find first tqProjectByIDAllInfo where
                          tqProjectByIDAllInfo.tiProject_ID = tqCInvoiceForLegalDocument.tiProject_ID
                no-lock no-error.
                
                if available tqProjectByIDAllInfo then
                    assign tCInvoicePostingLine.tcProjectCode      = tqProjectByIDAllInfo.tcProjectCode.
                else do:
                    assign vcMessage           = trim(substitute(#T-7'Cannot find Project for ID number &1':250(10753312)T-7#,tqCInvoiceForLegalDocument.tiProject_ID))
                           viLocalReturnStatus = -1.
                    <M-63 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-710979':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BMFGLegalDocument>
                end. /* NOT if available tqProjectByIDAllInfo           */
            end.     /* if tqCInvoiceForLegalDocument.tiProject_ID <> 0 */ 
        end.         /* if not available tCInvoicePostingLine           */
    end.             /* find first tqCInvoiceForLegalDocument           */
end.                 /* for each tqLegalDocByLegDocByShipToByDate where */

if viLocalReturnStatus <> 0 then assign oiReturnStatus = viLocalReturnStatus.
if oiReturnStatus = -98 then assign oiReturnStatus = 0.


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 = "BMFGLegalDocument".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiLegalDocumentReport".
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/bmfglegaldocument.apilegaldocumentreport.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icDomain = <parameter value>
       vhParameter::ilLegalDocumentType = <parameter value>
       vhParameter::icLegalDocumentFrom = <parameter value>
       vhParameter::icLegalDocumentTo = <parameter value>
       vhParameter::itReceiveDateFrom = <parameter value>
       vhParameter::itReceiveDateTo = <parameter value>
       vhParameter::icShiptoFrom = <parameter value>
       vhParameter::icShipToTo = <parameter value>
       vhParameter::ilReprint = <parameter value>.

/* 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.