Cobol data file

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
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Cobol data file

Post by anu123 »

Hi all,

In my Cobol source file, I have field as S(5)V99.The values are like

000770{
001690D
000845B
011250{

I tried to use DataTypePicS9 / DataTypePicComp3V99 / DataTypeEbcdicPic9V99

But I could not convert and load it into my target DB (Oracle)

Please some though some light ...

thanks in advance,
Thank you,
Anu
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Your EBCDIC is allready transfered to ASCII so use this function:
FUNCTION SwitchEBCDICSign(Arg1)

Laenge=len(Arg1)
Links=Arg1[1,Laenge-1]
Hyro=SEQ(Arg1[1])

BEGIN CASE
CASE Hyro >= 65 AND Hyro <= 73; Ans=(Links:Hyro-64)+0
CASE Hyro >= 74 AND Hyro <= 82; Ans=(Links:Hyro-73)*-1
CASE Hyro=249 ; Ans=(Links:"0")+0
CASE Hyro=166 ; Ans=(Links:"0")*-1
CASE Hyro=228 ; Ans=(Links:"0")+0
CASE Hyro=252 ; Ans=(Links:"0")*-1
CASE Hyro >= 48 AND Hyro <= 57; Ans=( Links:Hyro-48 )+0
CASE @TRUE ; Ans=@NULL
END CASE

RETURN(Ans)
Wolfgang Hürter
Amsterdam
dssiddu
Participant
Posts: 66
Joined: Mon Nov 07, 2005 10:28 pm
Contact:

Post by dssiddu »

hi

u can use complex flat file.
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

WoMawill

Your function is great but can you be more explicit about its use.
Do you call it everytime ?
Is the null return an error or a no action needed flag.

Thank you.
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

WoMaWil wrote:Your EBCDIC is allready transfered to ASCII so use this function:
FUNCTION SwitchEBCDICSign(Arg1)

Laenge=len(Arg1)
Links=Arg1[1,Laenge-1]
Hyro=SEQ(Arg1[1])

BEGIN CASE
CASE Hyro >= 65 AND Hyro <= 73; Ans=(Links:Hyro-64)+0
CASE Hyro >= 74 AND Hyro <= 82; Ans=(Links:Hyro-73)*-1
CASE Hyro=249 ; Ans=(Links:"0")+0
CASE Hyro=166 ; Ans=(Links:"0")*-1
CASE Hyro=228 ; Ans=(Links:"0")+0
CASE Hyro=252 ; Ans=(Links:"0")*-1
CASE Hyro >= 48 AND Hyro <= 57; Ans=( Links:Hyro-48 )+0
CASE @TRUE ; Ans=@NULL
END CASE

RETURN(Ans)

thank you very much WoMaWil. I created a Routine with above code. and when I converted

SwitchEBCDICSign(001690D) =16904
SwitchEBCDICSign(000845B) =8452

But the Routine is not returning any thing for below values.

SwitchEBCDICSign(000770{) = null
SwitchEBCDICSign(011250{) = null

Lately, tried to convert the incoming S9(5)V99 with DataTypePicComp3V99().But this function returning a value like "30303012345.57".But I think, this value should be like "30303.57"(Number(5,2)), as incoming field is of S9(5)V99.I guess, S9(5)V99 = Decimal(5,2). Some one please correct me if I am wrong.

DSSIDDU, thanks for the reply. I do not have .cfd. I have lot of source fields. Can we define them in CFF stage manually?

thanks in advance,
Thank you,
Anu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's probably easier to create a CFD manually (in Notepad perhaps), import that, and proceed with using a CFF stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

ray.wurlod wrote:It's probably easier to create a CFD manually (in Notepad perhaps), import that, and proceed with using a CFF stage.
thanks Ray.

I am new to cobol file. Could you please guide me in creating CFD? or jus through some light on how CFD looks like...

thanks in advance,
Thank you,
Anu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you're unfamiliar with COBOL I'm afraid a full explanation would not make any sense. Basically, CFD stands for "COBOL File Definition", which is a file containing metadata - in a particular format - that describe the data in some other, data, file. COBOL uses a concept called "levels" to represent structured data, and uses a number of "COMP" (computational) data types to represent packed decimal data. It is these with which you are trying to deal.

Maybe using Wolfgang's routine, or an appropriate modification of it, will be better for you. I had assumed, since you were working with COBOL data, that you were COBOL-"literate".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Hi,

To fill my needs more precisely I wrote my own version of the SwitchEBCDICSign.

Function SwitchEBCDICSign(Montant)

LMontant=Trim(Montant)
Longeur=len(LMontant)
Lien=LMontant[1,Longeur-1]
Car=SEQ(Right(LMontant,1))
if num(LMontant) then Ans=LMontant
else
* Call DSLogInfo("Montant ":LMontant,"TRACE")
* Call DSLogInfo("Longeur ":Longeur,"TRACE")
* Call DSLogInfo("Lien ":Lien,"TRACE")
* Call DSLogInfo("1car ":LMontant[1],"TRACE")
* Call DSLogInfo("Car ":Car,"TRACE")
Begin CASE
* Entre A et I
CASE Car >= 65 AND Car <= 73
Ans=(Lien:Car-64)+0
* Entre J et R
CASE Car >= 74 AND Car <= 82
Ans=(Lien:Car-73)*-1
* Cf Ascii Etendue
CASE Car=249
Ans=(Lien:"0")+0
* Cf en Ascii Etendue
CASE Car=166
Ans=(Lien:"0")*-1
* {
CASE Car=123
Ans=(Lien:"0")*-1
* }
CASE Car=125
Ans=(Lien:"0")*-1
* Cf en Ascii Etendue
CASE Car=228
Ans=(Lien:"0")+0
* Cf en Ascii Etendue
CASE Car=252
Ans=(Lien:"0")*-1
* Entre 0 et 9
CASE Car >= 48 AND Car <= 57
Ans=( Lien:Car-48 )+0
* Autre cas
CASE @TRUE
Ans=@NULL
END CASE
end
RETURN(Ans)
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

thurmy34 wrote:Hi,

To fill my needs more precisely I wrote my own version of the SwitchEBCDICSign.

Function SwitchEBCDICSign(Montant)

LMontant=Trim(Montant)
Longeur=len(LMontant)
Lien=LMontant[1,Longeur-1]
Car=SEQ(Right(LMontant,1))
if num(LMontant) then Ans=LMontant
else
* Call DSLogInfo("Montant ":LMontant,"TRACE")
* Call DSLogInfo("Longeur ":Longeur,"TRACE")
* Call DSLogInfo("Lien ":Lien,"TRACE")
* Call DSLogInfo("1car ":LMontant[1],"TRACE")
* Call DSLogInfo("Car ":Car,"TRACE")
Begin CASE
* Entre A et I
CASE Car >= 65 AND Car <= 73
Ans=(Lien:Car-64)+0
* Entre J et R
CASE Car >= 74 AND Car <= 82
Ans=(Lien:Car-73)*-1
* Cf Ascii Etendue
CASE Car=249
Ans=(Lien:"0")+0
* Cf en Ascii Etendue
CASE Car=166
Ans=(Lien:"0")*-1
* {
CASE Car=123
Ans=(Lien:"0")*-1
* }
CASE Car=125
Ans=(Lien:"0")*-1
* Cf en Ascii Etendue
CASE Car=228
Ans=(Lien:"0")+0
* Cf en Ascii Etendue
CASE Car=252
Ans=(Lien:"0")*-1
* Entre 0 et 9
CASE Car >= 48 AND Car <= 57
Ans=( Lien:Car-48 )+0
* Autre cas
CASE @TRUE
Ans=@NULL
END CASE
end
RETURN(Ans)

thanks Ray. I will look for alternative. I have requested for .cfg file. Thanks for the code thurmy34.
Thank you,
Anu
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Hi,

Does anyone interested by a new version of the SwitchEBCDICSign routine ?
patrickmn10
Participant
Posts: 16
Joined: Fri Apr 28, 2006 1:01 pm

Post by patrickmn10 »

Hi,

Could you please send new version of SwitchEBCDICSign to patrickmn10@yahoo.com, Also let me know what values did u test, give me some examples of that.

thanks
Chuah
Participant
Posts: 46
Joined: Thu May 18, 2006 9:13 pm
Location: Melbourne

Post by Chuah »

thurmy34 wrote:Hi,

Does anyone interested by a new version of the SwitchEBCDICSign routine ?
Hi,
Yes would be most interested. Can you please send the routine to jnguy@bigpond.net.au

Thanks,
Nick
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Hi All

If you were instered by the SwitchEBCDICSign function take a look a t this topic
viewtopic.php?t=101163

Maybe it's better to use the sdk ?

I will try this myself ang keep you posted.

Regards
Post Reply