project QadFinancials > class BPaymentSelection > method ExportBEAbroadDetailLines

Description

This method is supposed to prepare and realize export of detail data in Belgium abroad format.


Parameters


itPayDateinputdate
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.ExportBEAbroad


program code (program7/bpaymentselection.p)

/* This method is supposed to be called only from      */
/* BPaymentSelection.ExportBEAbroad Method - therefore */
/* the references to the data definitions not defined  */
/* here are valid */

/* =================== */
/* Export Detail Lines */
/* =================== */
assign viLineCounter  = 0
       viLineCounter2 = 0
       viMonthCounter = 0.

for each tExpFields 
    break by tExpFields.tcCredCreditorCode
          by tExpFields.tcCredBankNumber
          by tExpFields.tcBankCurrencyCode:

    if first-of(tExpFields.tcCredCreditorCode) or
       first-of(tExpFields.tcBankCurrencyCode) or
       first-of(tExpFields.tcCredBankNumber)   
/* XS JirHol 21/01/2005 */
    or tExpFields.tlCredIsIndividualPayment
/* XE JirHol 21/01/2005 */
    then do:
        empty temp-table tBLWI.
/* XS JirHol 12/01/2005 */
    end.

    assign vdCreditorPayTot = 0.

    /* PTW 06/10/05 when you have a creditnote and creditnotecorrection, it doesn't work good
    for each btExpFields where
             btExpFields.tcCredCreditorCode         = tExpFields.tcCredCreditorCode         and
             btExpFields.tcCredBankNumber           = tExpFields.tcCredBankNumber           and
             btExpFields.tcCredBankNumberValidation = tExpFields.tcCredBankNumberValidation and
             btExpFields.tcCredBankNumberExtension  = tExpFields.tcCredBankNumberExtension  and
             btExpFields.tcBankCurrencyCode         = tExpFields.tcBankCurrencyCode:
         assign vdCreditorPayTot = vdCreditorPayTot + btExpFields.tdAmountLC01.
    end.
    */
    assign vdCreditorPayTot = vdCreditorPayTot + tExpFields.tdAmountLC01.

    if vdCreditorPayTot <= 0
    then next.

    assign viLineCounter  = viLineCounter + 1
           viMonthCounter = 11.

    /* ========================================================== */
    /* The creation of a 1-record starts identity 01              */
    /* ========================================================== */
    assign vcExpLine = '1':U + 
                       string(viLineCounter,'9999':U) +
                       '01':U +
                       string(day  (itPayDate),'99':U) +
                       string(month(itPayDate),'99':U) +
                       substring(string(year(itPayDate),'9999':U), 3, 2,"CHARACTER":U) +
                       string(trim(tExpFields.tcReference1),'x(16)':U).

    /* ========================================================== */
    /* Put the BLIW-code and the amount                           */
    /* ========================================================== */
    assign /*vdCreditorPayTot = 0
           vdCreditorPayTot = tExpFields.tdAmountLC01 * 100 */
           vdCreditorPayTot = vdCreditorPayTot * 100
           vcExpLine        = vcExpLine + string(tExpFields.tcBankCurrencyCode,'x(4)':U)
                                        + string(tExpFields.tcBankGroup5,'x':U)
                                        + string(vdCreditorPayTot,'999999999999999':U).

    accumulate vdCreditorPayTot (TOTAL).
    
    /* ========================================================== */
    /* Put the account number of the company                      */
    /* ========================================================== */
    assign vcExpLine      = vcExpLine 
                            + ' ':U
                            + (if tExpFields.tcBankGroup5 = 'D':U
                               then string(tqBankNumberByParentID.tcCurrencyCode,'x(3)':U)
                               else fill (' ':U,3))
                            + fill (' ':U,6)
                            + string(tqBankNumberByParentID.tcBankNumber,'999999999999':U)
                            + fill (' ':U,57)
           viLineCounter2 = viLineCounter2 + 1.

    /* ========================================================== */
    /* Write the record to the file                               */
    /* ========================================================== */
    put stream sExpStream unformatted vcExpLine skip.
    
    /* ========================================================== */
    /* Part 02 of the 1-records containing the company adres      */
    /* ========================================================== */
    assign vcExpLine      = '1':U 
                           + string(viLineCounter,'9999':U)
                           + '02':U
                           + string(caps(tqCompanyPropertyByBusinessRel.tcBusinessRelationCode),'x(35)':U)
                           + string(caps(tqCompanyPropertyByBusinessRel.tcAddressStreet1),'x(35)':U)
                           + string(caps(tqCompanyPropertyByBusinessRel.tcAddressZip),'9999':U)
                           + ' ':U
                           + string(caps(tqCompanyPropertyByBusinessRel.tcAddressCity),'x(30)':U)
                           + fill (' ':U,16)
           viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.
    
    /* ========================================================== */
    /* Part 03 of the 1-records containing the company adres      */
    /* ========================================================== */
    assign vcExpLine = '1':U
                       + string(viLineCounter,'9999':U)
                       + '03':U
                       + string(caps(tqCompanyPropertyByBusinessRel.tcCountryDescription),'x(35)':U)
                       + fill(' ':U,10).
        
    if tqBankNumberByParentID.tcBankNumberSwiftCode <> ' ':U and
       tqBankNumberByParentID.tcBankNumberSwiftCode <> ?
    then assign vcExpLine = vcExpLine +
                             string(caps(tqBankNumberByParentID.tcBankNumberSwiftCode),'x(11)':U) +
                             fill(' ':U,65).
    else assign vcExpLine = vcExpLine + fill(' ':U,76).
    
    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.
    
    /* ========================================================== */
    /* Part 04 of the 1-records left blanko                       */
    /* ========================================================== */
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '04':U
                       + fill(' ':U,80).
    
    if tExpFields.tcCredBankSwift <> '':U and
       tExpFields.tcCredBankSwift <> ?
    then assign vcExpLine = vcExpLine +
                            string(caps(tExpFields.tcCredBankSwift),'x(11)':U) +
                            fill(' ':U,24) +
                            '1':U +
                            fill(' ':U,5).
    else if tExpFields.tcCredBankBusRelationCode <> '':U and
            tExpFields.tcCredBankBusRelationCode <> ?
         then assign vcExpLine = vcExpLine +
                                 string(caps(tExpFields.tcCredBankBusRelationCode),'x(35)':U) +
                                 '2':U +
                                 fill(' ':U,5).
         else assign vcExpLine = vcExpLine + fill(' ':U,41).

    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.
        
    /* ========================================================== */
    /* Part 05 of the 1-records                                   */
    /* ========================================================== */
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '05':U.
    
    if tExpFields.tcCredBankSwift <> '':U and
       tExpFields.tcCredBankSwift <> ?
    then assign vcExpLine = vcExpLine + fill(' ':U,121).
    else if tExpFields.tcCredBankBusRelationCode <> '':U and
            tExpFields.tcCredBankBusRelationCode <> ?
         then assign vcExpLine = vcExpLine
                                 + string(caps(tExpFields.tcCredBankAddressStreet1),'x(35)':U)
                                 + fill (' ':U,35)
                                 + '*':U
                                 + string(caps(tExpFields.tcCredBankAddressCountry),'x(3)':U)
                                 + ' ':U
                                 + string(caps(tExpFields.tcCredBankAddressZip),'x(6)':U)
                                 + string(caps(tExpFields.tcCredBankAddressCity),'x(24)':U)
                                 + fill (' ':U,10)
                                 + fill (' ':U,6).
         else assign vcExpLine = vcExpLine
                                 + fill (' ':U,115)
                                 + fill (' ':U,6).
    
    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.         

    /* ========================================================== */
    /* Part 06 of the 1-records                                   */
    /* ========================================================== */
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '06':U.

    if tExpFields.tcCredBankNumberValidation = {&BANKNUMBERVALIDATION-IBAN} 
    then assign vcExpLine = vcExpLine +
                            string (tExpFields.tcCredBankNumber,'x(34)':U).
    else if tExpFields.tcCredAddressCountry <> ' ':U and
            tExpFields.tcCredAddressCountry <> ?     and
            tExpFields.tcCredBankAddressCountry = 'DE':U
         then assign vcExpLine = vcExpLine +
                                 string(tExpFields.tcCredBankAddressCountry,'x(2)':U) +
                                 ' ':U +
                                 string(tExpFields.tcCredBankNumberExtension,'x(8)':U) +
                                 ' ':U +
                                 string(tExpFields.tcCredBankNumber,'x(22)':U).
         else if tExpFields.tcCredAddressCountry <> ' ':U and
                 tExpFields.tcCredAddressCountry <> ?     and
                 tExpFields.tcCredBankAddressCountry = 'BE':U
              then assign vcExpLine = vcExpLine +
                                      ' ':U +
                                     (if tExpFields.tcBankCurrencyCode <> tExpFields.tcCurrencyCodePay
                                      then string(tExpFields.tcBankCurrencyCode,'x(3)':U)
                                      else fill(' ':U,3)) +
                                      fill (' ':U,6) +
                                      string(tExpFields.tcCredBankNumber,'x(12)':U) +
                                      fill (' ':U,12).
              else assign vcExpLine = vcExpLine +
                                      string(tExpFields.tcCredBankNumber,'x(34)':U).
                             
    assign vcExpLine = vcExpLine +
                       string(caps(tExpFields.tcCredBusRelationCode),'x(35)':U) +
                       string(caps(tExpFields.tcCredAddressStreet1),'x(35)':U).

    if tExpFields.tcCredBankNumberValidation = {&BANKNUMBERVALIDATION-IBAN}
    then assign vcExpLine = vcExpLine + '1':U.
    else if tExpFields.tcCredAddressCountry <> ' ':U and
            tExpFields.tcCredAddressCountry <> ?     and
            tExpFields.tcCredBankAddressCountry = 'BE':U
         then assign vcExpLine = vcExpLine + '2':U.
         else assign vcExpLine = vcExpLine + ' ':U.

    if tExpFields.tcCredAddressCountry <> ' ':U
    then assign vcExpLine = vcExpLine +
                            string(tExpFields.tcCredAddressCountry,'x(2)':U) +
                            fill(' ':U,14).
    else assign vcExpLine = vcExpLine + fill(' ':U,16).

    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.         

    /* ========================================================== */
    /* Part 07 of the 1-records with the data of the creditor     */
    /* ========================================================== */
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '07':U
                       + string(caps(tExpFields.tcCredAddressZip),'x(8)':U)
                       + ' ':U
                       + string(caps(tExpFields.tcCredAddressCity),'x(26)':U)
                       + string(caps(tExpFields.tcCredAddressCountry),'x(35)':U)
                       + fill(' ':U,10).

    /* ========================================================== */
    /* Add the reference part1  to the file  (record 07)          */
    /* and at the same time fill up part2 for record 08           */
    /* ========================================================== */
    assign viLength = length(tExpFields.tcReference1,"CHARACTER":U).
    assign vcExpLine = vcExpLine + trim(tExpFields.tcReference1)
                       + fill (' ':U,41 - viLength).
                       
    /* ========================================================== */
    /* Put the record into the file                               */
    /* ========================================================== */
    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.

    /* ========================================================== */
    /* Part 08 of the 1-records left blanko                       */
    /* ========================================================== */
    assign viLength = length(tExpFields.tcReference2,"CHARACTER":U).
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '08':U 
                       + tExpFields.tcReference2
                       + fill (' ':U, 121 - viLength).
    
    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.
    
    /* ========================================================== */
    /* Part 09 of the 1-records left blanko                       */
    /* ========================================================== */
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '09':U
                       + fill (' ':U,121).
    
    assign viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.

    /* ========================================================== */
    /* Part 10 of the 1-records containing the groupcodes         */
    /* ========================================================== */
    assign vcExpLine = '1':U 
                       + string(viLineCounter,'9999':U)
                       + '10':U
                       + fill (' ':U,35).
    
    if tExpFields.tcBankGroup3 = '///':U
    then assign vcExpLine = vcExpLine + fill(' ':U,3).
    else assign vcExpLine = vcExpLine + string(tExpFields.tcBankGroup3,'xxx':U).
    
    assign vcExpLine      = vcExpLine
                           + string(tExpFields.tcBankGroup2,'xxx':U)
                           + fill(' ':U,10)
                           + fill('0':U,12)
                           + ' ':U
                           + string(tExpFields.tcBankGroup6,'xx':U)
                           + fill (' ':U,55).
           viLineCounter2 = viLineCounter2 + 1.
    put stream sExpStream unformatted vcExpLine skip.

    /* ========================================================== */
    /* Part 11 of the 1-records containing the amounts            */
    /* ========================================================== */
    find tBLWI where
         tBLWI.tcBLWI = tExpFields.tcBankGroup1
         no-error.
    if not available tBLWI
    then do:
        <Q-3 run PayFormatGroupPrim (all) (Read) (NoCache)
          (input ?, (PayFormatGroupID)
           input {&PAYMENTFORMAT-BE2}, (PayFormatTypeCode)
           input 1, (PayFormatGroupSequence)
           output dataset tqPayFormatGroupPrim) in BPaymentFormat >
        find first tqPayFormatGroupPrim no-error.
        if not available tqPayFormatGroupPrim
        then do:
            <M-5 run SetMessage
          (input  #T-7'The payment format group 1 for payment format $1 is not defined in the system.':80(2977)t-7# (icMessage), 
           input  {&PAYMENTFORMAT-BE2} (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'D':U (icType), 
           input  3 (iiSeverity), 
           input  ? (icRowid), 
           input  'QADFIN-1238':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            assign oiReturnStatus = -1.        
            return.
        end.
        
        <Q-4 run PayFormatCodebyGroupID (all) (Read) (NoCache)
          (input ?, (PayFormatCodeID)
           input tExpFields.tcBankGroup1, (PayFormatCode)
           input tqPayFormatGroupPrim.tiPayFormatGroup_ID, (PayFormatGroupID)
           output dataset tqPayFormatCodebyGroupID) in BPaymentFormat >
        find first tqPayFormatCodebyGroupID no-error.
        if not available tqPayFormatCodebyGroupID
        then do:
            <M-6 run SetMessage
          (input  #T-8'The payment format code $1 for group 1 of payment format $2 is not defined in the system.':80(2978)t-8# (icMessage), 
           input  tExpFields.tcBankGroup1 + chr(2) + {&PAYMENTFORMAT-BE2} (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'D':U (icType), 
           input  3 (iiSeverity), 
           input  ? (icRowid), 
           input  'QADFIN-1239':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            assign oiReturnStatus = -1.        
            return.
        end.
        
        create tBLWI.
        assign tBLWI.tcBLWI        = tqPayFormatCodebyGroupID.tcPayFormatCode
               tBLWI.tcDescription = tqPayFormatCodebyGroupID.tcPayFormatCodeDescription.
    end.
    
    assign tBLWI.tdPayAmount   = tBLWI.tdPayAmount + /*tExpFields.tdAmountLC01.    */ vdCreditorPayTot.

    if last-of(tExpFields.tcCredCreditorCode) or
       last-of(tExpFields.tcBankCurrencyCode) or
       last-of(tExpFields.tcCredBankNumber)
/* XS JirHol 21/01/2005 */
    or tExpFields.tlCredIsIndividualPayment
/* XE JirHol 21/01/2005 */
    then for each tBLWI:
        assign vcExpLine      = '1':U
                               + string(viLineCounter,'9999':U) 
                               + string(viMonthCounter,'99':U)
                               + string(tBLWI.tcBLWI,'xxx':U)
                               + string(tBLWI.tdPayAmount * 100,'999999999999999':U)
                               + fill(' ':U,6)
                               + substring(caps(tBLWI.tcDescription),1,49,"CHARACTER":U)
                               + fill(' ':U,48)
               viLineCounter2 = viLineCounter2 + 1.
        put stream sExpStream unformatted vcExpLine skip.
        assign viMonthCounter = viMonthCounter + 1.
    end.
end.

/* ========================================================== */
/* 9-record being the end record                              */
/* ========================================================== */
assign vcExpLine = '9':U 
                   + string(viLineCounter2,'999999':U)
                   + string(viLineCounter,'999999':U)
                   + string((accum total vdCreditorPayTot),'999999999999999':U)
                   + fill (' ':U,100).
put stream sExpStream unformatted vcExpLine skip.

/* ==================== */
/* Close the stream     */
/* ==================== */
output stream sExpStream close.