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

Append operation using Unique - how to get it to work

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

    Append operation using Unique - how to get it to work

    Scenario:
    Multiple bank accounts are monitored throughout the day for deposits and withdrawals to post into various ledgers and customer accounts.
    Clerks log into various banking sites continuously downloading CSVs.
    Administrator using Alpha, periodically selects csvs to update into the system. They may select the same csv as earlier (to ensure picking up added transactions) as well as most recent csvs
    Requirement:
    When bank transactions are collected it must not allow duplicate that transactions, only new entries appearing since last update. The bank systems dont always append to the bank statement, earlier entries picked up later can be inserted before a previous one.

    None of the above is strange or unusual, but I cannot get the append operation to append only unique;
    Determined by fields iDate (c)+ iAmount (n) + idesc (c)
    it either appends nothing or all again
    Simple DB attached. bankcsv.dbf must update to banks_imported,dbf.
    Then Add a or alter a transaction with an amount in bankcsv.dbf. Update again and only the new transaction/s should be appended.

    I included only a couple of my attempts.
    All the other ops and code work flawlessly from origin to account journals - except for this little bit in the middle.
    My only alternative otherwise is to code a laborious procedure.
    Attached Files
    Last edited by Ray in Capetown; 01-18-2014, 04:50 AM.

    #2
    Re: Append operation using Unique - how to get it to work

    Your field iAmount is 14 wide in one table but 15 wide in another. Your uniqueness expression assumes they're both 15 wide. At present the unique op is trying to compare 15 wides against a field that is only 14 wide.

    Comment


      #3
      Re: Append operation using Unique - how to get it to work

      Date and Description are also different Ray.
      You could build a Index by trimming the data and then use the EXIST feature to exclude data that is already present if you cannot control the CSV input field size.
      Or, move from CSV table to a table in the format and size you want, then Append.
      See our Hybrid Option here;
      https://hybridapps.example-software.com/


      Apologies to anyone I haven't managed to upset yet.
      You are held in a queue and I will get to you soon.

      Comment


        #4
        Re: Append operation using Unique - how to get it to work

        Thanks so much Tom. i had recreated these tables so many times I overlooked checking.
        Now I see too that the idate char field is different in length.
        I will follow up on that lead.

        Comment


          #5
          Re: Append operation using Unique - how to get it to work

          Ray, let us know how things turn out. Ted's got a good point. Check all fields involved in the append beforehand. If the "link" expression fails a record will be omitted. If the "link" expression is ok, the append will occur but some data may be truncated. So, compare structures of master and transaction tables beforehand.
          l

          Comment


            #6
            Re: Append operation using Unique - how to get it to work

            Yes I see Ted. Embarrassing.
            I can control the csv table from the import. i have to pay more attention, sloppy.
            I will revert after I have "unpickled" myself

            Thanks

            Comment


              #7
              Re: Append operation using Unique - how to get it to work

              Will do

              Comment


                #8
                Re: Append operation using Unique - how to get it to work

                After correcting the field lengths, the APPEND still duplicated all records including the new ones. Maybe a mixed field match is too complex, and I didnt want to change a bunch of imports and tables to make all amounts Char..
                Experimented a bit and eventually wrote a function that does exactly what is required to replace the APPEND operation, with added advantage of not inverting records as APPEND seems to do. It's quick because it can implement LQO with an index on Idate
                You can try it with the sample DB in #1 - save the function below and call it from Interactve Editor
                Code:
                FUNCTION bank.csvview_add AS L ( )
                dim r2v as p
                tbadd=table.open("banks_imported")
                tbcsv=table.open("bankcsv")
                tbcsv.query_create("","iamount<>0")
                tbcsv.fetch_first()
                while .not. tbcsv.fetch_eof()
                	vfnd=tbadd.query_create("","idate+IAMOUNT+idesc="+quote(tbcsv.idate+tbcsv.IAMOUNT+tbcsv.idesc))
                	if vfnd.records_get()= 0
                		tbcsv.record_to_vars(r2v)
                		iserr=tbadd.enter_record(r2v)
                		if iserr.has_errors .or. iserr.has_warnings
                			ui_dlg_box("POSSIBLE ERROR","Please check entry "+r2v.idesc)
                		end if
                	end if
                	tbcsv.fetch_next()
                end while
                'parentform:BROWSE1.resynch()
                END FUNCTION
                Last edited by Ray in Capetown; 01-19-2014, 05:10 AM.

                Comment


                  #9
                  Re: Append operation using Unique - how to get it to work

                  This works Ray.
                  I created a new Table from the CSV table, changed the order of query for the Unique test.
                  Looks like the order of the Unique query needs to be specific.
                  Now I'm off to clean my gun. Been shooting this morning!
                  Attached Files
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  Apologies to anyone I haven't managed to upset yet.
                  You are held in a queue and I will get to you soon.

                  Comment


                    #10
                    Re: Append operation using Unique - how to get it to work

                    Excellent.
                    I will study what you did.. thanks Ted.
                    What you shooting at?

                    Comment


                      #11
                      Re: Append operation using Unique - how to get it to work

                      Clays today. Take a long time to cook, longer to eat.
                      See our Hybrid Option here;
                      https://hybridapps.example-software.com/


                      Apologies to anyone I haven't managed to upset yet.
                      You are held in a queue and I will get to you soon.

                      Comment


                        #12
                        Re: Append operation using Unique - how to get it to work

                        Ray,

                        Yes, the field lengths was probably the issue because when I changed both linking Key expressions by changing concat symbols from pluses to minus's, it started working.

                        ie: idate-str(iamount,15,2)-Idesc

                        Comment


                          #13
                          Re: Append operation using Unique - how to get it to work

                          Ray, one issue on appending unique records that is worth noting: You have to account for the possibility of two or more legitimate identical transactions.

                          I also use 'append unique' in my finance app when downloading and appending bank transactions. An issue came up a couple of days ago where I had to change my linking key/uniqueness expression. I take the train to and from work daily and I pay the same amount daily. However two of the transactions posted on the same day, instead of on separate days like they should of. Therefore one of the charges would not append as my linking key/uniqueness expression uses the same basic fields as yours: posting_date. Description, and Amount. To test for truly a unique record, since there are no transaction IDs associated with each bank record, the only thing I could do was add "balance" to that linking key. That way if I have two legitimate identical transactions on the same day, one will not be excluded because the remaining account balance will be different.

                          Comment


                            #14
                            Re: Append operation using Unique - how to get it to work

                            Suggestion.

                            Capture the transaction time in a TIME field.
                            Create calculated fields in the Banking and the CSV tables.
                            The calc field = a trim of all you need to make the record unique.
                            Use the calculated field as the Unique identifier as it should be the record DNA.

                            Rerun the Rules in the CSV table, and also the Banking table before Appending.

                            Just amount/date/reference (unless unique at the source end) just isn't sufficient.
                            See our Hybrid Option here;
                            https://hybridapps.example-software.com/


                            Apologies to anyone I haven't managed to upset yet.
                            You are held in a queue and I will get to you soon.

                            Comment


                              #15
                              Re: Append operation using Unique - how to get it to work

                              Ted, I am not sure how to accomplish that. I don't know how the banking system works, but it appears the ACH transactions are accumulated for some number of hours and then "batched" into, or over to the bank site. So, two transaction that may happen 24 hours apart appear to be batched at the same time. The data that the banks provides is limited to only the 4 fields mentioned.

                              Comment

                              Working...
                              X