Skip to Content
0
Jul 27, 2020 at 03:46 PM

CPI: BAI file: Convert a text file to XML using groovy script

505 Views Last edit Jul 27, 2020 at 03:48 PM 2 rev

Hi Guys,

I have a text fie from the bank which needs to be converted to complex type WSDL file and send to S4 HANA cloud via SOAP protocol. I checked many blogs and realized a CSV to XML converter can be used only for simple XML files. I believe a groovy script has to be used to convert the text file to WSDL. Has anybody else encountered a similar issue and if yes how did you resolve it?

Note: I have put a snippet of the XML and WSDL file to give an idea of how it would look like. Depending on the first two digits the values/fields that follow in that line varies.

Text file format:

01,BOFMCAM2,10000833,200611,1038,5,80,1,2/ 02,10000833,BOFMCAM2,1,200610,,USD,2/ 03,00014628973,USD,015,15789137,,,901,15789137,,, 88,010,15789137,,,030,15789137,,, 88,040,15789137,,,060,15789137,,, 88,066,15789137,,/ 49,110523959,5/ 03,00011240341,CAD,901,0,,,015,72520353,,, 88,010,-2907305,,,040,0,,, 88,100,75427658,9,V,200610,,066,0,,, 88,030,72520353,,,060,72520353,,/ 16,275,2907305,V,200609,,,/ 88,Zero Balance Credit 88,0001-1025-852 88,VIREMENT-TRESORERIE ZERO 16,195,152060,V,200610,,,/ 88,Incoming Wire Payment 88,RECEPTION D"UN PAIEMENT 88,CA, CONCUR TECHNOLOGIES I 16,142,9252963,V,200610,,,/ 88,Direct Deposit 88,GE LEBLANC MSP/DIV 16,142,344925,V,200610,,,/ 88,Direct Deposit 88,STC BPY/FAC 16,142,3042526,V,200610,,,/ 88,Direct Deposit

WSDL file:

-<xsd:complexType name="ElectronicBankStatementHeader"> -<xsd:sequence> <xsd:element type="xi0:BankNumber_GFN" name="BankNumber" minOccurs="0"/> <xsd:element type="xi0:BankCountry_GFN" name="BankCountry" minOccurs="0"/> <xsd:element type="xi0:SWIFTCode_GFN" name="SWIFTCode" minOccurs="0"/> <xsd:element type="xi0:BankAccountID" name="BankAccount" minOccurs="0"/> <xsd:element type="xi0:BankAccountHolderName" name="BankAccountHolderName" minOccurs="0"/> <xsd:element type="xi0:BankAccountAdditionalName_GFN" name="BankAccountAdditionalName" minOccurs="0"/> <xsd:element type="xi0:BankAccountType_GFN" name="BankAccountType" minOccurs="0"/> <xsd:element type="xi0:BankStatement_GFN" name="BankStatement" minOccurs="0"/> <xsd:element type="xi0:Date" name="BankStatementDate" minOccurs="0"/> <xsd:element type="xi0:Date" name="BankStatementPeriodStartDate" minOccurs="0"/> <xsd:element type="xi0:Date" name="BankStatementPeriodEndDate" minOccurs="0"/> <xsd:element type="xi0:CurrencyCode" name="Currency" minOccurs="0"/> <xsd:element type="xi0:Amount" name="OpeningBalAmtInBankAcctCrcy" minOccurs="0"/> <xsd:element type="xi0:Amount" name="TotalDebitAmtInBkAcctCrcy" minOccurs="0"/> <xsd:element type="xi0:Amount" name="TotalCreditAmtInBkAcctCrcy" minOccurs="0"/> <xsd:element type="xi0:Amount" name="ClsgBalAmtInBkAcctCrcy" minOccurs="0"/> <xsd:element type="xi0:BankStatementNumberOfItems_GFN" name="BankStatementNumberOfItems" minOccurs="0"/> <xsd:element type="xi0:SenderIBAN_GFN" name="SenderIBAN" minOccurs="0"/> </xsd:sequence> </xsd:complexType> -<xsd:complexType name="ElectronicBankStatementLineItems"> -<xsd:sequence> <xsd:element type="xi0:Date" name="BankPostingDate" minOccurs="0"/> <xsd:element type="xi0:Date" name="ValueDate" minOccurs="0"/> <xsd:element type="xi0:Time" name="ValueDateTime" minOccurs="0"/> <xsd:element type="xi0:Amount" name="AmountInBankAccountCurrency" minOccurs="0"/> <xsd:element type="xi0:Amount" name="FeeAmountInTransactionCrcy" minOccurs="0"/> <xsd:element type="xi0:CurrencyCode" name="OriginalCurrency" minOccurs="0"/> <xsd:element type="xi0:Amount" name="AmountInOriginalCurrency" minOccurs="0"/> <xsd:element type="xi0:Amount" name="FeeAmountInOriginalCrcy" minOccurs="0"/> <xsd:element type="xi0:PaymentTransactionText_GFN" name="PaymentTransactionCode" minOccurs="0"/> <xsd:element type="xi0:PartnerBankCountry_GFN" name="PartnerBankCountry" minOccurs="0"/> <xsd:element type="xi0:PartnerBank_GFN" name="PartnerBank" minOccurs="0"/> <xsd:element type="xi0:PartnerBankSWIFTCode_GFN" name="PartnerBankSWIFTCode" minOccurs="0"/> <xsd:element type="PartnerBankAccount" name="PartnerBankAccount" minOccurs="0"/> <xsd:element type="xi0:BusinessPartner_GFN" name="BusinessPartner" minOccurs="0"/> <xsd:element type="xi0:DaybookEntry_GFN" name="DaybookEntry" minOccurs="0"/> <xsd:element type="xi0:Check_GFN" name="Check" minOccurs="0"/> <xsd:element type="xi0:BankStatementItemDescription1_GFN" name="BankStatementItemDescription1" minOccurs="0"/> <xsd:element type="xi0:BankStatementItemDescription2_GFN" name="BankStatementItemDescription2" minOccurs="0"/> <xsd:element type="xi0:ExchangeRateRate" name="ExchangeRate" minOccurs="0"/> <xsd:element type="xi0:Amount" name="OverdueChargeAmtInBkAcctCrcy" minOccurs="0"/> <xsd:element type="xi0:PartnerBankIBAN_GFN" name="PartnerBankIBAN" minOccurs="0"/> <xsd:element type="xi0:NoteToPayeeInBankStatement_GFN" name="NoteToPayeeInBankStatement" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence>

Thanks in advance.