A critical piece for EDI processing and general document processing in fielPro

John Esak john at valar.com
Wed Jun 28 12:21:19 PDT 2006



Hello all,

Well, as you know already the FilePro Survivor Series Quarterly CD's
I owed you alll are out the door.  They are chock full of little tidbits
and sometimes even nice big comlete min-applications.  Like the one
I'm putting up here. This is a nifty app that came up a few weeks ago in
the FP Room. Nancy Palmquist mentioned she was storing a lot of files,
and I suggested she not put them all in one directory, but parcel them
out to an organized archive. After a bit I sent her a version of the
following table. Since then, no less than 3 more people came into the
room asking about almost exactly the same thing, so I sent it to them
also. Since this process is on one of the Quarterly CD's I don't see
any reason why I shouldn't make it available to everyone. There are a
few more Survivor Series Version 1 sets still available and buyers
will get all the Quarterlies from that... even the $275 special which
now has only two days to go!

Meanwhile, this is a really great processing table. If you do any EDI
transaction of business, you *NEED* something like this... exactly this....
Why? What does it do? Essentially, it takes the documents you receive
each day and stores them in a dated archive tree. For example, if I get
an invoice document in today... it would store the incoming document
*automatically* into:

/tmp/EDI/archive/inv/in/06/06

That is, it puts it in an arvhive folder for "incoming" documents dated June
of
2006. On Saturday, when we recieve any invoice documents, it will put them
into

/tmp/EDI/archive/inv/in/06/07

meaning it will create the July (or 07) directory automaticdally. If this
were
December going into January... on January 1st it would create the 07 year
directory automatically and then create the January directory or 07/01.

Once an invoice is archived and processed, you might (must) send out an
acknowledgement document. This process does that also, creating a full
hierarchy of directories until it gets down to:

/tmp/EDI/archive/inv/out/06/06

and then it places the date_and_batched stamped document here.

It is all very simple... but absolutely reliable in its operation. You
must be able to rely on these things... EDI documents must be kept on file
for 7 years by law.

In any case, here is one complete method for doing this absolutely necessary
operation. There's much more to learn about EDI... but here is a critical
function you won't have to re-invent the wheel to get.

I'm going to put up the "movie" from the Survivor Quarterly CD so you
can hear the detailed description of how the table actually works, too.

Here is the link... but it may not be up there until about 3pm today.

Have fun. (By the way, below the table is a colon-delimitd version you can
cut and paste into a prc.table. And please NOTE, only by watching the movie
on the CD or streamed from the net can you see the detailed description of
the flepro "batch"  file which helps this work so nicely. Sorry.


         If: '
    1  Then: 'EVERYTHING HINGES ON THE qual VARIABLE in @once
         If: 'There is no INPUT processing, everything starts at @once
    2  Then: 'There is no INPUT processing,  everything starts at @once
    3  Then: END
@once    If: '@once
    4  Then:
    5  Then: declare qual(7)
         If: 'this can be set with a getenv("some variable") or just grab
@qu
    6  Then: qual="test"       'for this test, just hardcoding it
         If: @pm eq "special" or @pm eq "john"
    7  Then: qual="test"
    8  Then: declare lkup_file, daybatch(2,0rj)
    9  Then: lkup_file="daybatch"
   10  Then: lookup dayb=(lkup_file) k=@td i=A -nxp
         If: not dayb
   11  Then: lookup dayb=(lkup_file) r=free
   12  Then: dayb(1)=@td;  dayb(2)=dayb(2)+"1";  daybatch=dayb(2);  write
dayb
   13  Then: declare Incoming_File
         If: 'this can be set to "po_infile.dat" for a po processing table
   14  Then: Incoming_File="inv_infile.dat"
         If: 'default to a Unix style separator
   15  Then: declare sls(1);  sls=chr("47")  'the / between directories
         If: @os eq "DOS"                    'change it to a backslash if
DOS
   16  Then: sls=chr("92")                     'the \ between folders
   17  Then: declare DirShare, DirArc, DirIn, DirOut, DirCat
   18  Then: declare DirArcIn, DirArcOut
         If: 'sometimes the main directory can be a share on a server
   19  Then: DirShare="/tmp/EDI"
         If: @os eq "DOS"
   20  Then: DirShare="C:\\EDI"
   21  Then: DirIn="in";  DirOut="out"; DirArc="archive"
         If: 'set the document category: invoice 810, or po 850
   22  Then: DirCat="inv"
   23  Then: DirArcIn=DirShare { sls { DirArc { sls { DirCat { sls { DirIn
   24  Then: declare InDate(6,ymd)
   25  Then: InDate=@td
   26  Then: declare Year(2),  Month(2)
   27  Then: Year=mid(InDate,"1","2");  Month=mid(InDate,"3","2")
   28  Then: declare DirYear, DirMonth
   29  Then: DirYear=DirArcIn { sls { Year
   30  Then: DirMonth=DirYear { sls { Month
         If: 'test the dirs for the incoming_file date
   31  Then: gosub mk_dirs
   32  Then: declare InStamp, ArcFile, FullPath1, FullPath2
   33  Then: InStamp=InDate { "_" { daybatch
   34  Then: ArcFile=InStamp { "_" { incoming_file
   35  Then: FullPath1=DirShare { sls { Incoming_File
   36  Then: FullPath2=DirMonth { sls { Arcfile
   37  Then: declare SysCommand
   38  Then: SysCommand="cp" < FullPath1 < FullPath2
         If: @os eq "DOS"
   39  Then: SysCommand="copy" < FullPath1 < FullPath2
   40  Then: system noredraw SysCommand
   41  Then: '
   42  Then: 'Here you do intricate and amzing things with the source
file....
   43  Then: 'In many cases sending a response or acknowledgment file
   44  Then: 'Then you will want to put that out file into the
archive/outbox
   45  Then: 'Let's say that in the amazing and dazzling code above you
create
   46  Then: 'a response file called ack.997.dat
   47  Then: 'Simply use the same stuff to archive that file as well...
   48  Then: 'Just construct the directory and filenames for the outbox
   49  Then: declare ack_outfile;  ack_outfile="ack_997.dat"
   50  Then: DirArcOut=DirShare { sls { DirArc { sls { DirCat { sls { DirOut
   51  Then: DirYear=DirArcOut { sls { Year
   52  Then: DirMonth=DirYear { sls { Month
         If: 'test the dirs for the ack.outfile
   53  Then: gosub mk_dirs
   54  Then: ArcFile=InStamp { "_" { ack_outfile
   55  Then: FullPath1=DirShare { sls { ack_outfile
   56  Then: FullPath2=DirMonth { sls { Arcfile
   57  Then: SysCommand="cp" < FullPath1 < FullPath2 < "2>/tmp/error"
         If: @os eq "DOS"
   58  Then: SysCommand="copy" < FullPath1 < FullPath2 < "2>/tmp/error"
   59  Then: system noredraw SysCommand
         If: 'end of @once and the entire process
   60  Then: EXIT
   61  Then: '
mk_dirs  If: 'mk_dirs         'checks to see if the year and month dirs
   62  Then: 'exist for the incoming_file date
tstYR    If: exists(DirYear) eq "1"
   63  Then:
tstMO    If: exists(DirMonth) eq "1"
   64  Then:
         If: 'If either Year directory or Month directory does not exist.
   65  Then: 'create them. Sometimes just Month, sometimes both Year and
Month
         If: 'the -p flag to mkdir creates subdirectories needed
   66  Then: 'Windows (DOS) does not need this. (Don't know the flag for
Linux
         If: 'the subdir flag is only required the first time the process is
   67  Then: 'ever run... to create the "archive/inv/in[out] dirs
   68  Then: declare subdir_flag, err
         If: @os ne "DOS"
   69  Then: subdir_flag="-p";  err="2>/dev/null"
         If: @os eq "DOS"
   70  Then: err="2>NUL"
         If: not tstYR
   71  Then: system noredraw "umask 077;mkdir" < subdir_flag < DirYear < err
         If: not tstMO
   72  Then: system noredraw "umask 077;mkdir" < DirMonth < err
   73  Then: return



:':'EVERYTHING HINGES ON THE qual VARIABLE in @once:
:'There is no INPUT processing, everything starts at @once:'There is no
INPUT pr
ocessing,  everything starts at @once:
::END:
@once:'@once::
::declare qual(7):
:'this can be set with a getenv("some variable") or just grab
@qu:qual="test"
    'for this test, just hardcoding it:
:@pm eq "special" or @pm eq "john":qual="test":
::declare lkup_file, daybatch(2,0rj):
::lkup_file="daybatch":
::lookup dayb=(lkup_file) k=@td i=A -nxp:
:not dayb:lookup dayb=(lkup_file) r=free:
::dayb(1)=@td;  dayb(2)=dayb(2)+"1";  daybatch=dayb(2);  write dayb:
::declare Incoming_File:
:   'this can be set to "po_infile.dat" for a po processing
table:Incoming_File=
"inv_infile.dat":
:                                'default to a Unix style separator:declare
sls(
1);  sls=chr("47")  'the / between directories:
:@os eq "DOS"                    'change it to a backslash if
DOS:sls=chr("92")
                    'the \ between folders:
::declare DirShare, DirArc, DirIn, DirOut, DirCat:
::declare DirArcIn, DirArcOut:
:       'sometimes the main directory can be a share on a
server:DirShare="/tmp/
EDI":
:@os eq "DOS":DirShare="C^A\\EDI":
::DirIn="in";  DirOut="out"; DirArc="archive":
:     'set the document category^A invoice 810, or po 850:DirCat="inv":
::DirArcIn=DirShare { sls { DirArc { sls { DirCat { sls { DirIn:
::declare InDate(6,ymd):
::InDate=@td:
::declare Year(2),  Month(2):
::Year=mid(InDate,"1","2");  Month=mid(InDate,"3","2"):
::declare DirYear, DirMonth:
::DirYear=DirArcIn { sls { Year:
::DirMonth=DirYear { sls { Month:
:'test the dirs for the incoming_file date:gosub mk_dirs:
::declare InStamp, ArcFile, FullPath1, FullPath2:
::InStamp=InDate { "_" { daybatch:
::ArcFile=InStamp { "_" { incoming_file:
::FullPath1=DirShare { sls { Incoming_File:
::FullPath2=DirMonth { sls { Arcfile:
::declare SysCommand:
::SysCommand="cp" < FullPath1 < FullPath2:
:@os eq "DOS":SysCommand="copy" < FullPath1 < FullPath2:
::system noredraw SysCommand:
::':
::'Here you do intricate and amzing things with the source file....:
::'In many cases sending a response or acknowledgment file:
::'Then you will want to put that out file into the archive/outbox:
::'Let's say that in the amazing and dazzling code above you create:
::'a response file called ack.997.dat:
::'Simply use the same stuff to archive that file as well...:
::'Just construct the directory and filenames for the outbox:
::declare ack_outfile;  ack_outfile="ack_997.dat":
::DirArcOut=DirShare { sls { DirArc { sls { DirCat { sls { DirOut:
::DirYear=DirArcOut { sls { Year:
::DirMonth=DirYear { sls { Month:
:'test the dirs for the ack.outfile:gosub mk_dirs:
::ArcFile=InStamp { "_" { ack_outfile:
::FullPath1=DirShare { sls { ack_outfile:
::FullPath2=DirMonth { sls { Arcfile:
::SysCommand="cp" < FullPath1 < FullPath2 < "2>/tmp/error":
:@os eq "DOS":SysCommand="copy" < FullPath1 < FullPath2 < "2>/tmp/error":
::system noredraw SysCommand:
:   'end of @once and the entire process:EXIT:
::':
mk_dirs:'mk_dirs         'checks to see if the year and month dirs:
    'exist for the incoming_file date:
tstYR:exists(DirYear) eq "1"::
tstMO:exists(DirMonth) eq "1"::
:'If either Year directory or Month directory does not exist.:'create them.
Some
times just Month, sometimes both Year and Month:
: 'the -p flag to mkdir creates subdirectories needed: 'Windows (DOS) does
not n
eed this. (Don't know the flag for Linux:
: 'the subdir flag is only required the first time the process is:  'ever
run...
 to create the "archive/inv/in[out] dirs:
::declare subdir_flag, err:
:@os ne "DOS":subdir_flag="-p";  err="2>/dev/null":
:@os eq "DOS":err="2>NUL":
:not tstYR:system noredraw "umask 077;mkdir" < subdir_flag < DirYear < err:
:not tstMO:system noredraw "umask 077;mkdir" < DirMonth < err:
::return:



More information about the Filepro-list mailing list