project QadFinancials > class BMassLayerTransfer > method ApiGetJournalEntries


Parameters


icTransientLayerCodeinputcharacter
icJournalCodeinputcharacter
iiPeriodYearFrominputinteger
iiPeriodPeriodFrominputinteger
iiPeriodYearToinputinteger
iiPeriodPeriodToinputinteger
itDateFrominputdate
itDateToinputdate
icDescriptioninputcharacter
icTargetJournalCodeinputcharacter
icActivityCodeinputcharacterAcitivty-code: in case the current-activity is not yet known on business-side and this parameter is filled, then the current activity-code on business-side will be filled with the value of this parameter.
tMassLayerTransferJournalEoutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bmasslayertransfer.p)

/* =========================================================================== */
/* This method receives filtering parameters from the UI, makes validation     */
/* of these parameters and retrieves journal entries fitting these parameters  */
/* =========================================================================== */ 

assign oiReturnStatus = -98.

/* Normalize input parameters */
if icTransientLayerCode = "" then assign icTransientLayerCode = ?.
if icJournalCode        = "" then assign icJournalCode        = ?.
if iiPeriodYearFrom     = 0  then assign iiPeriodYearFrom     = ?.
if iiPeriodPeriodFrom   = 0  then assign iiPeriodPeriodFrom   = ?.
if iiPeriodYearTo       = 0  then assign iiPeriodYearTo       = ?.
if iiPeriodPeriodTo     = 0  then assign iiPeriodPeriodTo     = ?.
if icDescription        = "" then assign icDescription        = ?.
if icTargetJournalCode  = "" then assign icTargetJournalCode  = ?.

/* Set curent activity when not yet known on business-side and when the associated parameter is filled */
if icActivityCode <> "":U and 
   icActivityCode <> ?    and 
   (vcActivityCode = "":U or
    vcActivityCode = ?)
then assign vcActivityCode = icActivityCode.

/* Validate input data and retrieve missing information */
<M-1 run ApiGetJournalEntriesValidate
   (input  icTransientLayerCode (icTransientLayerCode), 
    input  icJournalCode (icJournalCode), 
    input  iiPeriodYearFrom (iiPeriodYearFrom), 
    input  iiPeriodPeriodFrom (iiPeriodPeriodFrom), 
    input  iiPeriodYearTo (iiPeriodYearTo), 
    input  iiPeriodPeriodTo (iiPeriodPeriodTo), 
    input  itDateFrom (itDateFrom), 
    input  itDateTo (itDateTo), 
    input  icDescription (icDescription), 
    input  icTargetJournalCode (icTargetJournalCode), 
    output viTransientLayerId (oiTransientLayerId), 
    output viJournalId (oiJournalId), 
    output viYearPeriodFrom (oiYearPeriodFrom), 
    output viYearPeriodTo (oiYearPeriodTo), 
    output viTargetJournalId (oiTargetJournalId), 
    output vcTargetJournalTypeCode (ocTargetJournalTypeCode), 
    output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper <  0 then return.

/* Find all of the YearPeriods from the range provided */
<Q-39 run PeriodByPeriodRange (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input viYearPeriodFrom, (FromYearPeriod)
    input viYearPeriodTo, (ToYearPeriod)
    output dataset tqPeriodByPeriodRange) in BPeriod>    

<Q-70 run LayerJournalForPosting  (Start) in BLayer>

/* copy result of the query to result dataset and assing new target journal */  
empty temp-table tMassLayerTransferJournalE.
            
for each tqPeriodByPeriodRange:
         
  <Q-62 run LayerJournalForPosting (all) (Read) (Cache)
     (input viCompanyId, (CompanyId)
      input itDateFrom, (DateFrom)
      input itDateTo, (DateTo)
      input icDescription, (Description)
      input viJournalId, (JournalId)
      input icTransientLayerCode, (LayerCode)
      input {&LAYERTYPECODE-TRANSIENT}, (LayerTypeCode)
      input tqPeriodByPeriodRange.tiPeriodYearPeriod, (PostingYearPeriod)
      input viTargetJournalId, (SkipJournalID)
      input vcTargetJournalTypeCode, (TargetJournalTypeCode)
      output dataset tqLayerJournalForPosting) in BLayer>
    
   
    for each tqLayerJournalForPosting:
        
        if tqLayerJournalForPosting.tlPostingIsAutoReversal and tqLayerJournalForPosting.tcPostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-REVERSING}
        then next.
        
        if tqLayerJournalForPosting.tiPostingTemplate_ID = 0 
        then do:
            create tMassLayerTransferJournalE.
            buffer-copy tqLayerJournalForPosting except tqLayerJournalForPosting.tcPostingAutoReversalType tqLayerJournalForPosting.tlPostingIsAutoReversal to tMassLayerTransferJournalE
            assign tMassLayerTransferJournalE.tiTargetJournalId   = viTargetJournalId
                   tMassLayerTransferJournalE.tcTargetJournalCode = icTargetJournalCode
                   tMassLayerTransferJournalE.tlIsProcessed       = no
                   tMassLayerTransferJournalE.tlIsSelect          = no.
        end.   
     
    end.

end.
/* return */
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 = "BMassLayerTransfer".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiGetJournalEntries".
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/bmasslayertransfer.apigetjournalentries.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icTransientLayerCode = <parameter value>
       vhParameter::icJournalCode = <parameter value>
       vhParameter::iiPeriodYearFrom = <parameter value>
       vhParameter::iiPeriodPeriodFrom = <parameter value>
       vhParameter::iiPeriodYearTo = <parameter value>
       vhParameter::iiPeriodPeriodTo = <parameter value>
       vhParameter::itDateFrom = <parameter value>
       vhParameter::itDateTo = <parameter value>
       vhParameter::icDescription = <parameter value>
       vhParameter::icTargetJournalCode = <parameter value>
       vhParameter::icActivityCode = <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.