Thursday, February 23, 2012

DB2 to XML....

Today I finished polishing my item master daily update and gave a copy to the Director of Application Development for code review. He commented this is the Apollo 11 version compared to his old style RPGII coding and smiled. I will take that as a compliment. ;)

I continued and started the Store master file daily update program. I completed the coding and the program compiled but I am getting pretty tired and decided I could finish up in the morning. This program needed some date manipulation changing six digit numeric field, YYMMDD, to character representation, CCYY-MM-DD.  Things sure have gotten easier with RPGLE and with Google to the rescue I had no problem catching on.

The fields are not true dates so my friend Sam Lennon's article on RPG IV legacy dates cheat sheet was not where I landed. I did find another article that I have looked at from time to time. The RPG free-format date conversion cheat sheet by Mitchel Laman is just what I needed.

I added a couple of fields to my D spec’s -

D @numA       S      6  0  inz(041205)                      yymmdd
D @dateA       S        d    inz(D’2004-12-04’) date formatted field
D Strod           A     10 ccyy-mm-dd alpha

I added a subroutine to my code to deal with the conversion.

begsr datesr;
@numA = sodte; // Store open date field from input file
@dateA = %date(@numA:*ymd);      // yymmdd to D’ccyy-mm-dd’

At the time I was not sure if the dashes would carry through. I then added the following to my routine that creates the XML for the IFS write. There is more to the XML but you get were I’m heading.

$xml = %char(@dateA)

I am really liking this RPGLE Free, much easier than when I worked with RPGII years ago.

~ Richard  

No comments:

Post a Comment