If ELSE statement

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
marbis
Participant
Posts: 5
Joined: Tue Jul 14, 2009 9:01 am

If ELSE statement

Post by marbis »

Hi,
I want map a field with this code, but datastage returns an error.
I think thet the problem is the number of 'if else' cosctruct.
Is possible?

if campo di input = 'R12'
THEN 'RCON' ELSE
if campo di input = '18A'
THEN 'RCON' ELSE
if campo di input = 'R42'
THEN 'RFAM' ELSE
if campo di input = '36A'
THEN 'RFAM' ELSE
if campo di input = 'CF4'
THEN 'RFAM' ELSE
if campo di input = 'R92'
THEN 'RINV' ELSE
if campo di input = 'CE8'
THEN 'RINV' ELSE
if campo di input = 'R17'
THEN 'RLEG' ELSE
if campo di input = '20A'
THEN 'RLEG' ELSE
if campo di input = 'R62'
THEN 'RLEG' ELSE
if campo di input = '46A'
THEN 'RLEG' ELSE
if campo di input = 'CG4'
THEN 'RPCF' ELSE
if campo di input = 'CG6'
THEN 'RPES' ELSE
if campo di input = 'R21'
THEN 'RPOC' ELSE
if campo di input = '22A'
THEN 'RPOC' ELSE
if campo di input = 'R52'
THEN 'RCRE' ELSE
if campo di input = '43A'
THEN 'RCRE' ELSE
if campo di input = 'CG2'
THEN 'RCRE' ELSE
if campo di input = 'R50'
THEN 'RMIM' ELSE
if campo di input = '41A'
THEN 'RMIM' ELSE
if campo di input = 'CG1'
THEN 'RMIM' ELSE
if campo di input = 'R30'
THEN 'RMPR' ELSE
if campo di input = '28A'
THEN 'RMPR' ELSE
if campo di input = 'CF1'
THEN 'RMPR' ELSE
if campo di input = 'R34'
THEN 'RFPR' ELSE
if campo di input = '30A'
THEN 'RFPR' ELSE
if campo di input = 'R15'
THEN 'RPER' ELSE
if campo di input = 'R37'
THEN 'RSMB' ELSE
if campo di input = '33A'
THEN 'RSMB' ELSE
if campo di input = 'CF6'
THEN 'RSMB' ELSE
if campo di input = 'CE2'
THEN 'RSMB' ELSE
if campo di input = 'R25'
THEN 'RATO' ELSE
if campo di input = '26A'
THEN 'RATO' ELSE
if campo di input = 'CN1'
THEN 'RATO' ELSE
if campo di input = 'R23'
THEN 'RCGE' ELSE
if campo di input = '24A'
THEN 'RCGE' ELSE
if campo di input = 'R61'
THEN 'RSCA' ELSE
if campo di input = 'CM7'
THEN 'RSCA' ELSE
if campo di input = 'R81'
THEN 'RPPR' ELSE
if campo di input = '51A'
THEN 'RPPR' ELSE
if campo di input = 'R90'
THEN 'RPSA' ELSE
if campo di input = 'R94'
THEN 'RSAA' ELSE
if campo di input = 'CE4'
THEN 'RCDO' ELSE
if campo di input = 'R00'
THEN 'RARA' ELSE
if campo di input = 'CF2'
THEN 'RPRL' ELSE
if campo di input = 'CE1'
THEN 'CMPR' ELSE
if campo di input = 'CM1'
THEN 'RAAL' ELSE
if campo di input = 'CM3'
THEN 'RAMM' ELSE
if campo di input = 'N55'
THEN 'RBOF' ELSE
if campo di input = '05A'
THEN 'RBOF' ELSE
if campo di input = 'N81'
THEN 'RPRI' ELSE
if campo di input = 'N84'
THEN 'RMPE' ELSE
if campo di input = '11A'
THEN 'RMPE' ELSE
if campo di input = 'N87'
THEN 'RMFA' ELSE
if campo di input = '13A'
THEN 'RMFA' ELSE
if campo di input = 'N89'
THEN 'RMSS' ELSE
if campo di input = 'N91'
THEN 'RMSB' ELSE
if campo di input = 'N51'
THEN 'CPTM' ELSE
if campo di input = '02A'
THEN 'CPTM' ELSE
if campo di input = 'N52'
THEN 'GEIM' ELSE
if campo di input = '03A'
THEN 'GEIM' ELSE
if campo di input = 'N71'
THEN 'CPTC' ELSE
if campo di input = 'N72'
THEN 'GECO' ELSE
if campo di input = 'N82'
THEN 'COPP' ELSE
if campo di input = '09A'
THEN 'COPP' ELSE
if campo di input = 'N8A'
THEN 'COPP' ELSE
if campo di input = '15A'
THEN 'COPP' ELSE
if campo di input = 'N85'
THEN 'COPE' ELSE
if campo di input = 'N86'
THEN 'GEPE' ELSE
if campo di input = '12A'
THEN 'GEPE' ELSE
if campo di input = 'N88'
THEN 'GEFA' ELSE
if campo di input = '14A'
THEN 'GEFA' ELSE
if campo di input = 'N92'
THEN 'GESB' ELSE
if campo di input = '16A'
THEN 'GESB' ELSE
if campo di input = '54A'
THEN 'GESB' ELSE
if campo di input = 'N93'
THEN 'COPD' ELSE
if campo di input = 'R47'
THEN 'RTES' ELSE
if campo di input = '39A'
THEN 'RTES' ELSE
if campo di input = 'CE6'
THEN 'RTES' ELSE
if campo di input = 'R70'
THEN 'RNES' ELSE
if campo di input = '49A'
THEN 'RNES' ELSE
if campo di input = 'CG8'
THEN 'RNES' ELSE
if campo di input = 'CM5'
THEN 'RDSK' ELSE
if campo di input = 'S01'
THEN 'GTSB' ELSE
''
end end end end end end end end end end
end end end end end end end end end end
end end end end end end end end end end
end end end end end end end end end end
end end end end end end end end end end
end end end end end end end end end end
end end end end end end end end end end
end end end end end end end end end end
end end end end


BYE
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Some points you need to consider

1.) Variable name must not have spaces in them
2.) END not required
3.) BYE not required :wink:

If you are using in a routine, you can use the CASE statement.
robjones
Participant
Posts: 24
Joined: Tue Nov 18, 2008 3:12 pm
Location: London

Post by robjones »

I'd be tempted to put all those values into a sequential file and perform a lookup rather than hardcode them all into that statement.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Moderator: please move to TX forum
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply