Look Fantastic PT 728X90

Call of Duty: Mobile

SEPA XML CODE - EN

C2B - Provision of Services Customer Registration Normalized (XML) SEPA


The creation of the SEPA (Single Euro Payments Area - Single Area Payments in euros) allowed the strengthening of European integration and the establishment of a single retail payment market. Currently, SEPA covers, in addition to EU Member States, Iceland, Liechtenstein, Monaco, Norway, San Marino and Switzerland. In this space, economic agents can make and receive payments in euro, within countries and between countries, under the same conditions, rights and obligations.
In achieving this goal, SEPA offers pan-European payment instruments, such as credit transfers (SCT) and Direct Debits (SEPA DD), whose operation is based on standards, procedures and, as far as possible, common infrastructure to all participants .
The technical and business models are defined by the European Payments Council (EPC), in the rulebooks and the respective Implementation Guidelines (available in www.europeanpaymentscouncil.eu). These models are based on the technical specifications of the ISO20022 standard and are designed to ensure an automated processing credit transfers and collections.
It is up to banks the responsibility to implement a Customer-to-Bank channel (C2B) compatible with SEPA, following standard messages for use of EPC recommendations of XML ISO20022 standard set out in the SEPA C2B Implementation Guidelines and offer its customers the layout file to use.
In this framework, to facilitate the connection between the client and the bank, the Portuguese banking community has developed a harmonized reporting format applicable to the SEPA Credit Transfer and SEPA Direct Debits to. This document describes this pattern, for use in customer relationship - Bank by the member institutions of the national banking community.
The use of a harmonized layout has clear benefits for C2B communication (especially for businesses and public administration bodies), is proposing to: (i) remedy the multitude of formats used by customers in their relationship with banks for initiation payment instructions; and (ii) provide companies and public administration bodies efficient and advantageous communication solution in terms of cost.


Since the relative documentation and structure of the XML file, we can move forward with the solution implemented for the payment of salaries of employees in the company where the date of today's meeting me to provide services.
Going from the beginning that we have a table with all the data from company employees. We'll have to add two more (2) fields, which are IBAN and BIC (Swift) the employee's account.
In my case all programmed in a report to which I named "File Bank", it has a "Request Page" with the following drawing.

MS NAV 2009 R2 - Report 60003 Ficheiro Banco

In the report of the design have a DataItem to the table where the stored ordered processing of data, open the code editor C / AL and scheduled the following instructions:

Pagamento Remuneracoes3 - OnPreDataItem()

IF vCartao THEN
  CurrReport.SKIP;
IF ((Filetype = Filetype::"0")OR(Filetype = Filetype::PS2)OR(Bank = '')) THEN
  CurrReport.SKIP;

Mov   :=48; // Numero da linha onde iniciam os pagamentos
Contar:=0;  // Total empregados processados
Total :=0;  // Total EUR Processado
IF DataLanc=0D THEN BEGIN;
  MESSAGE(Text60400);
  CurrReport.QUIT;
END;

Window.OPEN('#1#################################\\'+'Nº empregado               #2######\');
CompanyInfo.GET;
vDia:=FORMAT(DATE2DMY(DataLanc,1),0,'<Precision,0:0><Standard Format,1>');
vMês:=FORMAT(DATE2DMY(DataLanc,2),0,'<Precision,0:0><Standard Format,1>');
IF STRLEN(vDia)=1 THEN vDia:='0'+vDia;
IF STRLEN(vMês)=1 THEN vMês:='0'+vMês;
vAno:=FORMAT(DATE2DMY(DataLanc,3),0,'<Precision,0:0><Standard Format,1>');
IF DataLanc = TODAY THEN
  vTime := COPYSTR(FORMAT(TIME),1,8)
ELSE
  vTime := '08:00:00';

vDate := vAno+'-'+vMês+'-'+vDia+'T'+vTime;
//vDate := DELCHR(FORMAT(vDate),'=',' ');
vDate := CONVERTSTR(vDate,' ','0');
CLEAR(xmldoc);
CLEAR(xmlnode);
CLEAR(xmlnode2);
CLEAR(newnode);
PmtInfId := '';

CREATE(xmldoc,TRUE);

xmldoc.loadXML('<?xml version="1.0" encoding="UTF-8"?><Document></Document>');
xmlnode := xmldoc.documentElement;
AddAttribute(xmlnode,'xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
AddAttribute(xmlnode,'xmlns','urn:iso:std:iso:20022:tech:xsd:pain.001.001.03');

newnode    := xmldoc.createNode(1,'CstmrCdtTrfInitn','');
xmlnode.appendChild(newnode);
xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn');

newnode    := xmldoc.createNode(1,'GrpHdr','');
xmlnode2.appendChild(newnode);
  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr');
    newnode    := xmldoc.createNode(1,'MsgId','');
    newnode.text := 'Grupel-'+vDate;
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'CreDtTm','');
    newnode.text := vDate;
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'NbOfTxs','');
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'CtrlSum','');
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'InitgPty','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr/InitgPty');
      newnode    := xmldoc.createNode(1,'Nm','');
      newnode.text := CompanyInfo.Name;
      xmlnode2.appendChild(newnode);
      newnode    := xmldoc.createNode(1,'Id','');
      //newnode.text := CompanyInfo.Name;
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr/InitgPty/Id');
        newnode    := xmldoc.createNode(1,'PrvtId','');
        xmlnode2.appendChild(newnode);
        xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr/InitgPty/Id/PrvtId');
          newnode    := xmldoc.createNode(1,'Othr','');
          xmlnode2.appendChild(newnode);
          xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr/InitgPty/Id/PrvtId/Othr');
            newnode    := xmldoc.createNode(1,'Id','');
            newnode.text := '46082810001';
            xmlnode2.appendChild(newnode);


xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn');
newnode    := xmldoc.createNode(1,'PmtInf','');
xmlnode2.appendChild(newnode);
  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf');
    newnode    := xmldoc.createNode(1,'PmtInfId','');
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'PmtMtd','');
    newnode.text := 'TRF';
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'NbOfTxs','');
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'CtrlSum','');
    xmlnode2.appendChild(newnode);
    newnode    := xmldoc.createNode(1,'PmtTpInf','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/PmtTpInf');
      newnode    := xmldoc.createNode(1,'CtgyPurp','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/PmtTpInf/CtgyPurp');
        newnode    := xmldoc.createNode(1,'Cd','');
        newnode.text := 'SUPP';
        xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf');
      newnode    := xmldoc.createNode(1,'ReqdExctnDt','');
      newnode.text := vAno+'-'+vMês+'-'+vDia;
      xmlnode2.appendChild(newnode);
      newnode    := xmldoc.createNode(1,'Dbtr','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/Dbtr');
        newnode    := xmldoc.createNode(1,'Nm','');
        newnode.text := CompanyInfo.Name;
        xmlnode2.appendChild(newnode);
        newnode    := xmldoc.createNode(1,'PstlAdr','');
        xmlnode2.appendChild(newnode);
        xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/Dbtr/PstlAdr');
        newnode    := xmldoc.createNode(1,'Ctry','');
        newnode.text := 'PT';
        xmlnode2.appendChild(newnode);
        newnode    := xmldoc.createNode(1,'AdrLine','');
        newnode.text := CompanyInfo.Address+', '+CompanyInfo."Post Code"+' '+CompanyInfo.County+
        ', '+CompanyInfo.City;
        xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf');
      newnode    := xmldoc.createNode(1,'DbtrAcct','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/DbtrAcct');
        newnode    := xmldoc.createNode(1,'Id','');
        xmlnode2.appendChild(newnode);
        xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/DbtrAcct/Id');
          newnode    := xmldoc.createNode(1,'IBAN','');
          newnode.text := IBANEmpresa;
          xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf');
      newnode    := xmldoc.createNode(1,'DbtrAgt','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/DbtrAgt');
        newnode    := xmldoc.createNode(1,'FinInstnId','');
        xmlnode2.appendChild(newnode);
        xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/DbtrAgt/FinInstnId');
          newnode    := xmldoc.createNode(1,'BIC','');
          newnode.text := SWIFTEmpresa;
          xmlnode2.appendChild(newnode);

Pagamento Remuneracoes3 - OnAfterGetRecord()

IF vCartao THEN
  CurrReport.SKIP;
IF ((Filetype = Filetype::"0")OR(Filetype = Filetype::PS2)OR(Bank = '')) THEN
  CurrReport.SKIP;

Window.UPDATE(1,'');
Window.UPDATE(2,'');

Window.UPDATE(1,"Empregado Descr");
Window.UPDATE(2,"Cod Empregado");

IF NOT ("Processar para Ficheiro Transf") THEN BEGIN
  CurrReport.SKIP;
END;
IF PmtInfId = '' THEN
  PmtInfId := "No. Processamento";

CLEAR(escravo);
escravo.GET("Cod Empregado");
xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf');
newnode    := xmldoc.createNode(1,'CdtTrfTxInf','');
xmlnode2.appendChild(newnode);
AddAttribute(newnode,'ID',FORMAT(Contar));
  root := '[@ID = "'+FORMAT(Contar)+'"]';
  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root);
  newnode    := xmldoc.createNode(1,'PmtId','');
  xmlnode2.appendChild(newnode);
  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/PmtId');
    newnode    := xmldoc.createNode(1,'EndToEndId','');
    newnode.text := "No. Processamento";
    xmlnode2.appendChild(newnode);

  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root);
    newnode    := xmldoc.createNode(1,'Amt','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/Amt');
      newnode    := xmldoc.createNode(1,'InstdAmt','');
      newnode.text := CONVERTSTR(DELCHR(DELCHR(FORMAT("Valor Bruto Total"),'=',' '),'=','.'),',','.');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/Amt/InstdAmt');
      AddAttribute(xmlnode2,'Ccy','EUR');

  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root);
    newnode    := xmldoc.createNode(1,'CdtrAgt','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/CdtrAgt');
      newnode    := xmldoc.createNode(1,'FinInstnId','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/CdtrAgt/FinInstnId');
        newnode    := xmldoc.createNode(1,'BIC','');
        newnode.text := escravo."Swift Banco";
        xmlnode2.appendChild(newnode);

  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root);
    newnode    := xmldoc.createNode(1,'Cdtr','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/Cdtr');
      newnode    := xmldoc.createNode(1,'Nm','');
      newnode.text := "Empregado Descr";
      xmlnode2.appendChild(newnode);
      newnode    := xmldoc.createNode(1,'PstlAdr','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/Cdtr/PstlAdr');
        newnode    := xmldoc.createNode(1,'Ctry','');
        IF escravo."Country/Region Code" <> '' THEN
          newnode.text := escravo."Country/Region Code";
        IF escravo."Country/Region Code" = '' THEN
          newnode.text := 'PT';
        xmlnode2.appendChild(newnode);
       newnode    := xmldoc.createNode(1,'AdrLine','');
        newnode.text := escravo.Address;
        xmlnode2.appendChild(newnode);
        newnode    := xmldoc.createNode(1,'AdrLine','');
        newnode.text := escravo."Post Code"+' '+escravo.County+', '+escravo.City+' '+escravo."Country/Region Code";
        xmlnode2.appendChild(newnode);


  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root);
    newnode    := xmldoc.createNode(1,'CdtrAcct','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/CdtrAcct');
      newnode    := xmldoc.createNode(1,'Id','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/CdtrAcct/Id');
        newnode    := xmldoc.createNode(1,'IBAN','');
        newnode.text := escravo."IBAN Banco";
        xmlnode2.appendChild(newnode);

  xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root);
    newnode    := xmldoc.createNode(1,'RmtInf','');
    xmlnode2.appendChild(newnode);
    xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/RmtInf');
      newnode    := xmldoc.createNode(1,'Strd','');
      xmlnode2.appendChild(newnode);
      xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/RmtInf/Strd');
        newnode    := xmldoc.createNode(1,'CdtrRefInf','');
        xmlnode2.appendChild(newnode);
        xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/RmtInf/Strd/CdtrRefInf');
          newnode    := xmldoc.createNode(1,'Tp','');
          xmlnode2.appendChild(newnode);
         xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/RmtInf/Strd/CdtrRefInf/Tp');
            newnode    := xmldoc.createNode(1,'CdOrPrtry','');
            xmlnode2.appendChild(newnode);
            xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root
            +'/RmtInf/Strd/CdtrRefInf/Tp/'+'CdOrPrtry');
              newnode    := xmldoc.createNode(1,'Cd','');
              newnode.text := 'SCOR';
              xmlnode2.appendChild(newnode);
         xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/RmtInf/Strd/CdtrRefInf/Tp');
            newnode    := xmldoc.createNode(1,'Issr','');
            newnode.text := COPYSTR("Empregado Descr",1,34);
            xmlnode2.appendChild(newnode);
        xmlnode2   := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf'+root+'/RmtInf/Strd/CdtrRefInf');
          newnode    := xmldoc.createNode(1,'Ref','');
          newnode.text := "No. Processamento";
          xmlnode2.appendChild(newnode);
Mov   := Mov+1;
Contar:= Contar+1;
Total += "Valor Bruto Total";

Pagamento Remuneracoes3 - OnPostDataItem()


IF vCartao THEN
  CurrReport.SKIP;
IF ((Filetype = Filetype::"0")OR(Filetype = Filetype::PS2)OR(Bank = '')) THEN
  CurrReport.SKIP;

xmlnode2      := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr/NbOfTxs');
xmlnode2.text := FORMAT(Contar);
xmlnode2      := xmlnode.selectSingleNode('CstmrCdtTrfInitn/GrpHdr/CtrlSum');
xmlnode2.text := CONVERTSTR(DELCHR(DELCHR(FORMAT(Total),'=',' '),'=','.'),',','.');
xmlnode2      := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/PmtInfId');
xmlnode2.text := PmtInfId;
xmlnode2      := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/NbOfTxs');
xmlnode2.text := FORMAT(Contar);
xmlnode2      := xmlnode.selectSingleNode('CstmrCdtTrfInitn/PmtInf/CtrlSum');
xmlnode2.text := CONVERTSTR(DELCHR(DELCHR(FORMAT(Total),'=',' '),'=','.'),',','.');

Window.CLOSE;
MESSAGE('Foram criadas %1 linha(s) de movimento',Contar);
xmldoc.save('c:\temp\001-001-03-'+CompanyInfo.Name+'('+vAno+'-'+vMês+'-'+vDia+')'+'.xml');
ToFile := '001-001-03-'+CompanyInfo.Name+'('+vAno+'-'+vMês+'-'+vDia+')'+'.xml';

xmlread('c:\temp\001-001-03-'+CompanyInfo.Name+'('+vAno+'-'+vMês+'-'+vDia+')'+'.xml');

DOWNLOAD('c:\temp\001-001-03-'+CompanyInfo.Name+'('+vAno+'-'+vMês+'-'+vDia+')'+'.xml',Text014,'%temp%',Text015,ToFile);
CLEARALL;

AddAttribute(VAR XMLAttNode : Automation "'Microsoft XML, v6.0'.IXMLDOMNode";AttributeName : Text[180];AttributeValue : Text[180])

NewAttributeNode := XMLAttNode.ownerDocument.createAttribute(AttributeName);
IF AttributeValue <> '' THEN BEGIN
  NewAttributeNode.value := AttributeValue;
  XMLAttNode.attributes.setNamedItem(NewAttributeNode);
END;

xmlread(ficheiro : Text[250])

ffile.OPEN(ficheiro);
ffile.CREATEINSTREAM(strInStream);

IF ISCLEAR(xmldomDoc) THEN CREATE(xmldomDoc);

xmldomDoc.load(strInStream);

xmldomDoc.getElementsByTagName('CstmrCdtTrfInitn').item(0).attributes.removeNamedItem('xmlns');

xmlNodeList  := xmldomDoc.getElementsByTagName('CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf');

FOR i:=0 TO xmlNodeList.length()-1 DO BEGIN
  xmlNodeList.item(i).attributes.removeNamedItem('ID');
END;

ffile.CLOSE;
xmldomDoc.save(ficheiro);

Comentarios

Publicar un comentario

Entradas populares