Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

export fixed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    export fixed

    I don't see how I can export a table in fixed format, as in something like:

    ..
    export.field1(1,20) = "first_name"
    export.field2(21,20) = "last_name"
    export.field3(41,1) = "gender"
    ..

    Where the values in parens would be (offset, number of characters), and the output would be (sans the dots):

    Steve...............Wood................M
    Nikoo................Arasteh.............F
    Steve Wood
    See my profile on IADN


    #2
    Originally posted by Steve Wood
    I don't see how I can export a table in fixed format, as in something like:

    ..
    export.field1(1,20) = "first_name"
    export.field2(21,20) = "last_name"
    export.field3(41,1) = "gender"
    ..

    Where the values in parens would be (offset, number of characters), and the output would be (sans the dots):

    Steve...............Wood................M
    Nikoo................Arasteh.............F
    An export of character fields to text/ascii will give you that, given the defined width of the fields are as specified (20, 20, 1). I don't think you can specify that the export not be delimited in some manner but careful specification of that delimiter followed by a search and replace should do the trick.

    Numeric fields will follow the same general rule but appear right justified rather than left as you indicate you want.
    Last edited by Stan Mathews; 11-22-2005, 06:38 PM. Reason: Clarification
    There can be only one.

    Comment


      #3
      Thanks, but that's not going to satisfy the requirements. I have to export to SAP! For example, the export can be 2000 chars wide, with literal and field values, etc. I also have to convert decimal values to fixed, such as 100.99 to 00010099, do case conversion (Steve to STEVE), pad numeric strings, strip non-numerics from strings (100ABC200 to 100200), etc. I may also have a field that is 20 chars wide, but has to be exported as 100 chars wide, flush left.
      Steve Wood
      See my profile on IADN

      Comment


        #4
        Steve was asking the question as a followup to a conversation we had earlier today (thanks again for the input, Steve!).

        Unfortunately, many large mainframe systems don't know about delimited files and want fixed record length with the data in fixed positions. For example, my client needs to send employee data to an insurance company, so I have a specification in my hands that looks like this:

        EmployeeID #, Field Position 1-10
        Filler, Position 11
        Control Number, Pos 12-17
        etc, etc.

        and while they've alloted 10 characters for the EmployeeID, we're only using nine. With other products that I've used, you just "paint" the layout (e.g., to position all the fields) and tell the program to create ASCII files and badda bing. Steve and I were kicking around "What's the best way for Alpha to do this?"

        Often the data needs some transformations before it's outputted as well. Some want dates as DDMMYYYY, some want YYYYDDMM (with no "/") and so on.
        Lawrence Fox
        ComputerWizard Consulting
        http://www.computerwizardonline.com
        Bookkeeping, Accounting & Database Design
        "Nobody goes to work for themselves in order to do paperwork--so call the Wizard today and get back to doing what YOU love to do..."

        Comment


          #5
          Both are true, I also need to know for current projects. Here is a real example from DE that I have to duplicate in Alpha with fixed format output, field manipulation and a variable output filename. Its pretty self explanatory. I know I can't use the <tbl>.export() function for this. Its complicated by the last line where, after kicking out one line for each record, it posts a summary as the last line in the ascii file.

          Code:
          define "tAmountTot" number . 
          define "tAmountT"    text 12 .
          define "tAmountTotT" text 12 . 
          define global "gTransDate" text 6 . 
          define global "gMonthText" text 9 .
          define "tDesc" text 29 . 
          tDesc := "TELEPHONE CHARGES" .
          tDesc := jointext(jointext(tDesc,"  "),gMonthText) . -- must be 29 total
          
          for xcSCexportToGLsum ;
          
          -- AMNT DEFINITION
          tAmountT    := blank .
          tAmountT    := NumToText(abs(Amount),"000000000.00") .
          tAmountT    := StrNumbersOnly(tAmountT) .
          --tAmountT    := jointext(tAmountT , if (Amount < 0 ,"-", "+" )) . 
          
          tAmountTot  := tAmountTot + Amount .
          tAmountTotT := NumToText(abs(tAmountTot),"000000000.00") .
          tAmountTotT := StrNumbersOnly(tAmountTotT) .
          --tAmountTotT := jointext(tAmountTotT,"-") .
          
          list records
          
          GLNumber in order ; 
          tAmountT ; 
          gTransDate ;
          tAmountTotT ;
          tDesc . 
          end  .
          
          export to jointext(any CustomerSetup FMSdir , "\DATA\XFMSBILL.CSV") .
          .items
          JE@f[1,1,15]@f[1,2,11]00000000000@f[1,5,29]R000033@f[1,3,6]
          .end
          JE10349055500000000000000000@f[1,4,11]@f[1,5,29]R000033@f[1,3,6]
          Last edited by AaronBBrown; 11-23-2005, 09:47 AM.
          Steve Wood
          See my profile on IADN

          Comment


            #6
            Steve, for this kind of situation I'd look at using <file>.write_line() to create the "export" file one line at a time. You'd preprocess the field values from your source table, storing the results in character type variables. Each would be padded using the space() function to the desired "field" width. Then they'd be concatenated and written to the target file. Loop through all your records and badda bing you're done.

            -- tom

            Comment


              #7
              Originally posted by Steve Wood
              Thanks, but that's not going to satisfy the requirements. I have to export to SAP! For example, the export can be 2000 chars wide, with literal and field values, etc. I also have to convert decimal values to fixed, such as 100.99 to 00010099, do case conversion (Steve to STEVE), pad numeric strings, strip non-numerics from strings (100ABC200 to 100200), etc. I may also have a field that is 20 chars wide, but has to be exported as 100 chars wide, flush left.
              If Tom's solution involves more coding than you want, you could create a temporary table with the number of character fields you want to hold the total required length. IOW for 2000 chaacters you could use seven 255 wide character fields and one 215 wide. Write an append operation that adds records from your "real" table to the temp performing the necessary transformations. Export from the temp table and strip out the commas.

              Not as clean perhaps but involves no xbasic if you manually remove commas, a little if you code that..
              There can be only one.

              Comment


                #8
                One other alternative that I've seen suggested elsewhere (not for Alpha)--
                has anyone tried writing to a text driver and saving to disk? Would this not be the simplest approach?
                Lawrence Fox
                ComputerWizard Consulting
                http://www.computerwizardonline.com
                Bookkeeping, Accounting & Database Design
                "Nobody goes to work for themselves in order to do paperwork--so call the Wizard today and get back to doing what YOU love to do..."

                Comment


                  #9
                  Another thought

                  Originally posted by Stan Mathews
                  If Tom's solution involves more coding than you want, you could create a temporary table with the number of character fields you want to hold the total required length. IOW for 2000 chaacters you could use seven 255 wide character fields and one 215 wide. Write an append operation that adds records from your "real" table to the temp performing the necessary transformations. Export from the temp table and strip out the commas.

                  Not as clean perhaps but involves no xbasic if you manually remove commas, a little if you code that..
                  If you create a temporary table with the same number of fields as your original table but make all of the fields character of the width required by the target recipient and append the records to the temp table making the pad and other conversions needed during the append then this

                  Code:
                  exp_file = ui_get_file("Table to be exported","DBF (*.dbf)","","X")
                  IF exp_file = ""
                  	end
                  END IF
                  wrt_file = ui_get_file("File to be created","TXT (*.txt)","","N")
                  IF wrt_file = ""
                  	end
                  END IF
                  dim tbl as P
                  tbl = table.open(exp_file)
                  fil = file.create(wrt_file,FILE_RW_EXCLUSIVE)
                  number_of_fields = tbl.fields_get()
                  dim fld as P
                  tbl.fetch_first()
                  ln = ""
                  WHILE .NOT. tbl.fetch_eof()
                  	FOR i = 1 TO number_of_fields
                  		fld = tbl.field_get(i)
                  		ln = ln + fld.value_get()
                  	NEXT i
                  	fil.write_line(ln)
                  	ln = ""
                  	tbl.fetch_next()
                  	
                  END WHILE
                  
                  fil.flush()
                  fil.close()
                  tbl.close()
                  will export all of the fields from each record in the chosen temp table without interrupting delimiters.
                  There can be only one.

                  Comment


                    #10
                    Re: export fixed

                    Steve,

                    have you successfully exported to SAP? i was under the impression that alpha couldnt do this.

                    Comment


                      #11
                      Re: export fixed

                      My previous example was not from Alpha, its from DataEase. Ihave not tried to do a fixed length export from Alpha yet. But that (in the time I had to do so) is what SAP expected. I never followed up to try. My request was actually for a newbie friend that was needing an export in that format.

                      So the question is, how to do a fixed length export from Alpha.
                      Steve Wood
                      See my profile on IADN

                      Comment


                        #12
                        Re: export fixed

                        Greetings,

                        I have not done this in A5, but in other RADs I have done things like creating a string (or character blob) with something in the order of ...

                        Code:
                        dim mystring as C
                        
                        mystring = replicate(" ",250)
                        mystring = mystring+mystring+mystring[+mystring to desired length]
                        
                        mystring = stuff(mystring,1,20,"first_name")
                        mystring = stuff(mystring,21,20,"last_name")
                        ...
                        
                        write out mystring...
                        be sure to blank out before next record or...
                        always account for the total length of the field with blank padding...

                        hope this helps...

                        Regards,
                        Keith
                        Keith Weatherhead
                        Discus Data, Ltd
                        [email protected]

                        Comment


                          #13
                          Re: export fixed

                          I must be overlooking something simple and fundamental in the requirements.

                          Alpha's table ascii export operation does fixed length export. If you copy the data to a temporary table with field widths defined as needed in the export, and do an update for data conversions, then the export operation should give what you want. There may be extra fields in the table that are used as the source for the update operation but not actually exported.

                          Bill.

                          Comment

                          Working...
                          X