Hi Steven, its not necessary to prompt for the month number. Hope this helps.
<HAScript name="test" description="test" timeout="60000" pausetime="300" promptall="true" blockinput="false" author="sabine.rein" creationdate="30.08.2025" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">
<!-- import necessary java classes for working with dates and formatting -->
<import>
<type class="java.util.Date" name="Date"/>
<type class="java.util.Calendar" name="Calendar"/>
<type class="java.text.SimpleDateFormat" name="SimpleDateFormat"/>
</import>
<!-- define variables -->
<vars>
<!-- Variable to hold the current date -->
<create name="$currentDate$" type="Date" value="" />
<!-- Variable for calendar operations -->
<create name="$cal$" type="Calendar" />
<!-- Formatter for date formatting -->
<create name="$formatter$" type="SimpleDateFormat" value="" />
<!-- Variable to hold the month number as a string -->
<create name="$monthNumber$" type="string" value="" />
</vars>
<!-- First screen: Start -->
<!-- This is the entry screen where date calculation and formatting are performed -->
<screen name="Start" entryscreen="true" >
<description>
</description>
<actions>
<!-- 1. Create current date -->
<varupdate name="$currentDate$" value="$new Date()$" />
<!-- 2. Create a Calendar instance and set it to the current date -->
<varupdate name="$cal$" value="$Calendar.getInstance()$" />
<perform value="$cal.setTime($currentDate$)$" />
<!-- 3. Add 0 months (this line could be adjusted to move to a future or past month) -->
<perform value="$cal.add(2, 0)$" />
<!-- 4. Create a formatter to extract the month in "MM" format (e.G. 08 for August)-->
<varupdate name="$formatter$" value="$new SimpleDateFormat('MM')$" />
<!-- 5. Apply formatter to calendar date and store result in $monthNumber$ -->
<varupdate name="$monthNumber$" value="$formatter.format($cal.getTime()$)$" />
<!-- 6. Enter the formatted month number into the screen at row 4, column 19 / ADJUST ROW & COLUMNS NUMBERS ACCORDINGLY FOR YOUR SCRIPT-->
<input value="$monthNumber$" row="4" col="19" movecursor="false" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens >
<!-- Define next screen flow -->
<nextscreen name="Ende" />
</nextscreens>
</screen>
<!-- Final screen: Ende -->
<screen name="Ende" exitscreen="true" >
<description>
</description>
<actions>
<!-- Output the calculated month number to the system log (see terminal / windows settings) -->
<trace type="SYSOUT" value="$monthNumber$" />
<!-- Or Output the calculated month number via messagebox-->
<message title="'Month Number'" value="'The calculated month number is: ' + $monthNumber$" />
</actions>
<nextscreens >
</nextscreens>
</screen>
</HAScript>
------------------------------
Sabine Rein
------------------------------
Original Message:
Sent: Wed September 27, 2023 11:32 AM
From: Steven Lukas
Subject: HAScript problem
Let me say that this is my first attempt to do anything with HAScript and what I have read in the user guide has left me confused on how to solve this issue. Once a month I have to run a repetitive job that contains one variable - month number. Other screen inputs are fixed. I have managed to create a MAC file which accomplishes my needs but the month number variable only functions if I edit the MAC file and replace the variable in the script. I can live with it but want to be able to prompt for the value and have it used to replace a field on an input screen. I have attempted to do a screen prompt asking for the value. This works but when I hit the 5250 screen that needs this value, nothing is placed on the screen. There are a total of sixteen screens with the variable needing to be entered on every even number screen. I started with the one example I could find on the IBM web pages showing an input variable entered and echoed back to the screen but every attempt of mine to make this function fails.
Is there anyone who has puzzled out how to make this function? My code follows and was designed to run a report in MAPICS XA. If I remove screen1 and simply hard code the variable value it functions properly.
<HAScript name="test xxx" description="input dialog" timeout="60000" pausetime="300" promptall="true" blockinput="false" author="Steven Lukas" creationdate="09/27/2017" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">
<vars>
<create name="$strData$" type="string" value="00" />
</vars>
<screen name="Screen1" entryscreen="false" exitscreen="true" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
</description>
<actions>
<prompt name="'Type Month number'" description="" row="0" col="0" len="80" default="" clearfield="false" encrypted="false" movecursor="true" xlatehostkeys="true" assigntovar="$strData$" varupdateonly="true" required="false" title="" />
<input value="$strData$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens timeout="0" >
<nextscreen name="Screen2" />
</nextscreens>
<recolimit value="10000" />
</screen>
<screen name="Screen2" entryscreen="true" exitscreen="false" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
</description>
<actions>
<input value="'6[enter]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens timeout="0" >
<nextscreen name="Screen3" />
</nextscreens>
</screen>
<screen name="Screen3" entryscreen="false" exitscreen="false" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
<numfields number="55" optional="true" invertmatch="false" />
<numinputfields number="7" optional="true" invertmatch="false" />
</description>
<actions>
<input value="'[tab]n[tab]n[tab]0[tab]1[tab][tab]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
<input value="$strdata$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
<input value="'[field+][enter][enter]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens timeout="0" >
</nextscreens>
</screen>
</HAScript>
------------------------------
Steven Lukas
------------------------------