Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Packed Decimals
Message
From
07/12/2004 03:00:08
 
 
To
06/12/2004 22:35:24
Joel Hokanson
Services Integration Group
Bellaire, Texas, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00967378
Message ID:
00967388
Views:
22
>Does anyone know how to convert data in a packed decimal field to a standard numeric field.
>
>THe data file is an FTP download off a IBM Mainframe and the data was in DB2
>
>All of the file converts to standard ASCII text except the packed decimal field.


Joel,

I've used this to read as400 data
*--------------------------------------------------------------------------
function	PackedDecimalToNumber(xx)

	local zz
	zz = ath(m.xx)
	assert inlist(right(m.zz,1), 'D', 'F')
	
	return iif(right(m.zz,1) == 'D', -val(left(m.zz,len(m.zz)-1)), val(left(m.zz,len(m.zz)-1)) )
endfunc
*--------------------------------------------------------------------------
function	ath(x)
	local out, i
	out = ''
	for i = 1 to len(m.x)
		out = m.out + right(transform(asc(substr(m.x,m.i,1)),'@0'),2)
	endfor
	return	out
endfunc
*---------------------------------------------------------------------
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform