Case Statment

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

kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

JDionne wrote: I like the inlist funuction...but I dont understand it. I will not use something that I dont understand in a production job. I just cant do that.
Okay fine. But, stick it into Manager and put in a zillion test caes. Add it to your application porfolio after exhaustive regression tests. Part of using any programming language is building a common library.
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
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

kcbland wrote:Here's your logic corrected:

Begin Case
* (PACIFIC TRADE GENERAL):
Case ( Arg1 = '588' Or Arg1 ='570' Or Arg1 ='580' Or Arg1 ='582' Or Arg1 ='583' Or Arg1 ='560' Or Arg1 ='559' Or Arg1 ='549' Or Arg1 ='565' Or Arg1 ='557' Or Arg1 ='552' Or Arg1 ='538' Or Arg1 ='555' Or Arg1 ='579' Or Arg1 ='566' Or Arg1 ='546' Or Arg1 ='574' Or Arg1 ='561' Or Arg1 ='684' Or Arg1 ='553') AND NOT(Arg2 = 'MARSHAL ISL' OR Arg2 = 'KWAJALEIN')
Ans = 'PACIFIC TOTAL'
End Case
That tested for you?

Now i get the error:
Test completed.


Result = Program "TSTcasetest.B": Line 5, Variable "ANS" previously undefined. Empty string used.

as if they all failed the test.....
we are moving here though. I will study your answer more
Jim
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

Yup u are right. I see what my fat finger had done and now it works....This is great now I can move on to the harder logic in the code.
Thanx
Jim

btw how do i get this code to wrap to the next line. I realy need to be able to look at all of this at once and not scrol.
Jim
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Try splitting the statement up to make it more readable. You can put your codes into an array, kind of like setting a constant, then refer to this list anywhere in your code.

Code: Select all

PacCodes =  '588':@FM:'570':@FM:'580':@FM:'582':@FM:'583':@FM:'560':@FM:'559':@FM:'549':@FM:'565':@FM:'557':@FM:'552':@FM:'538':@FM:'555':@FM:'579':@FM:'566':@FM:'546':@FM:'574':@FM:'561':@FM:'684':@FM:'553'

PacLocs = 'MARSHAL ISL' :@FM:'KWAJALEIN'
Ans = ""
* (PACIFIC TRADE GENERAL): 
LOCATE Arg1 IN CheckCodes SETTING FoundCode THEN
    LOCATE Arg2 IN CheckLocs SETTING FoundLoc THEN
        Ans = 'PACIFIC TOTAL' 
    end
end
You can also set up code lists for other regions and run multiple LOCATE statements.
Post Reply