Question

Macro to Get Data from ISeries into excel

Asked by: pchan8888

OK, My eyes are getting tired from reading through EE.  It's very informative with suggestions but I need a step by step to connect to our AS400.  
I did get the DATA Menu>"Get External Data via ODBC" to work fine but it's not able to be used in a shared enviroment as this option is grey out  Hence, the only option is "Transfer Data from ISeries".  I'm looking for a macro that will log me in and refresh every 7 minutes.  
Our server is: 10.1.1.2
File Library is HS#LIBR
File is HSPBEDFLOW
User ID: User
Password: Password
 
This is the manual way and I did try to record and it did not give me any lines to work with:
Go into Data>Data Transfer from ISeries.  It asks for Transfer Request.  I chose create new file press OK.
It gives me teh ISeries Address: 10.1.1.2. I press next and teh next windo comes up asking for Lib/File: HS#LIBR/HSPDEDFLOW then pres next.  I then get Customize File Transfer..I just press next. In the next window it ask to save reuest to file.  I press Finish without doing anything in the screen.  It then ask to signon to ISeries with User ID and Password..put  in the info and I get the data in A1.  

Could one of the expertise assist please.  I'm relatively new.  
Regards,
Paul

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-12-21 at 11:40:09ID23038887
Tags

excel

,

iseries

,

data

,

macro

,

from

Topics

Programming for iSeries / AS400

,

Microsoft Excel Spreadsheet Software

,

VB Script

Participating Experts
3
Points
500
Comments
24

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. AS400 iSeries Database
    Am actually trying to DTS data from SQL 2000 to AS400 database(IBM iSeries) getting the below error message : [IBM] [Series Access ODBC Driver][DB2 UDB] SQL0204- SOETAR in QSYS type *LIB not found. Am using iSeries Access ODBC Driver
  2. Export Database from MS-Access to iSeries (AS400 …
    HI, I need to export MS-Access database to iSeries and after the export, I want to configure AS400 DB2 for coldfusion to work directy.
  3. Export SQL server to Iseries(as400)
    Hi, I would like to export data from an SQL server 8 to Iseries(AS400). Does anybody have a good solution for this? Is it possible to create a XML file from SQL server? Does AS400 read XML? Regards, Stefan
  4. iSeries Printer Creation
    How do you create an HP printer on the iSeries AS400 system?
  5. iSeries Access Macro/Scripts - Terminal Server
    We use iSeries access as a client program to interface with a business application running on our AS400. Some users have a PC - iSeries Access installed. We also have a number of users who use a Windows Terminal Server. I have installed the iSeries Access program on the 2003 ...
  6. Ruby and iSeries
    We currently run an IBM AS400 / iSeries. We use the cwbtfxla.xll excel plugin ("Transfer Data from iSeries") I was wondering is there any way to automate this using ruby and win32ole? Can anyone point me towards any resources that use ruby with the iSeries access fo...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: jocasio123Posted on 2007-12-21 at 12:07:36ID: 20516032

I'm not sure how to do that as a macro, but I think Once you have everything in A1, you can Select Data->Text to Columns and separate the columns that way.

 

by: roryaPosted on 2007-12-21 at 13:55:40ID: 20516662

Set up the querytable as you outlined. Once you have it on the worksheet, switch to the VBEditor, then in the immediate window (Ctrl+G to open that if it's not visible) and type:
?Activesheet.Querytables(1).Connection
and press enter. This should output the connection string more or less as you need to use it with ADO.
Regards,
Rory

 

by: pchan8888Posted on 2007-12-21 at 19:23:12ID: 20517595

Hi Rory,
I'll try your suggestion on Monday when I'm back at work.  Good to see you again.  Did you get 2nd question points?  Hope you got it.  I still need assistance with question 1 that I uploaded.  
Sincerely,
Paul

 

by: daveslaterPosted on 2007-12-22 at 13:13:38ID: 20519866

Hi
I use several methods.
1 - ADO to access the AS/400 and download.
2 - Create a Client access data transfer and load it from there.

It depends on the amount of info, the speed of the line and what you want to do with it.
here is the ado code

Sub DWNLD()
Set conn = CreateObject("adodb.connection")
Set rcd = CreateObject("adodb.recordset")
cnnstr = "DRIVER={Client Access ODBC Driver (32-bit)};SYSTEM=999.999.999.999;USERID=User;PWD=Password"


conn.Open cnnstr

Set rcd.ActiveConnection = conn


sqlstm = "SELECT * FROM LIBRARY.FILE"


rcd.Open sqlstm

Set flds = rcd.Fields
For i = 0 To flds.Count - 1
Cells(1, i + 1).Value = flds(i).Name
Next i

j = 2
Do While Not (rcd.EOF)

For i = 0 To flds.Count - 1
Cells(j, i + 1).Value = flds(i).Value
Next i

rcd.movenext
j = j + 1
Loop


Set rcd = Nothing
Set conn=Nothing
End Sub

 

by: pchan8888Posted on 2007-12-24 at 05:18:05ID: 20524521

Hi Daveslater,
I've tried your coding this a.m.
I gethe following mesage: Run Time Error -2147217900 (80040e14)
[IBM][Iseries Access ODBC Driver][DB2 UDB]SQL0104- Token, was not valid.  Valid tokens: , FROM INTO.
Not sure what  this means??!!

PS how would you go about the second option as a trial: the Client Access Data Transfer?  What does that entails?

Hi Rory,
I tried you method and itgave me this in the window: ODBC; DSN-ISeries

 

by: pchan8888Posted on 2007-12-24 at 05:40:04ID: 20524551

OK update,
Found out the issue of the error message.  I had to chose the a .dll from the IBM folder.  If yo can Daveslater, please give me more info on the Client Access Data Transfer

 

by: pchan8888Posted on 2007-12-24 at 06:34:14ID: 20524724

Is there a way to automatically refresh every 7 mnutes by the DWNLD macro?

 

by: daveslaterPosted on 2007-12-24 at 07:05:24ID: 20524871

Just read the question in more detail
The connect string should be
cnnstr = "DRIVER={Client Access ODBC Driver (32-bit)};SYSTEM=10.1.1.2;USERID=User;PWD=Password"

and the sql should be:
sqlstm = "SELECT * FROM  HS#LIBR.HSPBEDFLOW"


 

by: pchan8888Posted on 2007-12-24 at 07:07:43ID: 20524875

Hi Daveslater,
Yep got that part and is working...I just need a macro that would automate it to run every 7 minutes.  Any ideas?  Thanks!!  Paul

 

by: daveslaterPosted on 2007-12-24 at 07:08:46ID: 20524878

Hi
for the timer look at this question.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_22571676.html
I could copy the code but then the person who wrote it would not get the credit.

Dave

 

by: pchan8888Posted on 2007-12-24 at 08:25:32ID: 20525125

Thanks Dave!!  I will review it.  Quick question, If I want to specify a worksheet to beging loading the data from the As400 where in the code should I put that in??
Thanks for your help!!  Merry X-mas
Paul

 

by: daveslaterPosted on 2007-12-24 at 10:15:21ID: 20525442

Hi
The code is.

dim ws as worksheet
set ws=sheets("Sheet1")

For i = 0 To flds.Count - 1
ws.Cells(j, i + 1).Value = flds(i).Value
Next i


Dave

 

by: roryaPosted on 2007-12-24 at 16:54:04ID: 20526195

You might want to look at the Range object's CopyFromRecordset method as it will be faster than looping through each row and field. (Or use GetRows if you want a subset)

 

by: pchan8888Posted on 2007-12-24 at 18:08:27ID: 20526297

Hi Rory,
I'm still interested in anything at this time.  Thus far, yes daves coding takes awhile but it does the job even without the assigned worksheet.  However, if it might be faster, I will need input from you as you already seen what I'm trying to do.  I am not familiar with VB and I'm just cutting and pasting as well as doing research along the ways.  As I mention first, there's a lot of info but without being able to apply it, it's a learning curve for me.  

Dave,
The reason I asked for the specific worksheet is that, if I was on any sheet that is in the fore front, the data is transferred onto that sheet and "messes it up".  Hence, I needed to "direct" the download of data into eg. sheet19.  
I did find a way to refresh the data Dave. Thanks!

I think I saw another code that will only allow one user to update vs. other users under the shared environment.  I believe that is the next step.  I did post another question if anyone is interested.  Thanks to all and Merry Christmas!!!!

 

by: pchan8888Posted on 2007-12-24 at 18:29:58ID: 20526320

This is teh code by Kusi 25 That I've found..I hope it will work.  Probably give it a try on Thursday.

"To prevent from running the queries on all more than one machine, you could  add little vba code to check the computername or username before running the queries

Create a module (not a class module):

Option Compare Database
Option Explicit

Public Declare Function GetComputerName _
  Lib "Kernel32" Alias "GetComputerNameA" _
 (ByVal sBuffer As String, lBufferSize As Long) As Long

Public Function GetComputer() As String

Dim sComputerName As String
Dim lSize As Long
Dim lLength As Long
sComputerName = String(16, " ")
lSize = Len(sComputerName)
lLength = GetComputerName(sComputerName, lSize)
GetComputer = Left(sComputerName, lSize)

End Function


in your sub add the following code:

If GetComputer <> "MycomputerName" Then
Else
'Your query code here
End If"

credit to:  Kusi

 

by: roryaPosted on 2007-12-27 at 15:45:57ID: 20538356

Application.OnTime Now + TimeValue("00:07:00"), "DWNLD"
will schedule the macro to run in 7 minutes time.
Regards,
Rory

 

by: pchan8888Posted on 2007-12-28 at 09:52:35ID: 20543595

Hi daveslater,
Is there a way to spped up your code that you provided??

 

by: pchan8888Posted on 2007-12-28 at 09:53:25ID: 20543604

Hi Dave,
Sorry about the misspelling:
Is there a wayto speed up your code that you provided?
Regards, Paul

 

by: roryaPosted on 2007-12-28 at 11:48:20ID: 20544510

You need to set a reference to the Microsoft DAO object library under Tools->References in the VBEditor.

 

by: pchan8888Posted on 2007-12-28 at 12:33:45ID: 20544890

Thank Rory,
I've give it a try on Monday.  Since I have you,
The module basroomchange or something similar... different computer that I'm using.  At this time, it's not "updating the code PM,PF, M, or F when using Dave's code.  It works on teh original version that you assisted still.  How did you "assign" that module to kick in after refresh???
Thanks in advance!!
Paul

 

by: daveslaterPosted on 2007-12-28 at 14:31:07ID: 20545733

Hi
I will look at the code over the week-end and get a version that works with the original example.

Dave

 

by: roryaPosted on 2007-12-28 at 17:27:33ID: 20546437

Not sure what you mean. The original code I dealt with was, as I recall, a Querytable and this is not, hence there is no refresh event to use.
As far as writing your data to the sheet goes, it is probably quicker to use:

Worksheets(1).Range("A1").CopyFromRecordset rs

rather than writing out row by row or trying to create an array (unless you have a row limit to worry about)

Regards,
Rory

 

by: daveslaterPosted on 2008-01-04 at 05:06:04ID: 20581687

Hi
I was doing some surfing of the holidays.
This is some free software that will allow you to what you want.
http://www.enhanceddatasystems.com/ED/Pages/ExcelTimer.htm
I will delete the other comments so people do not get confused.

Dave

 

by: pchan8888Posted on 2008-01-07 at 05:57:03ID: 31419484

Thank you for the macro code.  I'll use this for the time being :-)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...