Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AS/400 Macro Date input

Status
Not open for further replies.

mikecoemd

IS-IT--Management
Nov 7, 2013
12
US
Forgive my newbieness, but I am trying to make my workday more efficient and am pretty new to scripting macros!

Here is my goal: to have a macro that prompts me for input once for a value that can be recalled and re-used. (I wish I knew the terminology, but don't - so bear with me!). Below is an example of my macro. Where it says "110513" I simply want YESTERDAYS date in MMDDYY format... but sometimes I need to input a range, which is why I would like it to prompt me for input rather than simply SendKey yesterdays date.

Here is the actual code that only sends the pre-set date/value (110513):

sub subSub1_()
autECLSession.autECLOIA.WaitForAppAvailable

autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "110513"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "110513"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
end sub


Logically what I would like:

OPENS with a Message box prompt, asking for a value. That value is stored as USER_VALUE.

sub subSub1_()
autECLSession.autECLOIA.WaitForAppAvailable

autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "USER_VALUE"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "USER_VALUE"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
end sub


 
mikecoemd said:
How would I make my macro pause, and have a pop-up box appear that says, "Do xxxx now, then press okay to continue" and then continue the macro after "Ok" is pressed?
IMO, you can use everything what VBscript supports.
Try either simply
Code:
Wscript.echo "Do xxxx now, then press okay to continue"
or MessageBox - for example:
Code:
message = "Do xxxx now, then press okay to continue"
call msgbox (message, vbInformation, "My AS/400 Macro")
Some message boxes are in the example I gave above i.e.:
That was a working macro, so message boxes must work.
 
How can I do this without executing a new sub for each input?
I'm not sure if I understand well what you want to achieve, but when the 2 subrotines do the same thing you can call only one with the two date arguments for example:
Code:
...
if my_date <> " " then 
  [highlight]call subSub1_(my_date)[/highlight]
end if

if my_date2 <> " " then 
  [highlight]call subSub1_(my_date2)[/highlight]
end if
...
 
So... I could have the first date represented by "call subSub1_(my_date)" and the second date represented y "call subSub1_(my_date2)" all within the same sub?

Code:
'SUBSUB1 DEMONSTRATES INPUT FROM THE DIM MY_DATE TEXTBOX BEING UTILIZED
sub subSub1_(date_mmddyy)
   autECLSession.autECLOIA.WaitForAppAvailable
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys [highlight #FCE94F]date_mmddyy[/highlight]
      autECLSession.autECLPS.SendKeys "    "
   autECLSession.autECLOIA.WaitForInputReady
end sub

'SUBSUB2 DEMONSTRATES INPUT FROM THE DIM MY_DATE2 TEXTBOX BEING UTILIZED
sub subSub2_(date_mmddyy)
   autECLSession.autECLOIA.WaitForAppAvailable
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys [highlight #FCE94F]date_mmddyy[/highlight]      autECLSession.autECLPS.SendKeys "[enter]"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[enter]"
end sub

and if so, how would the script know which value was from my_date1 vs my_date2?

I just don't want to have to fill in a messagebox, and 'end sub' in between each set of dates. It wouldn't simplify much for me because I would have to run multiple macros!
 
how would the script know which value was from my_date1 vs my_date2
For example if you have declared the subroutine so
Code:
sub subSub1_(date_mmddyy)
   ...
   autECLSession.autECLPS.SendKeys date_mmddyy
   ...
end sub
and if you have for exampe my_date1 = 111013 and my_date2 = 111113 then
Code:
call subSub1_(my_date1)
causes this instruction be executed
Code:
   ...
   autECLSession.autECLPS.SendKeys 111013
   ...
and
Code:
call subSub1_(my_date2)
this
Code:
   ...
   autECLSession.autECLPS.SendKeys 111113
   ...
 
I just don't want to have to fill in a messagebox, and 'end sub' in between each set of dates. It wouldn't simplify much for me because I would have to run multiple macros!
You can record one subroutine which use 2 dates and run it once. For example you have 2 green scrrens . In the first you enter date1, then by pressing the function key you skip to the second screen and here you enter date2. You can record this action using macro recorder and then parametrize it wirh 2 dates for example you will get instead of subSub1_ and subSub2_ only
Code:
sub subSub1_(date_mmddyy1, date_mmddyy2)
   ...
   autECLSession.autECLPS.SendKeys date_mmddyy1
   ...
   autECLSession.autECLPS.SendKeys date_mmddyy2      
   ...
end sub

Then in your macro script you can input the 2 dates
Code:
dim my_date1, my_date2
my_date1 = InputBox("Start Date:","Date Input","MMDDYY",100,100)
my_date2 = InputBox("End Date:","Date Input","MMDDYY",100,100)
and then call the subroutine
Code:
call subSub1_(my_date1, my_date2)

 
Everything worked like a charm this morning! Many thanks!

is this language one that I can define subs and then call upon them in a specified order? For example, this would run in sequential order unless otherwise specified by one of these subs, correct?

Code:
Sub1
Series of events
end sub

sub2
Series of events
end sub

sub77
Series of events
end sub

How could I make it pause, and ask me to hit "Ok" to proceed at the end of Sub2? Your suggestions earlier only produced errors!

Code:
Wscript.echo "Do xxxx now, then press okay to continue"

or MessageBox - for example:

Code:
message = "Do xxxx now, then press okay to continue"
call msgbox (message, vbInformation, "My AS/400 Macro")
 
To execute the subroutines you need to call them:
Code:
call Sub1
call sub2
call sub77

The MsgBox should work.
 
Mikrom, I finished my whole script and it froze up a few times -- would you mind looking over it? Sometimes it goes faster than the AS400 is ready to accept input and it freezes!

Questions:
1. is there a way to analyze the text on screen so I can create more complex macros? eg. if screen = "timeout" then call sub55?
2. what is the difference between WaitForAppAvailable and WaitForInputReady?

Thanks,
Mike
 
Hi mikecoemd,

Unfortunately I cannot answer your questions as simple.
To answer your question I would need to know exactly what you wanted to do and probably have an access to your AS/400 to be able to try it myself.

On the other hand - I have not created any green-screen applications and macros for it for a long time.

My IT managers have come together with the Java and .NET people. I was told that the green-screen applications are outdated and no longer macros are used and if I wanted to keep my job, I was forced to learn Java.
So, I learned Java and now I'm creating webservices. It's all much more complicated as before.
We used to have four COBOL-Programmers and one AS/400 admin and now we have five COBOL-Programmers and three Java-programmers, one ambigious (that's me) , one admin for AS/400 and 2 admins for application servers.
But the IT managers are happy ... and I also - because I get paid :)




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top