× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Birgitta,

SQL may be efficient to create a simple, no a very simple XML document, but
if
you are in the business of transferring business documents you either has
to code
a lot of business logic and create a lot of inhouse files before and that
is double double
work.

To give you an example of how complex the code can be I include a sample
program
creating a danish public invoice


On Tue, May 22, 2012 at 5:08 PM, Birgitta Hauser <Hauser@xxxxxxxxxxxxxxx>wrote:

If you are already on Release 7.1 you can use the SQL XML Publishing
Functions in composition with embedded SQL to write directly into the IFS:
Example:

D MyXMLDoc S SQLTYPE(XML_CLOB_File)
D
//**********************************************************************
C/Exec SQL Set Option Commit=*None, DatFmt=*ISO, TimFmt=*ISO,
C+ Naming=*SYS, CloSQLCsr=*EndActGrp
C/End-Exec
/FREE
Clear MyXMLDoc;
MyXMLDoc_Name = '/home/Hauser/MyXMLDoc.xml';
MyXMLDoc_NL = %Len(%Trim(MyXMLDoc_Name));
MyXMLDoc_FO = SQFOVR; //Replace if exists

Exec SQL
Select XmlDocument
(xmlgroup(EmployeeNo as "PersNo",
Trim(Trim (FirstName) concat ' ' concat
Trim(Name)) as "PersName",
Address as "Street",
ZipCode as "ZipCode",
City as "City"
Order By City Desc, Name
Option Row "Employee"
Root "Staff"))
into :MyXMLDoc
From LobStaff;


*InLR = *On;
/END-FREE

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"


-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
Im
Auftrag von Amanda Paul
Gesendet: Tuesday, 22. May 2012 15:39
An: rpg400-l@xxxxxxxxxxxx
Betreff:


What are the different ways of composing an xml document Using RPG, any
examples ?

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




/EJECT
*=====================================================================

* Hoveddokument
* =============

*=====================================================================
/free
begsr XML_file;

/end-free

* Hent Dags dato

c* eval ÅDateIso = ÅDateYmd Sumpost dato
c* move ÅDateIso ÅDatetext

* Hent faktura-header

c headkey chain stahdrf 80

* Hent firma-header

c shsufx chain l9sfxmf 80

* Hent kundeoplysninger
c IF Shdebn <> 0
c EVAL Betkun = Shdebn
c ELSE
c EVAL Betkun = Shkunn
C ENDIF

c z-add shkunn kunkey
c kunkey chain dmreg 80
c** kunkey chain kunopl13 80

* Hent betalingsmåde

c dmgfid chain gfreg 80

* Hent kommunikationsoplysninger

c dlkey chain dlreg 80

* Hent rentesatser

c dmgmid chain gmreg 80

* Hent fakturaoplysninger

c Oio4key chain stao04 80

* Calculate Modulus 10 checkciffer (Result in ÅMO10M)
c* eval Åmo10n = dmdmno
c eval Åmo10n = betkun
c exsr Åmod10

* Faktura eller kreditnota

c if shfakt >= 0
c eval xmltype = 'F'
c else
c eval xmltype = 'K'
c endif

* Vend Headerbeløb ved Kreditnota
c if xmltype = 'K'
c z-sub shfakt shfakt
c z-sub shordp shordp
c z-sub shafgt shafgt
c z-sub shfkkr shfkkr
c z-sub shmogr shmogr
c z-sub shmokr shmokr
c endif

c z-add shmoms xxmoms
/free

echo('<?xml version="1.0" encoding="UTF-8"?>');

xmlNode('Invoice'
:'xsi:schemaLocation="'+ 'urn:oasis:names:specification:ubl:schema:'
+'xsd:Invoice-2 UBL-Invoice-2.0.xsd' +'" ' + nl() + x'0505'
+'xmlns:xsi="'+ 'http://www.w3.org/2001/XMLSchema-instance' +'" '
+ nl() + x'0505'
+'xmlns="'+ 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'
+'" ' + nl() + x'0505'
+'xmlns:cac="'+ 'urn:oasis:names:specification:ubl:schema:xsd:'
+ 'CommonAggregateComponents-2' + '" ' + nl + x'0505'
+'xmlns:cbc="'+ 'urn:oasis:names:specification:ubl:schema:xsd:'
+'CommonBasicComponents-2' +'" ' + nl() + x'0505'
+'xmlns:ccts="'+ 'urn:oasis:names:specification:ubl:schema:xsd:'
+'CoreComponentParameters-2' + '" ' + nl() + x'0505'
+'xmlns:sdt="'+ 'urn:oasis:names:specification:ubl:schema:xsd:'
+'SpecializedDatatypes-2' +'" ' + nl() + x'0505'
+'xmlns:udt="'+ 'urn:un:unece:uncefact:data:specification:'
+'UnqualifiedDataTypesSchemaModule:2' +'" '
);
echo('');
xmlNode('cbc:UBLVersionID':'':'2.0');
xmlNode('cbc:CustomizationID':'':'OIOUBL-2.02');
xmlNode('cbc:ProfileID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:profileid-1.2' +'" '
:'urn:www.nesubl.eu:profiles:profile5:ver2.0'
);

// Header
xmlNode('cbc:ID':'':%char(pafakn));
xmlNode('cbc:CopyIndicator':'':'false');
xmlNode('cbc:IssueDate':'':isoFromNum(padato:'*YMD':'8'));
xmlNode('cbc:InvoiceTypeCode'
:'listAgencyID="'+ '320' +'" '
+'listID="'+ 'urn:oioubl:codelist:invoicetypecode-1.1' +'" '
:'380'
);
xmlNode('cbc:DocumentCurrencyCode':'':'DKK');
xmlNode('cbc:AccountingCost':'':'.');

exsr OrderReference;
exsr AccountingSupplierParty;
exsr AccountingCustomerParty;
exsr BuyerCustomerParty;
exsr Delivery;
exsr PaymentMeans;
exsr PaymentTerms;
exsr afgtot;
exsr TaxTotal;
exsr LegalMonetaryTotal;
exsr InvoiceLine;

echo('');
xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr OrderReference;

echo('');
xmlNode('cac:OrderReference');

if shref = *blanks;
xmlNode('cbc:ID':'':'.');
else;
xmlNode('cbc:ID':'':shref);
endif;
xmlNode('cbc:SalesOrderID':'':%trim(%editc(shordn : 'X')));
xmlNode('cbc:IssueDate':'':isoFromNum(shfakd:'*YMD':'8'));

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr AccountingSupplierParty;

echo('');
xmlNode('cac:AccountingSupplierParty');

xmlNode('cac:Party');
// xmlNode('cbc:EndpointID'
// :'schemeID="'+ 'DK:CVR' +'" '
// :'DK73648718'
// );
xmlNode('cbc:EndpointID'
// :'schemeAgencyID="'+ '9' +'" '
:'schemeID="'+ 'GLN' +'" '
// :'5790001267278'
:%trim(%editc(l9ean : '4'))
);
xmlNode('cac:PartyIdentification');
xmlNode('cbc:ID'
:'schemeID="'+ 'DK:CVR' +'" '
:'DK' + %trim(%editc(l9cvr : '4'))
);
xmlEndNode('cac:PartyIdentification');
xmlNode('cac:PartyName');
xmlNode('cbc:Name':'':l9adr1);
xmlEndNode('cac:PartyName');
xmlNode('cac:PostalAddress');
xmlNode('cbc:AddressFormatCode'
:'listAgencyID="'+ '320' +'" '
+'listID="'+ 'urn:oioubl:codelist:addressformatcode-1.1' +'" '
:'StructuredLax'
);
xmlNode('cbc:StreetName':'':l9adr2);
fipost = %subst(l9adr4: 1: 5);
fibynv = %subst(l9adr4: 6: 24);
xmlNode('cbc:CityName':'':fibynv);
xmlNode('cbc:PostalZone':'':fipost);
xmlNode('cac:Country');
xmlNode('cbc:IdentificationCode':'':'DK');
xmlEndNode('cac:Country');
xmlEndNode('cac:PostalAddress');
xmlNode('cac:PartyTaxScheme');
xmlNode('cbc:CompanyID'
:'schemeID="'+ 'DK:SE' +'" '
:'DK' + %trim(%editc(l9cvr : '4'))
);
xmlNode('cac:TaxScheme');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxschemeid-1.1' +'" '
:'63'
);
xmlNode('cbc:Name':'':'Moms');
xmlEndNode('cac:TaxScheme');
xmlEndNode('cac:PartyTaxScheme');
xmlNode('cac:PartyLegalEntity');
xmlNode('cbc:RegistrationName':'':l9adr1);
xmlNode('cbc:CompanyID'
:'schemeID="'+ 'DK:CVR' +'" '
:'DK' + %trim(%editc(l9cvr : '4'))
);
xmlEndNode('cac:PartyLegalEntity');
xmlNode('cac:Contact');
xmlNode('cbc:ID':'':shbtjn);
xmlNode('cbc:Name':'':shbtjt);
xmlNode('cbc:Telephone':'':l9tlf);
xmlNode('cbc:Telefax':'':l9fax);
xmlNode('cbc:ElectronicMail':'':l9mail);
xmlEndNode('cac:Contact');
xmlEndNode('cac:Party');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr AccountingCustomerParty;

echo('');
xmlNode('cac:AccountingCustomerParty');

if shdebn > 0;
xxdebn = shdebn;
xxdeb1 = shdeb1;
xxdeb2 = shdeb2;
xxdeb3 = shdeb3;
xxdeb4 = shdeb4;
xxdeb5 = shdeb5;
else;
xxdebn = shkunn;
xxdeb1 = shdmn1;
xxdeb2 = shdmn2;
xxdeb3 = shdmn3;
xxdeb4 = shdmn4;
xxdeb5 = shdmn5;
endif;
if xxdeb1 = *blanks;
xxdeb1 = xxdeb2;
xxdeb2 = *blanks;
endif;
if xxdeb2 = *blanks;
xxdeb2 = xxdeb3;
xxdeb3 = *blanks;
endif;

xmlNode('cac:Party');
xmlNode('cbc:EndpointID'
:'schemeAgencyID="'+ '9' +'" '
+'schemeID="'+ 'GLN' +'" '
:dlkomm
);
xmlNode('cac:PartyIdentification');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '9' +'" '
+'schemeID="'+ 'GLN' +'" '
:dlkomm
);
xmlEndNode('cac:PartyIdentification');
xmlNode('cac:PartyName');
xmlNode('cbc:Name':'':xxdeb1);
xmlEndNode('cac:PartyName');
xmlNode('cac:PostalAddress');
xmlNode('cbc:AddressFormatCode'
:'listAgencyID="'+ '320' +'" '
+'listID="'+ 'urn:oioubl:codelist:addressformatcode-1.1' +'" '
:'StructuredLax'
);
xmlNode('cbc:StreetName':'':xxdeb2);
xmlNode('cbc:AdditionalStreetName':'':xxdeb3);
bdpost = %subst(xxdeb4: 1: 5);
bdbynv = %subst(xxdeb4: 6: 24);
xmlNode('cbc:CityName':'':bdbynv);
xmlNode('cbc:PostalZone':'':bdpost);
xmlNode('cac:Country');
xmlNode('cbc:IdentificationCode':'':'DK');
xmlEndNode('cac:Country');
xmlEndNode('cac:PostalAddress');
xmlNode('cac:Contact');
xmlNode('cbc:ID':'':oiwuid);
xmlNode('cbc:Name':'':oiwuna);
xmlEndNode('cac:Contact');
xmlEndNode('cac:Party');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr BuyerCustomerParty;

if shdebn = 0;
leavesr;
xxdebn = shdebn;
xxdeb1 = shdeb1;
xxdeb2 = shdeb2;
xxdeb3 = shdeb3;
xxdeb4 = shdeb4;
xxdeb5 = shdeb5;
else;
xxdebn = shkunn;
xxdeb1 = shdmn1;
xxdeb2 = shdmn2;
xxdeb3 = shdmn3;
xxdeb4 = shdmn4;
xxdeb5 = shdmn5;
endif;
if xxdeb1 = *blanks;
xxdeb1 = xxdeb2;
xxdeb2 = *blanks;
endif;
if xxdeb2 = *blanks;
xxdeb2 = xxdeb3;
xxdeb3 = *blanks;
endif;

echo('');
xmlNode('cac:BuyerCustomerParty');

xmlNode('cac:Party');
xmlNode('cbc:EndpointID'
:'schemeAgencyID="'+ '9' +'" '
+'schemeID="'+ 'GLN' +'" '
:dlkomm
);
xmlNode('cac:PartyIdentification');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '9' +'" '
+'schemeID="'+ 'GLN' +'" '
:dlkomm
);
xmlEndNode('cac:PartyIdentification');
xmlNode('cac:PartyName');
xmlNode('cbc:Name':'':xxdeb1);
xmlEndNode('cac:PartyName');
xmlNode('cac:PostalAddress');
xmlNode('cbc:AddressFormatCode'
:'listAgencyID="'+ '320' +'" '
+'listID="'+ 'urn:oioubl:codelist:addressformatcode-1.1' +'" '
:'StructuredLax'
);
xmlNode('cbc:StreetName':'':xxdeb2);
xmlNode('cbc:AdditionalStreetName':'':xxdeb3);
bdpost = %subst(xxdeb4: 1: 5);
bdbynv = %subst(xxdeb4: 6: 24);
xmlNode('cbc:CityName':'':bdbynv);
xmlNode('cbc:PostalZone':'':bdpost);
xmlNode('cac:Country');
xmlNode('cbc:IdentificationCode':'':'DK');
xmlEndNode('cac:Country');
xmlEndNode('cac:PostalAddress');
xmlNode('cac:Contact');
xmlNode('cbc:ID':'':oiwuid);
xmlNode('cbc:Name':'':oiwuna);
xmlEndNode('cac:Contact');
xmlEndNode('cac:Party');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr Delivery;

echo('');
xmlNode('cac:Delivery');

if shlevd > 0;
xmlNode('cbc:ActualDeliveryDate':'':isoFromNum(shlevd:'*YMD':'8'));
else;
xmlNode('cbc:ActualDeliveryDate':'':isoFromNum(shfakd:'*YMD':'8'));
endif;

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr PaymentMeans;

echo('');
xmlNode('cac:PaymentMeans');

xmlNode('cbc:ID':'':'1');
xmlNode('cbc:PaymentMeansCode':'':'93');
xmlNode('cbc:PaymentDueDate':'':isoFromNum(shfofd:'*YMD':'8'));
xmlNode('cbc:InstructionID':'':'000'
+ %editc(betkun:'X')
+ %editc(Åmo10m:'X'));
xmlNode('cbc:PaymentID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:paymentid-1.1' +'" '
:'71'
);
xmlNode('cac:CreditAccount');
xmlNode('cbc:AccountID':'':%editc(gfexpk:'X'));
xmlEndNode('cac:CreditAccount');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr PaymentTerms;

echo('');
xmlNode('cac:PaymentTerms');

xmlNode('cbc:PaymentMeansID':'':'1');
xmlNode('cbc:Note':'':'SPECIFIC');
xmlNode('cbc:SettlementDiscountPercent':'':'00');
xmlNode('cbc:PenaltySurchargePercent':'':'00');
xmlNode('cbc:Amount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shfakt:'P'))
);
xmlNode('cac:SettlementPeriod');
xmlNode('cbc:EndDate':'':isoFromNum(shfofd:'*YMD':'8'));
xmlEndNode('cac:SettlementPeriod');
xmlNode('cac:PenaltyPeriod');
xmlNode('cbc:StartDate':'':isoFromNum(shfofd:'*YMD':'8'));
xmlNode('cbc:StartTime':'':'00:00:00');
xmlEndNode('cac:PenaltyPeriod');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr AllowanceCharge;

echo('');
xmlNode('cac:AllowanceCharge');

xmlNode('cbc:ID':'':%char(linno));
xmlNode('cbc:ChargeIndicator':'':'true');
xmlNode('cbc:AllowanceChargeReason':'':lfttyp);
xmlNode('cbc:MultiplierFactorNumeric':'':'1');
xmlNode('cbc:SequenceNumeric':'':'1');
xmlNode('cbc:Amount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(lfbelb:'P'))
);
xmlNode('cbc:BaseAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(lfbelb:'P'))
);
xmlNode('cac:TaxCategory');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxcategoryid-1.1' +'" '
:'StandardRated'
);
xmlNode('cbc:Percent':'':%char(xxmoms));
xmlNode('cac:TaxScheme');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxschemeid-1.1' +'" '
:'63'
);
xmlNode('cbc:Name':'':'Moms');
xmlEndNode('cac:TaxScheme');
xmlEndNode('cac:TaxCategory');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr TaxTotal;

echo('');
xmlNode('cac:TaxTotal');

xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shmogr:'P'))
);
xmlNode('cac:TaxSubtotal');
xmlNode('cbc:TaxableAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shmogr:'P'))
);
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shmokr:'P'))
);
xmlNode('cac:TaxCategory');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxcategoryid-1.1' +'" '
:'StandardRated'
);
xmlNode('cbc:Percent':'':%char(xxmoms));
xmlNode('cac:TaxScheme');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxschemeid-1.1' +'" '
:'63'
);
xmlNode('cbc:Name':'':'Moms');
xmlEndNode('cac:TaxScheme');
xmlEndNode('cac:TaxCategory');
xmlEndNode('cac:TaxSubtotal');

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr LegalMonetaryTotal;

if shfakt = 0;
*inlr = *on;
return;
endif;

echo('');
xmlNode('cac:LegalMonetaryTotal');

xmlNode('cbc:LineExtensionAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shmogr-xxafgt:'P'))
);
xmlNode('cbc:TaxExclusiveAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shmokr:'P'))
);
xmlNode('cbc:TaxInclusiveAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shfakt:'P'))
);
if xxafgt <> 0;
xmlNode('cbc:ChargeTotalAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(xxafgt:'P'))
);
endif;
xmlNode('cbc:PayableAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(shfakt:'P'))
);

xmlEndNode();

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr InvoiceLine;

linno = 0;
/end-free
c linekey setll stafakl0

c dow 1 = 1

c linekey reade stafakl0 40

c if *in40 = *on
c leave
c endif

* Vend fortegn på kreditnota (således de IKKE optræder negativt)
c if xmltype = 'K'
c z-sub sfleva sfleva
c z-sub sfbeld sfbeld
c endif
/free

echo('');
xmlNode('cac:InvoiceLine');

linno += 1;
linmom = %dech(sfbeld * shmoms / 100:11:2);

xmlNode('cbc:ID':'':%char(linno));
if sfleva > 0;
xmlNode('cbc:InvoicedQuantity'
:'unitCode="'+ 'EA' +'" '
:%trim(%editc(sfleva:'P'))
);
else;
xmlNode('cbc:InvoicedQuantity'
:'unitCode="'+ 'EA' +'" '
:'1'
);
endif;
xmlNode('cbc:LineExtensionAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(sfbeld:'P'))
);
xmlNode('cac:TaxTotal');
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linmom:'P'))
);
xmlNode('cac:TaxSubtotal');
xmlNode('cbc:TaxableAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(sfbeld:'P'))
);
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linmom:'P'))
);
xmlNode('cac:TaxCategory');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxcategoryid-1.1' +'" '
:'StandardRated'
);
xmlNode('cbc:Percent':'':%char(xxmoms));
xmlNode('cac:TaxScheme');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxschemeid-1.1' +'" '
:'63'
);
xmlNode('cbc:Name':'':'Moms');
xmlEndNode('cac:TaxScheme');
xmlEndNode('cac:TaxCategory');
xmlEndNode('cac:TaxSubtotal');
xmlEndNode('cac:TaxTotal');



xmlNode('cac:Item');
if sftxt <> *blanks;
xmlNode('cbc:Description':'':sftxt);
xmlNode('cbc:Name':'':sftxt);
else;
xmlNode('cbc:Description':'':'.');
xmlNode('cbc:Name':'':'.');
endif;
xmlNode('cac:SellersItemIdentification');
if sfvarn <> *blanks;
xmlNode('cbc:ID'
:'schemeID="'+ 'n/a' +'" '
:sfvarn
);
else;
xmlNode('cbc:ID'
:'schemeID="'+ 'n/a' +'" '
:'text'
);
endif;
xmlEndNode('cac:SellersItemIdentification');
xmlEndNode('cac:Item');
xmlNode('cac:Price');
if sfleva > 0;
xmlNode('cbc:PriceAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(sffakp:'P'))
);
else;
xmlNode('cbc:PriceAmount'
:'currencyID="'+ 'DKK' +'" '
:'0.00'
);
endif;
xmlNode('cbc:BaseQuantity'
:'unitCode="'+ 'EA' +'" '
:'1'
);
xmlNode('cbc:OrderableUnitFactorRate':'':'1');
xmlEndNode('cac:Price');

xmlEndNode();

exsr InvoiceLineA;

enddo;

endsr;
/end-free

/EJECT
*=====================================================================
/free
begsr InvoiceLineA;

/end-free
* Læs tilhørende afgiftliner
* Hvis varen er en skaffevare (sfvatp=S) tages afgiften fra fakturalinien STAFAKF
* der kan kun være en afgift ved skaffevarer
c if sfvatp = 'S'
c and sfafgg <> *BLANKS
* Vend fortegn på kreditnota (således de IKKE optræder negativt)
c eval satxt = sfafgt
c eval saplkr = sfplkr
c eval(H) saabel = sfplkr * sfleva
c*bvh if xmltype = 'K'
c*bvh z-sub saabel saabel
c*bvh endif

/free
dsply 'afgift skaf';

echo('');
xmlNode('cac:InvoiceLine');

linno += 1;
linmom = %dech(saabel * shmoms / 100:11:2);
if sfleva <> 0;
linprs = %dech(saabel / sfleva :11:2);
else;
linprs = 0;
endif;

xmlNode('cbc:ID':'':%char(linno));
if sfleva > 0;
xmlNode('cbc:InvoicedQuantity'
:'unitCode="'+ 'EA' +'" '
:%trim(%editc(sfleva:'P'))
);
else;
xmlNode('cbc:InvoicedQuantity'
:'unitCode="'+ 'EA' +'" '
:'1'
);
endif;
xmlNode('cbc:LineExtensionAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(saabel:'P'))
);
xmlNode('cac:TaxTotal');
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linmom:'P'))
);
xmlNode('cac:TaxSubtotal');
xmlNode('cbc:TaxableAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(saabel:'P'))
);
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linmom:'P'))
);
xmlNode('cac:TaxCategory');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxcategoryid-1.1' +'" '
:'StandardRated'
);
xmlNode('cbc:Percent':'':%char(xxmoms));
xmlNode('cac:TaxScheme');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxschemeid-1.1' +'" '
:'63'
);
xmlNode('cbc:Name':'':'Moms');
xmlEndNode('cac:TaxScheme');
xmlEndNode('cac:TaxCategory');
xmlEndNode('cac:TaxSubtotal');
xmlEndNode('cac:TaxTotal');

xmlNode('cac:Item');
if satxt <> *blanks;
xmlNode('cbc:Description':'':satxt);
xmlNode('cbc:Name':'':satxt);
else;
xmlNode('cbc:Description':'':'.');
xmlNode('cbc:Name':'':'.');
endif;
xmlNode('cac:SellersItemIdentification');
if satxt <> *blanks;
xmlNode('cbc:ID'
:'schemeID="'+ 'n/a' +'" '
:satxt
);
else;
xmlNode('cbc:ID'
:'schemeID="'+ 'n/a' +'" '
:'afgift'
);
endif;
xmlEndNode('cac:SellersItemIdentification');
xmlEndNode('cac:Item');
xmlNode('cac:Price');
if sfleva > 0;
xmlNode('cbc:PriceAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linprs:'P'))
);
else;
xmlNode('cbc:PriceAmount'
:'currencyID="'+ 'DKK' +'" '
:'0.00'
);
endif;
xmlNode('cbc:BaseQuantity'
:'unitCode="'+ 'EA' +'" '
:'1'
);
xmlNode('cbc:OrderableUnitFactorRate':'':'1');
xmlEndNode('cac:Price');

xmlEndNode();
/end-free


c else

* Hvis varen IKKE er en skaffevare (sfvatp<>S) tages afgiften fra afgiftsstatik STAAFGF
c afgfkey setll staafgl2

c dow 1 = 1

c afgfkey reade staafgl2 41

c if *in41 = *on
c leave
c endif

* Vend fortegn på kreditnota (således de IKKE optræder negativt)
c if xmltype = 'K'
c z-sub saabel saabel
c endif

/free

echo('');
xmlNode('cac:InvoiceLine');

linno += 1;
linmom = %dech(saabel * shmoms / 100:11:2);
if sfleva <> 0;
linprs = %dech(saabel / sfleva :11:2);
else;
linprs = 0;
endif;

xmlNode('cbc:ID':'':%char(linno));
if sfleva > 0;
xmlNode('cbc:InvoicedQuantity'
:'unitCode="'+ 'EA' +'" '
:%trim(%editc(sfleva:'P'))
);
else;
xmlNode('cbc:InvoicedQuantity'
:'unitCode="'+ 'EA' +'" '
:'1'
);
endif;
xmlNode('cbc:LineExtensionAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(saabel:'P'))
);
xmlNode('cac:TaxTotal');
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linmom:'P'))
);
xmlNode('cac:TaxSubtotal');
xmlNode('cbc:TaxableAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(saabel:'P'))
);
xmlNode('cbc:TaxAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linmom:'P'))
);
xmlNode('cac:TaxCategory');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxcategoryid-1.1' +'" '
:'StandardRated'
);
xmlNode('cbc:Percent':'':%char(xxmoms));
xmlNode('cac:TaxScheme');
xmlNode('cbc:ID'
:'schemeAgencyID="'+ '320' +'" '
+'schemeID="'+ 'urn:oioubl:id:taxschemeid-1.1' +'" '
:'63'
);
xmlNode('cbc:Name':'':'Moms');
xmlEndNode('cac:TaxScheme');
xmlEndNode('cac:TaxCategory');
xmlEndNode('cac:TaxSubtotal');
xmlEndNode('cac:TaxTotal');

xmlNode('cac:Item');
if satxt <> *blanks;
xmlNode('cbc:Description':'':satxt);
xmlNode('cbc:Name':'':satxt);
else;
xmlNode('cbc:Description':'':'.');
xmlNode('cbc:Name':'':'.');
endif;
xmlNode('cac:SellersItemIdentification');
if satxt <> *blanks;
xmlNode('cbc:ID'
:'schemeID="'+ 'n/a' +'" '
:satxt
);
else;
xmlNode('cbc:ID'
:'schemeID="'+ 'n/a' +'" '
:'afgift'
);
endif;
xmlEndNode('cac:SellersItemIdentification');
xmlEndNode('cac:Item');
xmlNode('cac:Price');
if sfleva > 0;
xmlNode('cbc:PriceAmount'
:'currencyID="'+ 'DKK' +'" '
:%trim(%editc(linprs:'P'))
);
else;
xmlNode('cbc:PriceAmount'
:'currencyID="'+ 'DKK' +'" '
:'0.00'
);
endif;
xmlNode('cbc:BaseQuantity'
:'unitCode="'+ 'EA' +'" '
:'1'
);
xmlNode('cbc:OrderableUnitFactorRate':'':'1');
xmlEndNode('cac:Price');

xmlEndNode();
/end-free
c enddo
c endif
/free

endsr;
/end-free

/EJECT
*================================================================
* Håndtering af afgift-totaler
* --- (max. 5 stk.) ---
*================================================================

c afgtot begsr

c eval linno = 0
c eval xxafgt = 0

* Fragt

c if shfrap <> 0
c eval linno = linno + 1
c eval lfttyp = *blanks
c eval lfbelb = 0
c eval lfttyp = 'Fragt'
c eval lfbelb = shfrap
c eval xxafgt = xxafgt + lfbelb
/free
exsr AllowanceCharge;
/end-free
c endif

* Eksp. gebyr

c if sheksp <> 0
c eval linno = linno + 1
c eval lfttyp = *blanks
c eval lfbelb = 0
c eval lfttyp = 'Gebyr'
c eval lfbelb = sheksp
c eval xxafgt = xxafgt + lfbelb
/free
exsr AllowanceCharge;
/end-free
c endif

* Faktura/fax rabat

c if shfkrb <> 0
c eval linno = linno + 1
c eval lfttyp = *blanks
c eval lfbelb = 0
c eval lfttyp = 'Rabat'
c eval lfbelb = shfkkr
c eval xxafgt = xxafgt + lfbelb
/free
exsr AllowanceCharge;
/end-free
c endif

c eval linno = 0

c endsr
c/EJECT
*================================================================
* Beregning af Modulus 10 Checkciffer

c Åmod10 begsr

c Åmo10a mult Åmo10v Åmo10b
c xfoot Åmo10c Åmo10s
c z-add Åmo10s Åmo10m
c 10 sub Åmo10m Åmo10m

c endsr
** ÅMO10V MODULUS 10 VÆGTE
212121212121212

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.