AS400 Macro

Posted on 2005-04-08
Last Modified: 2012-05-05
Hi again everyone,

I'm looking for some information on the native as/400 macro language, specifically two things:

1) Is it possible for a macro to call another macro?  Preferably a vbscript macro but I could deal with another native-language macro if thats the only option.

2) Is it possible for a native-language macro to run something externally (similar to the vb shell command)?

I'm offering 250 points for each sub-question.
Question by:mvidas
    LVL 14

    Accepted Solution

    here is the VB script to launch an external function

    'This example starts notepad with the file

    dim ProcessID
    ProcessID ="Notepad.exe" )

    If ProcessID > 0 then
          Msgbox "Notepad Started"
          Msgbox "Notepad not started"
    End if

    I will check how to run another macro

    LVL 35

    Author Comment

    Is there a way to run externally from the non-vbscript language?
    LVL 35

    Author Comment

    After searching and searching for a way to do it, I don't believe it is possible for a native-language macro to call another macro (native or vbscript), and I definately don't think its possible for a native macro to open an external program. the native language was extremely limited, which is probably why they added the vbscriping capabilities.

    The reason is the same as in my last question, I have a native macro loading the reports from Real Vision, then a vbscript macro to 'harvest' them.  I was hoping to have the native macro call the harvesting macro, then have it run a .vbs file on my hard drive that takes the outputted text files and extracts the data i want into a useful format. I have all the .vbs files I need, I was just trying to avoid the 3 step process, and avoid the vbscript macros as much as possible (due to that memory-releasing issue).  I'm trying to avoid extra steps so I can give my process to someone else who doesn't really understand macros. The less work for them, the better, in my opinion

    If you do figure out how to run another macro from a vbscript-macro, I could probably work with it to still accomplish some time-saving tasks.  
    I don't think you were yet at the guru level here in AS400 in my last question (though I don't remember sure), congrats.
    LVL 26

    Expert Comment


    You seem to be mixing terms. When you say "native", you will be referring to REXX, QShell, PASE or similar environments for a 'macro' language by definition. When you say "vbscript", you are automatically also "non-native". VBscript is Windows, not OS/400.

    However, in all OS/400 macro (or "scripting") languages, it's possible to call all other native languages.

    Through the RUNRMTCMD command, it's also possible to invoke macros or scripts or whatever on other systems such as client PCs. RUNRMTCMD is a kind of generic way to invoke functions on remote systems. There is also STRPCCMD which is designed to invoke functions on the current client PC. Both of those could start vbscripts.

    There are also various APIs that could be used, but I suspect that that gets well outside what you want to invest for time/effort in this.

    LVL 35

    Author Comment

    Hi Tom,

    I do apologize for the different names I refer to the languages, as I don't know what one of them is called.  My terminal program, an iSeries client access program (v5.5) can use two languages.  When I go to record a macro, it asks me if I want the Record Format to be "VBScript" or "Macro", and the 'Macro' language is what I referred to as 'native' (as that is what Dave referred to it in a previous questino of mine).  Just so you might be able to recognize the formats, here is an example of what I referred to as 'native':

    [wait app]

    And here is the same thing in the vbscript language:

     autECLSession.autECLPS.SendKeys "95[enter]"

    I know how to run other macros or external programs in the vbscripting language, would be very easy, but I don't know how to do it using the other language.  Do you have an idea? I'd love to stick to just vbscript macros (or even the standalone .vbs files that I use now to do the same thing), but with the memory releasing problem I'm pretty much stuck with using both (see http:Q_21340633.html for more info on that): a macro to load the reports in real vision and a script to export and delete them. I'm trying to see if I can get the macro to run the script, as well as an external .vbs I have that takes the files from the server, extracts the necessary data out of them, and combines into a consolidated file.  I've got everything done, so really at this point the only thing I'm trying to hurdle is having to update then run 2 or 3 macros to do this. I know it sounds trite but I'd love to have this down to just one, and I'm willing to spend the time and effort to accomplish this so it can be done without me in the future.

    I'd love to hear any/all ideas you may have!
    LVL 26

    Assisted Solution


    Ah. Emulator macros... I see.

    To tell the truth, it's been so long that I've worked directly with them that I'd need to research it. I'm not aware of ways to get them to run under control of your AS/400 unless it's done via EHLLAPI, PCSAPI or similar emulator APIs.

    Okay, it looks like this is where you need to look nowadays:

    That comes from:

    The "Emulator Programming" topic leads to the PDF.

    As you'll see, you'll need to create a program for the PC in order to invoke it from the AS/400. It _used_ to be possible under OS/2 to create a REXX script dynamically on the AS/400 and execute it from the PC via mapped drive or other ways. (If you have WDSC, you should have a rexx.exe that provides an Object REXX interface; but I doubt that does you any good for users.) REXX could then invoke DLLs or whatever.

    But you'll almost certainly need a compiled program -- C, VB, whatever -- to invoke your macros. Maybe Java could be used.

    Personally, this seems to be going in a backwards direction. Why not just replace the whole macro concept with programming on the AS/400 itself? From what you've said, there's no need for any macros at all.

    Windows functions could access whatever's needed through Windows Network shares served from your AS/400. The AS/400 could populate streamfiles in the share to drive any Windows process and invoke the process via STRPCCMD or RUNRMTCMD. Etc.

    LVL 35

    Author Comment

    Tom and Dave,

    Sorry I've neglected this question, other things have come up at work, and when I've had the time to come to EE, this question was far from my mind.

    As for programming on the AS/400 itself, I think that is beyond me.  I'm just an end user dealing with pre-generated reports, and don't have any command line capabilities that I know of.

    I'm just going to leave it as is, and possibly tinker with it a little bit in the next couple months (no one will have to run this for me until August, I believe).  I'm going to split the points evenly between you two.  I thought about waiting until May, as both of you have reached your 3,000 points for April, but I don't think either of you have a problem reaching 3000 so I'm going to close it now.

    Thanks again!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now