Question for DataStage Experts

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
ajtavella
Participant
Posts: 2
Joined: Tue Nov 09, 2004 10:34 am

Question for DataStage Experts

Post by ajtavella »

Hello everyone there.
I'm having problems creating one routine and I can't realize where the hell the error is. I presume it's related with some order or basic sintaxs stuff. I wonder whether some of you can evangelize me and let me find the answer.
This are the parameters for the routine:

Kstar
PathArchivoOrigen
CantidadCampos
PathArchivoDestino

This is the error message I'm getting:
REPEAT" unexpected, Was expecting: Array Name, Variable name,
New variable name, ';', Statement label, "ABORT", "ABORTE", "ABORTM",
"BEGIN", "BREAK", "CALL", "CHAIN", "CLEAR", "CLEARCOM", and so on....

This is the routine code:



PathOrigen = PathArchivoOrigen
RegistroDestino = ''
NoCumple = 0
OpenSeq PathOrigen To VariableFileOrigen Then

Loop

While ReadSeq RecordString From VariableFileOrigen

If Field(RecordString, ",", 6) = Kstar then
ValOption = Field(RecordString, ",", 5)
ValFrom = Field(RecordString, ",", 6)
ValTo = Field(RecordString, ",", 7)
Exit
End Else

ValOption = 'NN'
End

Repeat

CloseSeq VariableFileOrigen
OpenSeq PathOrigen To VariableFileOrigen then
PathDestino = PathArchivoDestino :ValOption

Loop

While ReadSeq RecordString From VariableFileOrigen

ValToActual = Field(RecordString, ",", 6)
ValFromActual = Field(RecordString, ",",7)

For CampoActual = 1 to CantidadCampos

RegistroDestino = RegistroDestino :",":Field(RecordString, ",", CampoActual)

Next CampoActual

OpenSeq PathDestino To VariableFileDestino Then

Begin Case

Case ValOption = 'EQ'

If ValFromActual = ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'NE'

If ValFromActual <> ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1


Case ValOption = 'BT'

If ValFromActual > ValFrom AND ValToActual < ValTo
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1


Case ValOption = 'LE'

If ValFromActual <= ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'GT'

If ValFromActual > ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'GE'

If ValFromActual >= ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'LT'

If ValFromActual < ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

End Case


Repeat

CloseSeq VariableFileOrigen
CloseSeq VariableFileDestino

Ans = NoCumple

-*-*-*-**-*

If anyone can solve this, he is earning my eternal respect! :-)
Thanks a lot!

Alejandro Tavella
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You have OpenSeq ... then without an end statement before the repeat statement.

Next time bracket your code with alt c and format it ahead of time.
Mamu Kim
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Before that you need to let us know why you are having your OpenSeq within the loop.
ajtavella
Participant
Posts: 2
Joined: Tue Nov 09, 2004 10:34 am

God bless KD

Post by ajtavella »

KIM DUKE RULES!!!!!!!!!!!!!!!!!

I want everybody in this prestigious forum to bless this amazing DS Guru!

Thanks a lot Kim!

It was that End stuff.

As regards the other question,I've got a routine that receives some parameter called Kstar, then looks for that value in the sequencial file, and when it finds that record, it gets the value from other three fields (ValTo, ValFrom and ValOption). Then you have to search the whole file and depending on the value of ValOption you write or not that record in a target file. There are other issues that don't let you do that in a transformer, so the advice from Lord Kim was fantastic.
Have a nice time and thanks a lot!

So, it goes like this!

PathOrigen = PathArchivoOrigen
RegistroDestino = ''
NoCumple = 0
OpenSeq PathOrigen To VariableFileOrigen Then

Loop

While ReadSeq RecordString From VariableFileOrigen

If Field(RecordString, ",", 6) = Kstar then
ValOption = Field(RecordString, ",", 5)
ValFrom = Field(RecordString, ",", 6)
ValTo = Field(RecordString, ",", 7)
Exit
End Else

ValOption = 'NN'
End

Repeat
End

CloseSeq VariableFileOrigen
OpenSeq PathOrigen To VariableFileOrigen then
PathDestino = PathArchivoDestino :ValOption

Loop

While ReadSeq RecordString From VariableFileOrigen

ValToActual = Field(RecordString, ",", 6)
ValFromActual = Field(RecordString, ",",7)

For CampoActual = 1 to CantidadCampos

RegistroDestino = RegistroDestino :",":Field(RecordString, ",", CampoActual)

Next CampoActual

OpenSeq PathDestino To VariableFileDestino Then

Begin Case

Case ValOption = 'EQ'

If ValFromActual = ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'NE'

If ValFromActual <> ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1


Case ValOption = 'BT'

If ValFromActual > ValFrom AND ValToActual < ValTo
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1


Case ValOption = 'LE'

If ValFromActual <= ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'GT'

If ValFromActual > ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'GE'

If ValFromActual >= ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

Case ValOption = 'LT'

If ValFromActual < ValFrom
then WriteSeq RegistroDestino To VariableFileDestino
else NoCumple = NoCumple + 1

End Case
End
Repeat
End

WEOFSeq VariableFileDestino

CloseSeq VariableFileOrigen
CloseSeq VariableFileDestino

Ans = NoCumple
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Kim is an IBM_WS_DS Guru!
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Thanks. I appreciate the compliment even though I get no respect from my friend Hester.
Mamu Kim
Post Reply