Wednesday, February 22, 2012

RPGLE Free learn something new every day...

While working on my XML project I ran in to a little problem. I have been building off my first concept program and have completed three programs that generate six XML documents. As I am working with the last program that captures additions and changes to the item master file I stumbled a little.  

I had to move my do loop outside the routine that writes to the IFS and I forgot to move the close file with it. I spotted the problem quickly and made adjustment but I had ran the program several times checking data in debug before I noticed the problem. So I run the program and no output was generated in the IFS. I scratched my head for a while thinking I goofed up the program and then ran one of my completed programs that I know works and no file generated, WTF!

I then ran WRKLNK to the directory I am working with and received error, to many files open. OK, I realize that I created the problem earlier in the day but did not know how to fix the problem. I prompt CLOF and need a PF name, but these are IFS stream files. Google to the rescue.

I quickly discovered that WRKJOB has a few more options other than I have used before like *OPNF. I ran the command and yes I see I have many open files, guess I ran testing a little more than I thought. But I still do not know how to fix the problem. DOH! Sign off and back on stupid!

So I resolved my problem and before I walked out for the day I ran my new program and generated the output I am looking for. :)

I taught myself a lot today. The program input is a file that is added to nightly from the item master journal file. I incorporated an external data structure for the before and after images based on the item master file with a prefix.

d Befjrn    e  ds  extname(ipithdr)

d Aftjrn      e  ds extname(ipithdr)

I figured out how to load the array using rpgle free, very cool and much better than adding the from and to positions for each field.

I had already written this program in rpgle and it tested great but since my other programs are rpgle free I wanted to change it to free. There are a few caveats in free that I was not aware of but quickly over came each challenge and by the end of the day I am very pleased.

I think I am going to figure out check for open files if program fails, that will be tomorrows task.

My programming skills are growing by leaps and bounds. I have been writing small amounts of code and debugging a lot of code over the last 15 years. I am really starting to feel well about my programming. I am sure I will have many challenges to overcome as time moves on.

Seems like I am not missing juggling many balls, answering phone calls, E-mail and educating users as operations manager as I thought I would. Just put in the ear-buds, turn up the music and jam on the keyboard, eight hours flies by!


Any fool can write code that a computer can understand.  Good programmers write code that humans can understand.  ~Martin Fowler

No comments:

Post a Comment