PDA

View Full Version : EDI Export


ABC123

John Castle
02-23-2005, 08:46 AM
I aim to export from a Purchase Order Header File plus related Purchase Order Lines file the data using the Tradacomms format for sending via the internet to a supplier.

The file format they require looks like this:
STX=STDS+FROM+UNTO+TRDT+SNRF++APRF'
MHD=MSRF+TYPE'
TYP=TCDE+TTYP'
SDT=SIDN'
CDT=CIDN'
FIL=FLGN+FLVN+FLDT'
MTR=NOSG'
MHD=MSRF+TYPE'
CLO=CLOC+CNAM+CADD'
ORD=ORNO++ORCD'
DIN=EDAT+LDAT'
COD=SEQA+SPRO+++UNOR+OQTY+OUCT++TFIN'
DNB=SEQA+SEQB++RTEX'
OTR=LORD'
MTR=NOSG'
MHD=MSRF+TYPE'
OFT=FTOR'
MTR=NOSG'
END=NMST'

Field seperators are + signs, line seperators are '. Some lines of the text above represent the PO header, some the PO line (only 1 shown here) and the final few the PO trailer.

This is one file for the complete PO.

I thought to create a table for each line of text above, export it as text then concatenate all the files into one in the correct order.

However how do I append all the files together?

Or is this there a much better way forward? This is hardly a simple or quick way. The data is more than likely to amount to more than 250 characters in length BTW.

Thanks for any help offered.

John Castle

Stan Mathews
02-23-2005, 12:26 PM
Hey John

Have you ever used any of the low level file methods to write directly to a file? I would approach this by leaving the records alone as they probably are in your set po_header and po_details. The process would consist of

open/create the text file
open set
get pointer1 to header table
get pointer2 to details table
find desired po header range by fetching in set
construct the line to write to the edi text file by using some constant values ("STX=") and some field values (pointer1.po_number+dtoc(pointer1.frm_date)+.....
open/create the text file
write the line
fetch the next record in the set
loop through process
close the set
close the text file

John Castle
02-24-2005, 11:50 PM
Thanks for this - I was looking for the functions to do this in the help files when I saw your post.

This does exactly what I need and avoids multiple export operations for each line then joining together a load of files.

John Castle