date dimension problem

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sivap
Participant
Posts: 14
Joined: Tue Oct 26, 2004 8:13 am

date dimension problem

Post by sivap »

Hi

I have Developed a Date dimension Job , which finds the Last Business day of Prior Month, Last Business Day of Same month Prior Year.

Source

4HashFiles(Holiday lookup) ------> Tranformer ---------> DB2 Target


I am using 4 lookups for checking 4 previous days form the last calender date of previous month.i have a routine for finding previous month last calender date. If I pass any date to that routine it gives the previous months last calender date. In this routine i am checking for Saturdays and Sundays also. For ex : if the last calender date is sat or sunday then it
should return Friday as last clender date of previous month. If the Last calender day is Monday and it is Holiday then I should get Friday as my last business day of previous month. Pls help me out to find what is problem in The Code:


if DSLink125.NOTFOUND then Iconv(PrevMonthDate(lkIAODSDATETarIn.GREG_DATE),"D-YMD[4,2,2]")
else if DSLink126.NOTFOUND then Iconv(PrevMonthDate(lkIAODSDATETarIn.GREG_DATE),"D-YMD[4,2,2]")-1 else if DSLink127.NOTFOUND then Iconv(PrevMonthDate(lkIAODSDATETarIn.GREG_DATE),"D-YMD[4,2,2]")-2
else if DSLink128.NOTFOUND then Iconv(PrevMonthDate(lkIAODSDATETarIn.GREG_DATE),"D-YMD[4,2,2]")-3 else if Not(DSLink125.NOTFOUND) and DSLink126.NOTFOUND then LBDofPrevMonthSv1 else if Not(DSLink125.NOTFOUND) and Not(DSLink126.NOTFOUND) and DSLink127.NOTFOUND then LBDofPrevMonthSv2 else if Not(DSLink125.NOTFOUND) and Not(DSLink126.NOTFOUND) and Not(DSLink127.NOTFOUND) and DSLink128.NOTFOUND then LBDofPrevMonthSv3 else if Not(DSLink125.NOTFOUND) and Not(DSLink126.NOTFOUND) and Not(DSLink127.NOTFOUND) and Not(DSLink128.NOTFOUND) then LBDofPrevMonthSv4 else " "
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Your problem is your code is unreadable. Name your links! Also, you include stage variables with no informatin about how they are derived. What's the result you're getting, and what were you expecting? Did you run a few different test cases and figure out if anything is working? How about posting your function for determining the last business day of a month? Do you know if that works?

Here's what I recommend:

1. Break this huge derivation down into a series of progressing stage variables, meaning derive little pieces into stage variables, then derive another stage variable using the results of other stage variables to make your caclulation easier.
2. Simplify your (absent) function to do more so that you don't have so much derivation logic which is difficult to debug because you have to run the job and don't have the features the Function editor has.
3. Post all missing logic so that we can help you better.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

I would never have such a long piece of code in a transformer. Impossible to debug or maintain. I would back to Ken's advice on the use of routines. Routines have a "Test" button that save and replay test scenarios for your code. Instant feedback on whether your code is correct and re-usable between jobs.

A combination of stage variables and routines should turn this into a transformer that is easy to understand. I cannot even begin to work through the statement as it appears now.
Post Reply