Exporting to ebcdic file

  • Thread starter Thread starter Mantok
  • Start date Start date
M

Mantok

I need to generate an ebcdic file (with different record
formats.)
I don't want to create a table then use the advance button
on the export function to create my file.

Is there a way to create an ebcdic file using OPEN
filename AS #1; PRINT #1 ?
Or using OUTPUTTO?
Or maybe even using a STREAM; with the CHARSET property?
 
Hi Mantok,

I need to generate an ebcdic file (with different record
formats.)

Does this just involve a straight conversion of character sets (i.e. all
data is text or text representations of numeric values), or does it also
involve generating packed numeric formats?
I don't want to create a table then use the advance button
on the export function to create my file.

How about creating a query instead (though AFAIK this won't help with
the packed numbers)?
Is there a way to create an ebcdic file using OPEN
filename AS #1; PRINT #1 ?

Only by generating the appropriate streams of bytes in your code and
printing them to the file. There are some character tables and sample
code at http://www.room42.com/store/computer_center/code_tables.shtml -
but remember that just as there are many Windows character sets there
are many variants of EBCDIC, and once you get outside the basic
"typewriter" characters mapping between them can become rather fraught.
Google will find much more information for you.
Or using OUTPUTTO?
No.

Or maybe even using a STREAM; with the CHARSET property?

AFAIK, only if the relevant EBCDIC variant is listed at
HKEY_CLASSES_ROOT\MIME\Database\Charset (and I only learnt that by
looking in Help<g>).
 
I could use a query. How do I write to a file?
-----Original Message-----


Does this just involve a straight conversion of character sets (i.e. all
data is text or text representations of numeric values), or does it also
involve generating packed numeric formats?
 
Something like this:

1) Create a query that returns the fields you want.

2) Use File|Export and export the query to a fixed width text file.
Click the Advanced... button in the text export wizard and set up an
export specification with the field widths and EBCDIC character set.
Save the specification.

3) Then use DoCmd.TransferText with the saved export specification.
 
My problem is that I am sending to an IBM machine.
I need to format my file with header and trailer record that
I can easily do the whole file by using a function within a module (which i
call from a macro.)
Function CreateGLStuff()
Open "\Programming\ARHERE" & Format(DATE, "mmddyy") & ".txt" For Output As #2
Dim FileDAte, Dataline As String
Dim Count As Integer
Dim Summary1, Summary2, Datefield As String
Dim data As Currency
Dim strSQL As String
Dim db As Database
Dim SS As Snapshot
strSQL = "SELECT * FROM tblMyTable " ' WHERE Account = '" & strAcctNum & "'"
Set db = CurrentDb()
Set SS = db.CreateSnapshot(strSQL)
Count = 0
FileDAte = Trim$(Format$(DATE, "yymmdd"))
Print #2, "$$DIR ID=Garbage" ' First Line
Print #2, "$$ADD ID=Garbage BID='MOREJUNK'" ' Second Line
SS.MoveFirst
Print #2, "WRTHIS" & " " & Format$(Val(SS("Account")), "0000000000") 'Third Line
Do While Not SS.EOF
CHKAMT = CHKAMT + Nz(SS("AMOUNT"), 0)
Dataline = Format$(Val(SS("Number")), "0000000000") + Format$(SS("Date"), "mmddyy") + Format$(Val(SS("Account")), "0000000000") + >Format$(Val(SS("TransCode")), "000") + Format$(SS("AMOUNT"), "0000000000") ' + Format$(SS("OPTIONAL"), "000000000000")
Print #2, Dataline
SS.MoveNext
Count = Count + 1
Loop

Summary1 = "&" + Space$(14) + Format$(Count, "00000") + Space$(3) + >Format$(FIELD1, "0000000000")
Print #2, Summary1
Print #2, "\\\\\\" + Format$(Count + 3, "0000000")
Close #2

End Function

But I also need to send it in a EBCDIC format.
 
A web search will find you an ANSI<->EBCDIC conversion table, if not
actual conversion functions. Then just convert each string to EBCDIC
before passing it to the Print # statement.

(That assumes that - as you said earlier - the required file is plain
EBCDIC text and does not contain packed numeric fields.)
 
Back
Top