Hi Guys,
I got some great advice with my previous question (See Here).
I am still working on the same project but now I need to "import" forex data into my database. The project is for non-profit purposes, its like a mini graduation project for the IBM Academic Initiative.
My Problem:
I need to parse an XML into my DB, but I think my DS is not correct.
My Request:
Please help me to import the XML into my DB, I believe my issue is with the DataStructure. Though I don't know what I am doing wrong.
Further Info:
I have found and very nice source for forex data from the ECB (European Central Bank). They say I can use their data when "ECB must be cited as the source."
I have edited the ECB xml file to only have 2 day's forex info, as I do not just to get the XML-INTO program I am writing to work.
Please find it attached as F1.xml
Changes in my opinion I needed to make some changes to the original ECB xml,
as the was ":" and duplicate tags.
My RPGLE (FxRatesXML.rpgle):
My Databse (FxRates.pf) (Another Tx to Philippe and Michael)
I got some great advice with my previous question (See Here).
I am still working on the same project but now I need to "import" forex data into my database. The project is for non-profit purposes, its like a mini graduation project for the IBM Academic Initiative.
My Problem:
I need to parse an XML into my DB, but I think my DS is not correct.
My Request:
Please help me to import the XML into my DB, I believe my issue is with the DataStructure. Though I don't know what I am doing wrong.
Further Info:
I have found and very nice source for forex data from the ECB (European Central Bank). They say I can use their data when "ECB must be cited as the source."
I have edited the ECB xml file to only have 2 day's forex info, as I do not just to get the XML-INTO program I am writing to work.
Please find it attached as F1.xml
Changes in my opinion I needed to make some changes to the original ECB xml,
as the was ":" and duplicate tags.
Code:
[B]From:[/B] [B]To:[/B] gesmes:Envelope gesmesEnvelope gesmes:subject gesmesSubject gesmes:Sender gesmesSender gesmes:name gesmesName Cube time CubeT time Cube currency CubeCur currency The last /Cube needs not be changed the rest must be /CubeT
Code:
// The Purpose of this program is to parse an xml file form ECB bank // The xml file contains 90 days worth of Forex Rates // The xml's (unedited) is obtainable from: // http://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html FFXRATES UF A E K Disk DgesmesEnvelope Ds Qualified D xmlnsGesmes 40A D xmlns 50A D gesmesSubject 20A D gesmesSender LikeDS(gesmesSender) D Cube LikeDS(Cube) D gesmesSender Ds Qualified D gesmesName 20A D Cube Ds Qualified D CubeT LikeDS(CubeT) Dim(90) //Prov for 90 Days D CubeT Ds Qualified D time D D CubeCur LikeDS(CubeCur) Dim(34) //Prov for 34 Currencies D CubeCur Ds Qualified D currency 3A D rate 9P 4 D XML_Source S 256A Varying D Inz('/home/OL20007/Christoff/F1.xml') D CURSYMFROM S 3A Inz('EUR') D CURSYMTO S 3A Inz(*HiVal) D RATE S 9P 4 Inz(*HiVal) D X S 3P 0 D Y S 3P 0 /Free //Read the XML into a mega DS XML-INTO gesmesEnvelope %XML(XML_Source: 'doc=file + case=any + allowmissing=yes'); //Process the mega DS and update the database //For the Days 1 to 90 For X = 1 to 90; gesmesEnvelope.Cube.CubeT(X).time = CURDATE; //If there is no Date in the XML file do not process or update DB IF NOT (CURDATE = *HiVal); //For the 34 Currencies For Y = 1 to 34; gesmesEnvelope.Cube.CubeT(X).CubeCur(Y).currency = CURSYMTO; gesmesEnvelope.Cube.CubeT(X).CubeCur(Y).rate = RATE; //IF there is no Currency info for the date, do not process. IF NOT (CURSYMTO = *HiVal) or (RATE = *HiVal); Chain (CURDATE:CURSYMFROM:CURSYMTO) FXRATES; If NOT %Found(FXRATES); Update FXRATESREC; ENDIF; ENDIF; //Reset the CurSymTO and the Rate variables to *HiVal Reset CURSYMTO; Reset RATE; ENDFOR; ENDIF; //Reset the CurDate var to *HiVal Reset CURDATE; ENDFOR; *Inlr = *On; Return; /End-Free
Code:
A************************************************************************** A*** Database of the Currencies A************************************************************************** A UNIQUE A R FXRATESREC A CURDATE L TEXT('Date of the Currency Row') A CURSYMFROM 3A TEXT('Convert From Currency Code') A CURSYMTO 3A TEXT('Convert To Currency Code') A RATE 9P 4 TEXT('Conversion Multiplier') A************************************************************************** A K CURDATE A K CURSYMFROM A K CURSYMTO
Comment