Results 1 to 8 of 8
  1. #1
    ShennyP is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    11

    Appending SAP exports Every Day


    I am very new to access and am struggling to find a good way to append daily exports from SAP with some error checking.

    To be more detailed we export 2 SAP files every day and I need the new data added to their appropriate master table. I know there is an import excel file function where you can append the new data to the table which works well however I don't think I can put duplicate and error checking using this method. I want to try and make it as easy as possible however I don't want any chance of wrong data going in. What is going the be the best way of doing this?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    What format are these exported files in - CSV or Excel? Options:

    1. possibly set links to the files and work with them like tables

    2. VBA automation code to process data one line or row at a time
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ShennyP is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    11
    Could export as either of those formats. These files will change tho and I need the historic data to stay in the table.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Appending should not impact existing records. If anything, the INSERT could fail to add new records but would not change existing.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,679
    1. You have e.g. an Excel table on shared resource. New info is entered/copied/read into this table. In case every new row must be added into Access table, every row in this Excel data table must have some unique (time) template/counter saved at creation time, which will be stored into Access table too. In case some Access table must be updated with data from Excel table, then the Excel table must have columns allowing to identify the data to be updated;
    2. You link the Excel table into your Access database. NB! The users will not have any access to linked table - not directly, and not through any forms!;
    3. You create a VBA procedure in Acccess database, which reads data from linked table, evaluates the validity of data, and inserts valid data into Access table(s) or updates Access table(s) with valid data. NB! This is the only use for linked table!;
    4. You create some control or form event which runs the procedure. Or you write a script run by scheduled task on some server/computer, which opens the Access database and runs the procedure.

  6. #6
    ShennyP is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    11
    Quote Originally Posted by ArviLaanemets View Post
    1. You have e.g. an Excel table on shared resource. New info is entered/copied/read into this table. In case every new row must be added into Access table, every row in this Excel data table must have some unique (time) template/counter saved at creation time, which will be stored into Access table too. In case some Access table must be updated with data from Excel table, then the Excel table must have columns allowing to identify the data to be updated;
    2. You link the Excel table into your Access database. NB! The users will not have any access to linked table - not directly, and not through any forms!;
    3. You create a VBA procedure in Acccess database, which reads data from linked table, evaluates the validity of data, and inserts valid data into Access table(s) or updates Access table(s) with valid data. NB! This is the only use for linked table!;
    4. You create some control or form event which runs the procedure. Or you write a script run by scheduled task on some server/computer, which opens the Access database and runs the procedure.
    This sounds like it could work well. Sounds like a good way of doing it without mistakes.

    So what I would do is have the export write over the top of the old export every day and someone would have to prompt a macro in this time to import the new data on top. This macro would obviously have conditions so that the identifier field (in my case order number) isn't a duplicate. I would probably set this up on a form and I assume i would have it as a push button much like vba?

    Would there be an example somewhere of someone writing a vba button doing this append with duplicate checking?

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    what you require may be simple to resolve, or it may be complex. it sounds like you need more than just being pointed in the right direction. To do this we really need some example data. For example you say 'doing this append with duplicate checking'. Duplicate of what? a single field? some fields? all fields? do the SAP records have a primary key? is the SAP data normalised? Are your destination tables normalised? Does the data need some conversion? What sort of error checking to you require? Does the SAP data need to relate to existing data either manually maintained or sourced from another system?

    Broadly speaking you will have 4 types of comparisons to make to determine

    1. those records in SAP data that are also in your destination table(s) and are identical in all fields
    2. those records in SAP data that are also in your destination table(s) and are different in some fields
    3. those records in SAP data that are not in your destination table(s)
    4. those records in your destination table(s) that are not in SAP data

    these have to be compared in light of your requirement - i.e. do you just want a current view - in which case the type of action required is likely to be

    1. ignore
    2. update destination tables with SAP data
    3. append SAP data to your destination table(s)
    4. delete those records in destination data

    or alternatively (although not recommended unless being stored in a separate, temporary back end)
    a. delete all data in destination tables (better to delete the temporary database and create a new one)
    b. append SAP data to destination table(s)


    Or perhaps you need to maintain a history so you can track changes - in which case you would likely do

    1. ignore
    2. append SAP data to your destination tables perhaps with the addition of a timestamp field
    3. append SAP data to your destination tables
    4. ignore or perhaps flag in some way that the record is no longer current

    Then you need to consider the metrics - typically how many records per load? how many fields? How many destination tables? frequency?

    you mention the need for error checking so the following may be relevant
    SAP has a habit of exporting data in a way that is not easy to import - such as starting the table of data a number of rows down (which might vary from file to file) and/or having one or more rows at the end of the report or blank rows in the middle of the dataset. I've also known it to produce reports where the worksheet names change (e.g. using week numbers or country names for sheet names)

    And do the columns have consistent data types? - no 'NULL' text in a numeric column for example? Does the SAP data have numeric columns which contain a lot of blank values - particularly in the top few rows - these will be interpreted as text

    There are other questions around automation but probably outside the scope of your question.

    You will find many examples out there for importing data - which one is right for you depends on how you answer the above. And you may have to cobble bits of code from different examples to meet your particular requirement.

  8. #8
    Join Date
    Apr 2017
    Posts
    1,679
    Quote Originally Posted by ShennyP View Post
    So what I would do is have the export write over the top of the old export every day ...
    Of course you can use some export procedure to read data from Excel table too, but my advice was to link the Excel table into Access DB.

    In design view, you activate External Data menu, and:
    a) Select <ODBC Database>, activate "Link the data source by creating a linked table.", and click OK. Select Excel workbook, and sheet/table/named range in it, etc.
    b) (I myself have never used it yet.) Select <Excel>, activate "Link the data source by creating a linked table.", select workbook, and click OK. Proceed.

    With Excel table linked, Access automatically refreshes the data, whenever the application is opened, and I think (have never looked deeply into way this works) also whenever the linked table is accessed (data are requested) - i.e. for users it is always on-time. So you avoid the hassle with querying data at all.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Blank row on Exports
    By BullwinkleTMoose in forum Import/Export Data
    Replies: 1
    Last Post: 08-30-2016, 03:01 PM
  2. Replies: 1
    Last Post: 02-29-2016, 03:40 PM
  3. Replies: 2
    Last Post: 04-08-2015, 12:43 PM
  4. How Access exports tables from a server
    By gg80 in forum Access
    Replies: 11
    Last Post: 11-16-2013, 06:17 PM
  5. Problem with Query exports to Excel
    By nokeefe in forum Access
    Replies: 9
    Last Post: 12-07-2011, 12:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums