Page 1 of 1

Cobol data file

Posted: Tue Apr 04, 2006 8:29 pm
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,

Posted: Wed Apr 05, 2006 12:48 am
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)

Posted: Wed Apr 05, 2006 1:34 am
by dssiddu
hi

u can use complex flat file.

Posted: Wed Apr 05, 2006 7:23 am
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.

Posted: Wed Apr 05, 2006 9:30 am
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,

Posted: Wed Apr 05, 2006 4:03 pm
by ray.wurlod
It's probably easier to create a CFD manually (in Notepad perhaps), import that, and proceed with using a CFF stage.

Posted: Wed Apr 05, 2006 6:59 pm
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,

Posted: Wed Apr 05, 2006 11:57 pm
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".

Posted: Thu Apr 06, 2006 3:29 am
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)

Posted: Thu Apr 06, 2006 9:48 am
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.

Posted: Tue May 23, 2006 4:04 am
by thurmy34
Hi,

Does anyone interested by a new version of the SwitchEBCDICSign routine ?

Posted: Tue May 23, 2006 11:58 am
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

Posted: Sun May 28, 2006 8:12 pm
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

Posted: Wed Jun 07, 2006 2:25 am
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