How to extract data from as400 to excel

BlueZone FTP has the ability to perform AS/400 data transfers via FTP and automatically place the data into a Microsoft Excel Spreadsheet.  The resulting spreadsheet can be edited and transferred back to the iSeries host.

This procedure assumes that you already have BlueZone FTP running and connected to an iSeries host.  It also assumes that you have an existing data file located on the iSeries host that you wish to download and view as a spreadsheet.

BlueZone FTP will display a transfer status dialog showing the file transfer progress.  To cancel a file transfer in progress, click the Cancel button.

After the file download is complete, the application (Excel) will automatically launch and display the data.

  • Highlight the Microsoft Excel file (.XLS) in the left hand, client side window and right click.  The Send File pop-up menu will display.

  • Select iSeries File Transfer from the pop-up menu.

  • The XLS File and the XLS Filename.OUTFILE will be parsed, the data file will be created and uploaded to the AS/400.

  • Hi,

    We have an old AS400 (don't have type, but it's something like 30 years old) that we need to extract data from (disk started to have a hard time to spin, we needed to shake them in order to make it spin again...)

    We were able to extract data from some of the tables, but we have one with 1,5 million entries. We did the other with Excel to Msquery, which worked well with no issues. But this one, of course, Excel won't take 1.5 million lines. Then we tried to send it to Access, but an error occur, and we are not able to skip this error (on line 235,716)

    I was trying to split the query, but I get an error while sending to MSquery. "SQL0227 - FETCH not valid, cursor CRSR0003 is unknown position."

    I tried to exclude the line, skip the line, but I get this error. If I try to open it in msquery and copy/paste data, I can do it with the first 65,000 lines, but after this msquery crash. If I try to send it to excel / access, it just crash.

    Does anyone have any idea on how to pull data from this nightmare? I tried asking old IT technician who worked for years with AS400 and they don't know how to get through. We were ready to pay for someone to extract the data, but there is no company with AS400 expertise around me (looked 200 km around me) and the only person that may have an idea on how to achieve this is not able to give me a valid reference (the data is sensitive...)

    Thank you..

    Edit: If anyone in the future find this post after searching like I did, here's what saved me:

    XML

    CPYF FROMFILE(LARGEFILE) TOFILE(library/SMALL1) CRTFILE(*YES) FROMRCD(1) 
    TORCD(100000) ERRLVL(*NOMAX)
    

    While the data transfer tools provided by IBM can certainly retrieve data for use in Excel, they are not the easiest nor the most functional way to do that. Excel features a Data ribbon in which you can select different ways to import data into Excel. This technote demonstrates two different ways to retrieve data by using an ODBC data source (DSN) which was previously created and finally by using a DSN-less connection. In the following examples, Excel 2016 was used but the features exist in older versions of Excel as well.

    Start by opening a blank worksheet and selecting the Data ribbon, then 'Get Data', 'From Other Sources' and select 'From ODBC' as shown in Fig. 1a

    How to extract data from as400 to excel

    Select the data source to connect to Db2 on IBM i and expand the 'Advanced options' twistie and type in your select statement in the 'SQL statement (optional)' section as shown in Fig. 1b.

    How to extract data from as400 to excel

    Click OK and it makes an ODBC connection, run the query and display the results in a table as shown in Fig. 1c

    How to extract data from as400 to excel

    Press 'Load' and it loads the data into the spreadsheet and saves the query in it as shown in Fig. 1d

    How to extract data from as400 to excel

    Note the 'Queries & Connections' item to the right of the data. If you hover your mouse over the spreadsheet icon just to the left of the query name (it was given a default name of Query1), you get a pop-up window as shown in Fig. 1e. The options in this window provide functions to edit the query and do several other things that are beyond the scope of this technote. Note, there is also a refresh icon to the right of the query name and clicking it refreshes the data in spreadsheet. If you close the 'Queries & Connections' pane, you can reopen it using the 'Queries & Connections' item on the Data ribbon.

    How to extract data from as400 to excel

    Selecting the EDIT option opens the dialog box shown in Fig. 1f. With this dialog you can modify the query, change the query name, and use the 'Advanced Editor' function (near the upper left) to edit the SQL statement.

    How to extract data from as400 to excel

    Connect Without A DSN

    In the previous example, a DSN was selected to define the connection. A DSN or data source Name can be thought of as a saved collection of default values for an ODBC connection to use. Ultimately, the application might override most any of the values you specify in a DSN so they aren't strict controls on the settings. While DSNs are a great way to get consistent behavior from one or more applications, they do require the step of creating the DSN. You can freely share a spreadsheet with an embedded data connection defined in it (like our first example). But the recipient must also have that DSN defined with the same name (and connecting to the same system). So you can see how a DSN is also a hindrance to the portability of the solution. Fortunately, we can define the connection without a data source. Then, we can share the spreadsheet with anyone with the ODBC driver installed on their system. They can refresh that data as needed.

    We follow the same steps of selecting the option to get data from ODBC. But this time, select '(None)' for the data source and enter a connection string that defines the ODBC driver to use and the system to connect to at a minimum. The ODBC connection string keywords and their default values are defined in the IBM Documentation. Using this interface, you do not need to provide values for anything more that the Driver and System keywords because we are not using any catalog features to browse for files or columns. If you have data in character fields defined with CCSID 65535, add the Translate keyword value pair.  This value causes that data to be converted from EBCDIC by using the job CCSID so that's in the example in Fig. 2a.

    How to extract data from as400 to excel

    You might be prompted for an ID and password after you press OK and then you are presented with the query results as in Fig. 1c from the first example. Select the option to load the data in the spreadsheet

    Parameterized Query

    Let's move on to something a little more dynamic. Frequently an entire table is transferred to a spreadsheet and then several rows are removed because they weren't wanted in the first place. In other words, a selection criteria set on the query ensures that only certain rows are selected and returned. The value for that criteria can be specified dynamically to provide a user with the flexibility to define the limiting values at run time. This next example shows how to create a parameterized query.

    For this case, the accounting team is sending refund checks to customers with large credit balances.  I need to find data for every customer that has a credit due to them that is greater than the limit that the accounting team set. Presently the limit is $10 so I really don't want to see the accounts that do not have more than a $10 credit due. I might change the query and add a hardcoded selection criteria, 'Where CDTDUE >= 10'. But the amount is known to vary from month to month and at the end of the fiscal year, anyone with a credit due is paid back. I don't want to edit the query every time it changes. I'd want the query to prompt me for a value when it is refreshed. To do accomplish this goal, we have to create the query a bit differently, by using Microsoft Query.

    To start, open a new spreadsheet and select the Data ribbon, select 'Get Data', 'From Other Sources', 'From Microsoft Query'. That opens the dialog box shown in Fig. 3a. Select your DSN and clear the box for 'Use the Query Wizard to create and edit queries'.

    How to extract data from as400 to excel

    In this case, it helps to have the library with the table you are querying in the library list of the DSN. That way you can select the schema (library) that the table is in, select the table and click 'Add' then 'Close' in the dialog box shown in Fig. 3b.

    How to extract data from as400 to excel

    Double-click the asterisk to populate the query with all of the columns, or select the columns you want in the order you want them. See Fig. 3c.

    How to extract data from as400 to excel

    Click 'Add Criteria...' option on the 'Criteria' menu. Add the criteria for your query. In my case, I want to be prompted for a value that the CDTDUE column must be greater than or equal to. So I select the CDTDUE field, the proper comparison operator from the list, and an open and closed bracket for the value as shown in Fig. 3d.

    How to extract data from as400 to excel

    Click add and it prompts for a value, type one in and then press 'Close' and then select 'Return Data to Microsoft Excel' from the 'File' menu. I am presented with the 'Import Data' window shown in Fig. 3e.

    How to extract data from as400 to excel

    Press 'Properties' to decide how you want the parameter to be set. The 'Connection Properties' window opens. Check the 'Refresh data when opening the file' option on the 'Usage' tab (Fig 3f). This setting causes a prompt for a new value every time the spreadsheet is opened. Then, select the 'Definition' tab, press 'Parameters' to open the 'Parameters' window shown in Fig. 3g.

    How to extract data from as400 to excel
    How to extract data from as400 to excel

    Note, by default, it selected the value you entered when Microsoft Query prompted you for a value to initially run the query. I want the query to prompt the user for a value every time. So I select the first option for how the parameter is to be obtained, 'Prompt for value using the following string:'. I enter a meaningful prompt string that the user is presented with. Finally, click 'OK' on this window and the preceding two windows to embed your query into Excel. Excel prompts you for a value and then it populates your spreadsheet with the query data (See Fig. 3h).

    How to extract data from as400 to excel

    Another Way To Enter Parameters - In The Spreadsheet Itself

    OK that works great but there are a couple of potential problems. When that spreadsheet opens, it prompts for the minimum credit due value but it doesn't suggest a default. If someone new is using this spreadsheet, it would be nice to see what the last value used was. The other issue is that the minimum credit values required for a refund check change only at the end of my fiscal year and even then, only for one month. How can I keep the flexibility of the parameterized query but not have to enter a value every time? One way is to pull the value from a cell on the spreadsheet itself and refresh the data only when that that value is changed or when I click 'Refresh All' on the Data ribbon.

    To start, open a new spreadsheet and create an input cell and a description of what is expected in that cell. Excel also has some default format colors you can apply to the cells to alert the user that a cell is an input value. See Fig. 4a for details.

    How to extract data from as400 to excel

    Proceed as in the previous example and this time when you return the data to Excel, the target location is under the input area (see Fig. 4b) and click 'Properties' again.

    How to extract data from as400 to excel

    Click the 'Definition' tab in the 'Connection Properties' dialog box and click the radio button titled 'Get the value from the following cell:'. Click the arrow button under that text (right side of the input field) then click your input field in the spreadsheet and Excel automatically adds the proper syntax to refer to the cell. In my example that would be =Sheet1!$B$1 meaning the value from Sheet1 of the workbook, Cell B1 (see Fig. 4c)

    How to extract data from as400 to excel

    Click the 'OK' buttons to close these windows and embed the data into the spreadsheet as shown in Fig. 4c

    How to extract data from as400 to excel

    This solution allows me to easily view what the parameter value is and I can update it and rerun the query by typing the new value into the input cell and pressing enter. At the end of the year, I put in the value 0.01 and press enter to get rows for everyone that has a credit due. (See Fig. 4e).

    How to extract data from as400 to excel

    How do I transfer data from iSeries to Excel?

    Step 1: Open Microsoft Excel, and display a blank worksheet. Then, select the Data Transfer from iSeries icon from the toolbar as shown below or select Data Transfer from iSeries from the Data drop down menu. This opens a new Transfer Request window.

    How do I extract data from a dataset in Excel?

    6 Methods to Extract Data from an Excel Sheet.
    Extract Data from Excel Sheet Using VLOOKUP Function. ... .
    Pick Data from Excel Sheet Using INDEX-MATCH Formula. ... .
    Extract Data from Excel Sheet Using Data Consolidation Tool. ... .
    Extract Data from Worksheet Using Advanced Filter..

    How do I import data from ODBC to Excel?

    How to import data to Excel using ODBC.
    Run MS Excel and click the Data tab..
    To import data, click From other sources and then select From data connection wizard..
    When Data Connection Wizard opens, select ODBC DSN and click Next to continue..
    Now you should select a data source you want to connect to (e.g. NetSuite)..

    How do I connect Db2 to Excel?

    Procedure.
    In the web console, go to the Run SQL page..
    Type one or more SELECT statements in the editor text box..
    Click one of the Run options..
    Click Excel ODC File..
    Download and open the BLUExcel. ... .
    Click Open to connect to the Db2 Warehouse database. ... .
    Type the user ID and password that you use to log in to Db2 Warehouse..