HCL Z and I Emulator: PCSAPI を使った自動化

2020/8/13 - 読み終える時間: 6 分

HCL Z and I Emulator (ZIE) は、文字通り IBM のメインフレームにアクセスするためのエミュレーターであり、高度が付加機能を備えています。そのひとつの API について書かれた英語版ブログの記事 Automation using PCSAPI の日本語版を掲載します。


PCSAPI を使った自動化

2020年8月11日

著者: Sudhir Ranjan Rout / Senior Developer, HCL

画像の説明

はじめに

ZIEWin は、IBM メインフレーム/AS400/VT セッションと通信するためのエミュレータインターフェイスを提供します。これは、ホストのデータの読み取りと更新を行い、他のアプリケーションとホストをインターフェイスするために使用されます。トランザクションのエミュレータ画面上で手動タスクを実行すると、反復的になり、長期的には以下の問題を持つことになります。

  • 非効率
  • 冗長性があり、エラーが発生しやすい
  • 時間がかかるため高価

ZIEWin は、ユーザーが一般的に実行されるタスクを自動化できるようにするために、多くのアプリケーション・プログラミング・インターフェース (API) を公開しています。異なるAPIは特定の機能のセットで提供されており、異なる目的に使用でき、ユーザーの要件に基づいて異なるプログラミングインターフェイスを提供します。異なる API は、Visual Basic for Applications(したがって、MS Officeアプリケーションをサポート)、C/C++、C#、Java、LotusScript、REXなどのプログラミング言語をサポートしています。

ZIEWin が提供する API セットとその機能のリストは以下のとおりです。

  • Windows セッション API (PCSAPI) のためのZと私のエミュレータ:ZIEWin のセッション管理
  • エミュレータ高レベル言語API(EHLLAPI)。セッションが確立されると、ワークステーション アプリケーションとホスト システム間の相互作用を管理
  • Z and I Emulator for Windows Host Access Class Library (HACL)。アプリケーションプログラマがホストアプリケーションに簡単かつ迅速にアクセスできるようにするオブジェクトのセット セッションが確立された後、アプリケーションとホストシステムを使用できます
  • SRPI リクエスタープログラムを書くためのツールを提供する拡張コネクティビティファシリティ(ECF)

今回のブログでは、PCSAPI について詳しく見ていきます。

PCS Session APIは、ZIEWin セッションの起動、セッションのオープン、セッションのクローズ、接続、切断を行えます。EHLLAPI API は IBM EHLLAPI 通信標準(TN3270 と TN5250 プロトコル)と密接に結合されているため、セッション管理 API の機能はありません。ZIEWin のセッション API はまた、プリンタ、ページ、クエリワークステーションプロファイル/セッションリスト/エミュレータのステータスを設定するための機能を提供します。これらの API は、EHLLAPI/HACL API と組み合わせて使用することで、自動化サイクルを完成させられます。

関数呼び出し規約

ZIEWin セッション API は、プログラミングを簡単にするために、すべての関数のシンプルなプロトタイプに従っています。上述したように、これらの API は複数のプログラミング言語(VBA、C/C++、C#など)を使用してアクセスしてプログラムできます。

関数タイプ: API の戻り値の型 関数名: 呼び出される関数 引数: 関数に渡される入力引数で、1 から 3 までの値があります。

以下に、最も一般的に使用されるPCS APIとそのプロトタイプを示します。

1. PCConnectSession BOOL WINAPI PCConnectSession(char cShortSessionID)

2. PCDisconnectSession BOOL WINAPI PCDisconnectSession(char cShortSessionID)

3. pcsQueryConnectionInfo BOOL WINAPI pcsQueryConnectionInfo(char cShortSessionID, CONNECTIONINFO *ConnectionInfo)

4. PCStartSession ULONG WINAPI PCStartSession(PSZ lpProfile, char cShortSessionID, USHORT fuCmdShow)

5. pcsStopSession BOOL WINAPI PCStopSession(char cShortSessionID, USHORT fuSaveProfile)

6. pcsQuerySessionList ULONG WINAPI pcsQuerySessionList(ULONG Count, SESSINFO *SessionList)

これらのAPIの詳細については、こちらをご覧ください。

MacroExecutionBlockDiagram:

次の図は、ZIEWin の API - マクロエンジン - IBM ホストのフローのハイレベルビューを示しています。

画像の説明

コード スニップされたVBAコード (Excel 用)

A. Declarations

'Declaration for PCSAPI functions and defining their prototype to VBA engine
Declare PtrSafe Function pcsStartSession Lib "PCSAPI32.DLL" (ByVal buffer As String, ByVal SessionID As Integer, ByVal CmdShow As Integer) As Integer
Declare PtrSafe Function pcsStopSession Lib "PCSAPI32.DLL" (ByVal SessionID As Integer, ByVal SaveProfile As Integer) As Integer
'Declaration for EHLLAPI functions and defining their prototype to VBA engine
Declare PtrSafe Function ZIEWin_SendKey& Lib "PCSHLL32.DLL" Alias "hllapi" (HllFunctionNo&, ByVal HllData$, HllLength&, HllReturnCode&)
Declare PtrSafe Function ZIEWin_SetCursor& Lib "PCSHLL32.DLL" Alias "hllapi" (HllFunctionNo&, ByVal HllData$, HllLength&, HllReturnCode&)
Declare PtrSafe Function ZIEWin_ConnectPS & Lib "PCSHLL32.DLL" Alias "hllapi" (HllFunctionNo&, ByVal HllData$, HllLength&, HllReturnCode&)
'Defining Global Variable
Dim SessionID As Integer
Dim ProfileName As String

B. Entry Function

'Function entry point which drives the automation
Sub PCSAPISample()
SessionID = 65 'Session A
ProfileName = "Iseriesdemos.WS" 'change it session name of your preference
'call the LaunchZIEWinSession Sub
LaunchZIEWinSession ProfileName, SessionID
'Create a EHLLAPI connection with ZIEWin
ConnectZIEWinSession
'Move the cursor to desired location on the ZIEWin Screen
moveCursor 8, 53, 10
'Send a string to ZIEWin Screen
sendString "HelloWorld"
'Disconnect and close the ZIEWin Session
StopZIEWinSession SessionID
End Sub

C. ConnectZIEWinSession

'Function to establish connection to a ZIEWin session
Public Function ConnectZIEWinSession()
    HllFunctionNo = 1
    HllData = "A"
    HllLength = 4
    HllReturnCode = 0
    RC = ZIEWin_ConnectPS(HllFunctionNo, HllData, HllLength, HllReturnCode)
    If RC = 0 Then
        MsgBox "Connection Established"
    Else
        MsgBox "Connection Failed"
    End If

End Function

D. LaunchZIEWin Function

'Function to launch the ZIEWin session
Public Function LaunchZIEWinSession(ProfileName As String, SessionID As Integer)

    On Error Resume Next
    Dim RC As Integer

    'PCSStartsession take 'session profile file' and the session ID (65->ASCII->'A')
    RC = pcsStartSession(ProfileName, SessionID, 2)

    If RC = 0 Then
        MsgBox "ZIEWin Launched Successfully"
    Else
        MsgBox "ZIEWin Launched failed"
    End If
End Function

E. Stop ZIEWin Session

'Function to disconnect and stop the ZIEWin session
Public Function StopZIEWinSession()

    On Error Resume Next
    Dim ziewinStop As Boolean

    'PCSStopSession takes Session ID and save mode as input
    ziewinStop = pcsStopSession(SessionID, 2)
    If (ziewinStop = True) Then
        MsgBox "ZIEWin Closed Successfully"
    End If
End Function

サンプルコードをダウンロードしてみてください。

PCSAPIの呼び出しをテストするために使用できるエクセルのサンプルを添付します。

PCSAPI_ZIEWin _Sample

お問い合わせ

HCL ZIEでのWebアプリケーションの整理、自動化機能、ラボサービスの提供に関する詳細については、以下までお問い合わせください。

ZIO@hcl.com

Sudhir Ranjan Rout

Developer, Lab Services

このブログについて

HCL Japan の Software 部門の複数担当者で HCL Software 全般について記しています。

Tags

Academy Accelerate Accelerator Ambassador AoC AppDev Pack AppScan ASoC beta BigFix BigFix 9.5 BigFix_Wiki BigFix Workspace branding CAA Client Applicatin Access cloud Cloud Apps Cloud Native Commerce Common Local License Server community companion Compass compliance Connections Connections 6.5 ConnectionsDocs Connnections CVE-2021-44228 developerWorks DevOpes Velocity DevOps DevOps Code ClearCase DevOps Code RealTime DevOps Deploy DevOps.Launch.AppScan DevOps Model RealTim DevOps Plan DevOps Test DevOps Velocity Digital Experience document Doino Volt Domino Domino AppDev Pacl Domino Leap Domino Volt Domino管理者アップデート認定試験対策 DQL DRYiCE dW dx Enterprise Integrator event fix fix_list fixlist forum General guide HCAA HCL Ambassador HCL Ambassadors HCL Domino REST API HCL OneTest Embedded HCL Z and I Emulator HCL Z and I Emulator for Transformation HCLSoftware U hints_and_tips history HTMO IBM_i ID_Vault iNotes ios ios13 ipad iPhone IZSAM KEEP Launch Launch.DevOps Leap Link logo MarvelClient mobile mui nds2019 ndv12beta News Noets/Domino Nomad Nomad Mobile Nomad Web Notes Notes/Domino Notes/Domino 10 Notes/Domino 11 notes-domino-9-10-limited-supportability-as-of-202204 Notes/Domino V12 Notes/Domion Notes/Domno notescons Now on_premises OneDB OneTest OnTime osaka press_release relay REST RTist SafeLinx Sametime Sametime 11 SoFy support survey system_requirement techtek Traveler Traveler 10 Traveler for Microsoft Outlook traveler.zip Unica Unica Discover Unica Interact UrbanCode Deploy UrbanCode Velocity v11 V12 Verse Verse Mobile Verse On-Premises VersionVault Volt Volt MX Volt MX Go Volt MX サンプルアプリ Webinar win7 Wordload Automation Workload Automation youtube Z Z Abend Investigator Z and I Emulator Z and I Emulator for Transformation Z and I Emulator for Web Z and I Emulator for Web Client Z Asset Optimizer Z Data Tools Z Software Asset Manager ZAI ZAO ZIE ZIE for Transformation ZIE for Web ZIE for Windows ZIET ZIETrans ZIEWeb うるう年 イベント ウェビナー ガイド クラウド クラウド終了 サイジング サポート サポート技術情報 サポート期間 サポート終了 セキュリティ セキュリティー セキュリティー脆弱性 セミナー ダイバーシティー ダウンロード テクてく テクてく Lotus 技術者夜会 ニュース ノーツコンソーシアム バージョンアップ パフォーマンス パートナー ベータ ポートフォリオ ライセンス 九州地区 Notes パートナー会 互換性 出荷日 各種ご案内資料 研修