Alpha Video Training
Page 1 of 2 12 LastLast
Results 1 to 30 of 34

Thread: Export a fixed length file

  1. #1
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default Export a fixed length file

    Hi all

    I want to export a file to our accounts package (Sun Accounts) but the file format is very specific it is as follows
    Field Name Field Lenght
    Account No , 15
    period , 7
    invoice date ,10 "yyyymmdd+2
    a field , 15 (always M)
    net value , 18 (no decimal place 28.20 = 2820
    Debit , 2 (always D)
    a field , 5 (always "captn")
    a field , 15 (always "captn")
    invoice No , 15
    invoice , 25 (always word invoice)
    todays date , 8 "yyyymmdd"
    period , 251

    This is then repeated for our vat total

    The report is by ACCOUNT, DEPOT , NOMINAL CODE

    Has any body any idea how i can produce the file


    kind regards

    Andy

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Need a sample table

    This can be done fairly easily. Attach a sample and I'll work something up.

    I am attaching an example of a table approximately matching your specification and a script that will export the data to a file named test.txt in your c:\ root directory.

    Your description of the fields is somewhat vague and includes a duplication (2 fields named period with different lengths).

    Pay no attention to the database name. Just re-using something old.


    Quote Originally Posted by andymeer@yahoo.co.uk
    Hi all

    I want to export a file to our accounts package (Sun Accounts) but the file format is very specific it is as follows
    Field Name Field Lenght
    Account No , 15
    period , 7
    invoice date ,10 "yyyymmdd+2
    a field , 15 (always M)
    net value , 18 (no decimal place 28.20 = 2820
    Debit , 2 (always D)
    a field , 5 (always "captn")
    a field , 15 (always "captn")
    invoice No , 15
    invoice , 25 (always word invoice)
    todays date , 8 "yyyymmdd"
    period , 251

    This is then repeated for our vat total

    The report is by ACCOUNT, DEPOT , NOMINAL CODE

    Has any body any idea how i can produce the file


    kind regards

    Andy
    Last edited by Stan Mathews; 03-28-2006 at 02:24 PM.

  3. #3
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    I will attach a sample of my main table where i would get the data from,

    I do not have a sample of the export file as i am at home at the moment but I will get it to you tomorrow

    The file that sun accounts requires does have the duplicate fields, the original program was written in Pick now D3 and i am trying to copy the layout so that it will import into our sun package.

    Stan i have not attached a single part of my dbase before which file extension would you need

    I will try your example and let you know how i get on

    Andy

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    Quote Originally Posted by andymeer@yahoo.co.uk
    I will attach a sample of my main table where i would get the data from,
    - That's all I need.

    Quote Originally Posted by andymeer@yahoo.co.uk
    I do not have a sample of the export file as i am at home at the moment but I will get it to you tomorrow
    - Don't need that if the specification earlier is correct regarding field types and widths, but it couldn't hurt.

    Quote Originally Posted by andymeer@yahoo.co.uk
    The file that sun accounts requires does have the duplicate fields, the original program was written in Pick now D3 and i am trying to copy the layout so that it will import into our sun package.
    - but your table can't have duplicate field names so I couldn't write the export without knowing them.

    Quote Originally Posted by andymeer@yahoo.co.uk
    Stan i have not attached a single part of my dbase before which file extension would you need
    - Just the main .dbf.

  5. #5
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    Please find my cons table attached,

    but your table can't have duplicate field names so I couldn't write the export without knowing them
    The fields Period for 7 I was thinking that i could set this with a var the format is 060 for period 6

    the fields
    captn 5
    captn 15
    m 15
    d 2
    invoice 25

    these are always text so i was thinking that i could write the text "M", "D" etc

    again stan thanks for all your help I was hoping to come to the conference but I am in CA for the 1st to the 20 of june for my wifes sisters wedding but I hope to make it next year and have a chance to meet you

    Andy
    Last edited by andymeer@yahoo.co.uk; 08-13-2006 at 04:34 AM.

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default I'm wrong again.

    I seldom use memo fields so I forget them. I can't open your table alone. Please attach all the cons files zipped into one file.

    Just hilight the table in the control panel, right click and choose zip. All the options on the options tab should be checked.


    Quote Originally Posted by andymeer@yahoo.co.uk
    Hi Stan

    Please find my cons table attached,



    The fields Period for 7 I was thinking that i could set this with a var the format is 060 for period 6

    the fields
    captn 5
    captn 15
    m 15
    d 2
    invoice 25

    these are always text so i was thinking that i could write the text "M", "D" etc

    again stan thanks for all your help I was hoping to come to the conference but I am in CA for the 1st to the 20 of june for my wifes sisters wedding but I hope to make it next year and have a chance to meet you

    Andy

  7. #7
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    Tried as you said, it would not zip error said "you cannot send a table that is secured or bound to a dbase please zip whole table"

    The whole table is 160mb

    So i have selected all the cons table files

    Andy
    Last edited by andymeer@yahoo.co.uk; 08-13-2006 at 04:34 AM.

  8. #8
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    Quote Originally Posted by andymeer@yahoo.co.uk
    Hi Stan

    Tried as you said, it would not zip error said "you cannot send a table that is secured or bound to a dbase please zip whole table"

    The whole table is 160mb

    So i have selected all the cons table files

    Andy
    Ok, now I have the table. Just need to know what fields in the cons table should be exported to what parts of the text file. Like

    Field Name Field Lenght
    Account No , 15 -----------------------------cons.dbf ???? field
    period , 7------------------------------------?????
    invoice date ,10 "yyyymmdd+2----------------etc
    a field , 15 (always M)
    net value , 18 (no decimal place 28.20 = 2820
    Debit , 2 (always D)
    a field , 5 (always "captn")
    a field , 15 (always "captn")
    invoice No , 15
    invoice , 25 (always word invoice)
    todays date , 8 "yyyymmdd"
    period , 251

  9. #9
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan


    Account = Acno
    Period = is not in table but I could put it in
    Invoice date = Invoice_Date
    M is not in table
    net value = Net_Total
    D is not in table
    captn for 5 is not in table
    captan for 15 is not in table
    invoice No = Invoice_No
    "invoice" is not in table
    todays date = not in table
    period = is not in table but I could put it in

    Could I put the fields into the table which could then be exported ?

    Andy

    P.S. it 2300hrs here and i have to be up at 0500, so if there is anything else i will answer in morning

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default On track but...

    Time for me to go home so we can fill in the details tomorrow.


    Period = is not in table but I could put it in
    We can't export data to the text file that doesn't exist. We can fill in things like "invoice" and "captn" but if you want the first "period" section of the text file to be anything other than seven spaces we have to decide where the info will come from. Likewise for the second period section.

    Sleep well.

  11. #11
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Morning Stan

    Our tax year here is from April 1st to March 31st

    So my periods are as so

    April 2006001
    May 2006002
    June 2006003
    July 2006004
    Aug 2006005
    Sept 2006006
    Oct 2006007
    Nov 2006008
    Dec 2006009
    Jan 2007010
    feb 2007011
    Mar 2007012

    What i was thinking is that I could put a case statement on a period field in the table, that way the accountant can report by period?

    Andy
    Last edited by andymeer@yahoo.co.uk; 01-27-2006 at 12:45 AM.

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    That's doable. When you perform the export I suppose the invoice date drives the first period field. What goes in the second where the width is defined as 251?

    Quote Originally Posted by andymeer@yahoo.co.uk
    Morning Stan

    Our tax year here is from April 1st to March 31st

    So my periods are as so

    April 2006001
    May 2006002
    June 2006003
    July 2006004
    Aug 2006005
    Sept 2006006
    Oct 2006007
    Nov 2006008
    Dec 2006009
    Jan 2007010
    feb 2007011
    Mar 2007012

    What i was thinking is that I could put a case statement on a period field in the table, that way the accountant can report by period?

    Andy

  13. #13
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    Quote Originally Posted by Stan Mathews
    That's doable. When you perform the export I suppose the invoice date drives the first period field. What goes in the second where the width is defined as 251?
    We've hit another snag. The fields you mention are not in the cons.dbf. As far as I can tell there are no fields invoice_date, net_total, or invoice_no in any of the tables in what you sent.

    Can't export what we don't have.

  14. #14
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    I have just zipped the table again and opened it locally and my fields

    invoice_date
    invoice_no
    net_value

    are all there please try this one

    Sorry I have not got back sooner but I have been on the road all day

    Andy
    Last edited by andymeer@yahoo.co.uk; 08-13-2006 at 04:34 AM.

  15. #15
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    I may have had an old copy of your table that wasn't getting over written. The attachment will export everything you specified except the last period field in your specification. I have no clue what you want there. It will put 251 spaces at the end of each line.

    I couldn't test the first period field completely as there are no values in the invoice_date field and I couldn't make any changes to any records because the posting field rules couldn't find the needed tables.

    Play with it and we gan go from here.
    Last edited by Stan Mathews; 03-28-2006 at 02:24 PM.

  16. #16
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    File I am copying is attached in the last field that is only period and 251 long is how it is formatted in the attached file.

    Stan I have just been talking and looking at the file and there are four extra fields and the last period fields is different

    second period is for 116
    new field account = Acno for 30
    branch = Col_depot for 15
    W "if branch = 01" for 90
    O is on put on the Nomi code line for 15

    My depot codes are as follows

    col_depot = old = 01
    col_depot = G = 02
    col_depot = ost = 03
    col_depot = mcr = 05
    col_depot = so = 06
    col_depot = be = 07

    Andy

  17. #17
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Sorry Stan

    Missed attachment

  18. #18
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default revised

    From your attachment I think you want the attached script.
    Last edited by Stan Mathews; 03-28-2006 at 02:24 PM.

  19. #19
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Thanks Stan

    I will try it tomorrow and let you know how it goes

    Andy

  20. #20
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    Please find attached my revised script it now matches the original in respect of the lenght and orientation of each field,

    If I look at the original file "trans" what it does is total the field net_value for a account "acno", then within the account sums each field with the nomi code for each nomi code. each total goes on a new line the only diferance is that instead of a "D" for debit as on the account line there is a "C" for credit and the Account becomes the nominal code,

    We have a tax here called VAT which the nominal code is 9350 for this line in the file we have to total the vat field this is also within the account

    I dont think I have explained that very well

    I will attach a summary operation to the dbase and call it stan for you to look at, the results are in a table dc00003

    Andy
    Last edited by andymeer@yahoo.co.uk; 08-21-2006 at 02:36 PM.

  21. #21
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Out of touch til Monday

    Andy,

    I'll give it a look sometime Monday.

    Stan
    Quote Originally Posted by andymeer@yahoo.co.uk
    Hi Stan

    Please find attached my revised script it now matches the original in respect of the lenght and orientation of each field,

    If I look at the original file "trans" what it does is total the field net_value for a account "acno", then within the account sums each field with the nomi code for each nomi code. each total goes on a new line the only diferance is that instead of a "D" for debit as on the account line there is a "C" for credit and the Account becomes the nominal code,

    We have a tax here called VAT which the nominal code is 9350 for this line in the file we have to total the vat field this is also within the account

    I dont think I have explained that very well

    I will attach a summary operation to the dbase and call it stan for you to look at, the results are in a table dc00003

    Andy

  22. #22
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    thanks Stan

    Andy

  23. #23
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    Hope you had a good weekend

    One other thing I have seen on the file on the nominal code line its total by nominal code by depot

    ie
    dp10360
    1010 old = 01
    1010 ost = 02


    Andy

  24. #24
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    Here is my Latest version It nearly does everything i want

    The only Problem i have is does not start a new Account but it runs through there nominal codes and vat codes

    I know its a problem with my if statement but i am not sure how to put it right

    Andy

  25. #25
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    I have come up against another problem

    The two lines of the file write should write the total invoice value and the total vat value

    fil.write_line(padr(alltrim(tbl.acno),15," ") +var->pd+cdate(tbl.first_invoice_date)+" "+"M "+(padr(remspecial(str(tbl.total_Net_total,12,2,"")),18," "))+"D "+"captn"+"captn"+padr(remspecial(str(tbl.first_invoice_no,15,0,"")),15," ")+"invoice "+cdate(date())+var->pd+space(154))+crlf()
    fil.write_line("9350 " +var->pd+cdate(tbl.first_invoice_date)+" "+"M "+(padr(remspecial(str(tbl.total_vat,12,2,"")),18," "))+"c "+"captn"+"captn"+padr(remspecial(str(tbl.first_invoice_no,15,0,"")),15," ")+"invoice "+cdate(date())+var->pd+space(244)+padr("O",15," "))+crlf()

    And the third line would be the nominal code value writes the nominal codes for the invoice

    The problem I have is that in the sumarize it has not got sub groups, so the first total would be total for the invoice/ account and vat total.

    and the sub group would be nominal code

    Andy
    New script attached

  26. #26
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default I'm lost.

    Here's my alteration of the andyscript2 file. You had two issues as I saw them.

    The section

    Code:
    newaccount:
    DIM SHARED account AS c
    account = tbl.eval("acno")
    occurred before the tbl.fetch_first() so it was looping back to the very beginning instead of starting at the next record. Move this after the tbl.fetch_first().

    The section

    Code:
    DIM SHARED account AS c
    		account = tbl.eval("acno")
    		
    		IF account = account THEN
    			goto sameaccount else
    			goto newaccount
    		END IF
    has the problem that account = account will always be true. This should probably be something like

    Code:
    DIM SHARED naccount AS c
    		naccount = tbl.eval("acno")
    		
    		IF naccount = account THEN
    			goto sameaccount else
    			goto newaccount
    		END IF
    Past that I am lost in all your discussions of summarizing, totals, etc.

    Hope this gets you back on the right track.

    Stan

  27. #27
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    If I could just go over again what i am trying to achieve then maybe you could give me an idea of the way i should go about it

    in the table i have the fields total_cost, Vat, Net_value

    For the Account line in the file I am trying th produce I want a total of net_value for a invoice No and a total of Vat (this is for all the consignments for any given invoice)

    The nomi code line in the file is the total_cost for each nominal code( this is for the given invoice)

    so my file would end up like below

    DP10360 TOTAL OF NET_VALUE
    9350 TOTAL OF VAT
    1010 TOTAL OF TOTAL_COST = TO 1010
    1020 TOTAL OF TOTAL_COST = TO 1020
    DA00017 TOTAL OF NET_VALUE
    9350 TOTAL OF VAT
    1010 TOTAL OF TOTAL_COST = TO 1010
    1020 TOTAL OF TOTAL_COST = TO 1020
    DA00020 TOTAL OF NET_VALUE
    9350 TOTAL OF VAT
    1010 TOTAL OF TOTAL_COST = TO 1010
    1020 TOTAL OF TOTAL_COST = TO 1020


    I hope this makes a little more sense of what i am trying to achieve

    Andy

  28. #28
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    Quote Originally Posted by andymeer@yahoo.co.uk
    Hi Stan

    If I could just go over again what i am trying to achieve then maybe you could give me an idea of the way i should go about it

    in the table i have the fields total_cost, Vat, Net_value

    For the Account line in the file I am trying th produce I want a total of net_value for a invoice No and a total of Vat (this is for all the consignments for any given invoice)

    The nomi code line in the file is the total_cost for each nominal code( this is for the given invoice)

    so my file would end up like below

    DP10360 TOTAL OF NET_VALUE
    9350 TOTAL OF VAT
    1010 TOTAL OF TOTAL_COST = TO 1010
    1020 TOTAL OF TOTAL_COST = TO 1020
    DA00017 TOTAL OF NET_VALUE
    9350 TOTAL OF VAT
    1010 TOTAL OF TOTAL_COST = TO 1010
    1020 TOTAL OF TOTAL_COST = TO 1020
    DA00020 TOTAL OF NET_VALUE
    9350 TOTAL OF VAT
    1010 TOTAL OF TOTAL_COST = TO 1010
    1020 TOTAL OF TOTAL_COST = TO 1020


    I hope this makes a little more sense of what i am trying to achieve

    Andy
    I think I have the picture now. The attachment should do what you want.
    Last edited by Stan Mathews; 03-28-2006 at 02:24 PM.

  29. #29
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default

    Quote Originally Posted by Stan Mathews
    I think I have the picture now. The attachment should do what you want.
    I commented out the summarization routine for testing. Attached is the un-commented out -real- script.
    Last edited by Stan Mathews; 03-28-2006 at 02:24 PM.

  30. #30
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default

    Hi Stan

    The Total off the VAT, & NET_TOTAL fields

    I want to do the same as the VAT & NET_TOTAL, on the total_charge field but giving me all the totals of the nominal code fields for each depot so I think it should be BY ACCOUNT,BY COL_DEPOT BY NOMI_CODE,
    Thanks again Stan
    Andy
    Last edited by andymeer@yahoo.co.uk; 01-30-2006 at 02:09 PM.

Similar Threads

  1. export fixed
    By Steve Wood in forum Alpha Five Version 7
    Replies: 12
    Last Post: 08-03-2006, 10:47 PM
  2. Export to text file
    By johnm in forum Alpha Five Version 6
    Replies: 11
    Last Post: 06-28-2005, 05:24 AM
  3. How to Export a file in After Validate?
    By LTinPB in forum Web Application Server v6
    Replies: 2
    Last Post: 06-10-2005, 08:36 AM
  4. How to create Export File....
    By mronck in forum Alpha Five Version 5
    Replies: 11
    Last Post: 10-24-2004, 05:37 AM
  5. character lenght
    By lkatz1 in forum Alpha Five Versions 2 and 3
    Replies: 4
    Last Post: 10-31-2001, 02:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •