Partial EHLLAPI input on Z and I Emulator for Windows host screen

Problem
Truncated command text was sent to a host when using HCL Z and I Emulator for Windows.
Cause

If an EHLLAPI application sends a SYSREQ key to the host and then tries to input a command onto the host screen, sometimes only a truncated part of the command is sent to the host. This problem occurs due to lack of synchronization between the SYSREQ processing at the Z and I Emulator for Windows host side and the input of commands from the EHLLAPI application.

When the application sends a SYSREQ command to the host, the following situations occur:
  • The OIA is updated to indicate that you are in a SSCP-LU session.
  • The Z and I Emulator for Windows session sends the AO command (the SYSREQ) to the 3270 host.

As soon as the host receives the SYSREQ, it responds to Z and I Emulator for Windows with the 0x15 or NL (NewLine) code. When Z and I Emulator for Windows processes this NL command by filling the rest of the line with NULLs, and moving the cursor to the beginning of the next line.

A problem occurs when the EHLLAPI application continues to input various commands in the host screen (through the SendKeys function), even before the Z and I Emulator for Windows session has received the NL command from the host and processed it. As a result, a part of the input command is first entered onto the screen, while the NL command is processed and the cursor is moved over to the next line. Then the remaining part of the command is input on the next line. Thus, only the truncated second part of the command is sent to the host, causing erroneous results.

Resolution
The solution for this problem is to force the EHLLAPI application to wait until the NL command is received and processed, before continuing to input the commands to the host screen. Once the session has notified the EHLLAPI application that the host response for SYSREQ has been processed, the EHLLAPI application can then continue with its input (because the session is now in the right state to accept new input). To accomplish this, use the following EHLLAPI function calls:
Start_Host_Notification (23)
Pause (18)
Set_Session_Parameters (9)
Query_Host_Update (24).
Possible code in the EHLLAPI application is as follows:
  • Call Sendkeys(@A@H). This sends the SYSREQ command to the session.
  • Call StartHostNotify with input B, where B indicates notification of both OIA and PS. This tells the session to notify the EHLLAPI application when the session's OIA and/or PS is updated by the host.
  • Call Pause, specifying a sufficient timeout period. This causes the EHLLAPI application to wait until the session notifies it of a host update to the session's OIA and/or PS. This occurs when the session receives the most-awaited host response for the SYSREQ command. Note that if the timeout value has been exceeded, and no host notification has been received, the Pause function call still returns.

Also, for this Pause call to work, you must use the Set_Session_Parameters (9) function call to enable the IPAUSE option. This is required because it tells the Pause API call to return when the host notifies the session of an OIA and/or PS update.

If Pause has returned due to an OIA/PS update (host notification), it has a return value of 26. If this is the case, you are ready to send the host command. Otherwise, you must wait again for the host response.

The EHLLAPI application can continue with the command once it knows that either the OIA or the Presentation Space (or both) has been updated by the host. The QueryHostUpdate is used to check what was updated: that is, whether the OIA alone was updated (return code 21), or the PS alone was updated (return code 22) or whether both the OIA and the PS were updated (return code 23).

For example, the EHLLAPI code might resemble the following part:
Send Keys(@A@H) /* Send SYSREQ command to the host */

Start Host Notification with 'B' in byte 2 /* Enable notification to EHLLAPI application
                                              when session's OIA and/or PS are updated */

Set Session Parms with IPAUSE option /* Allow Pause to be interrupted */

Label WW:

Pause for 15 seconds /* 15 secs is a sample time-out value */

retVal = Query Host Update /* Store return value of QueryHostUpdate() into retVal */

If (retVal = 21 or 22 or 23) /* OIA and/or PS was updated */

Send Keys("Your Input Command to host") /* Send input command to host */

else

goto (Label WW)

Stop Host Notification /* Disable host notification */ 

This is the most appropriate solution for this problem, because the EHLLAPI application waits for the exact minimum time required to allow the session to receive and process the SYSREQ host response, before sending its command input.

Another solution is to add a delay [for example, Sleep(1000)] in the EHLLAPI application between the SYSREQ command and the subsequent command, so that the session has enough time to receive and process the host response. However, this solution is not the best, because the delay might be too little or might be excessive.

Refer to RFC 2355 (TN3270 Enhancements) for more information about the 3270 SYSREQ functionality.