>We are in the process of moving from a mainframe to a dual P.C. server solution for some of our systems. Most of the files we receive are mainframe EPCDIC files in a standard format that we are able to convert to ascii before we slice and dice them to process the transactions.
>
>However, we have one file that has comp-3 values that is giving us a lot of grief. Does anyone have experience in 'deconverting' a file with comp-3 values to an ascii format? If so, I'd appreciate any relevant information you'd be able to share.
>
>Thanks, Al
The parameter should be passed as a string. An integer is returned, because the BCD packed data don't have any inherent decimal position - it's up to the software which reads/writes. This also means you don't have any idea where it goes unless you have source or apply WAG euristics :)
Func Bcd2Num
para bcd
priv x
x=''
#define tbl1 ':;<=>?'
#define tbl2 'abcdef'
for i=1 to len(bcd)
_asc = asc(subs(bcd,i))
x=x+chr(bshr(_asc,4)+48)+chr(band(_asc,15)+48)
endf
x=chrtran(x,tbl1,tbl2)
retu val(left(x,len(x)-1)) * iif(inlist(right(x, 1),'c','f'),1,-1)
This means, If I remember these Cobol types well, comp-3 should be a BCD packed, right? I remember there was some bcd-6 which was a 6-byte integer. Well, HTH.