Hallo Helmut,
vielleicht hilft Dir dies:

Simple screen capture
Nick Hobson
22 Apr 2002
Rating: -3.93- (out of 5)

Here is a simple technique for capturing the information on a screen and using it in a program.

My motivation for developing the program below was to save typing when using the STRSRVJOB command. I have recently had to debug many batch jobs. After having issued WRKJOB and typed "STRSRVJOB 123456/USERNAME/JOBNAME" a hundred times, I thought there must be some time-saving technique.

The program below is designed to be invoked from the WRKJOB screen. This screen displays the job number, user, and job name; all required by many job-related commands, such as STRSRVJOB. The program works by capturing the screen image (using the Dynamic Screen Manager APIs), extracting the required job details, and invoking the appropriate command.

The actual command string to be invoked is passed to the program by one of a number of commands. Command SRV passes the string 'STRSRVJOB'. Command PRTLOG passes the string 'DSPJOBLOG OPTION(*OUTPUT)'. The range of job-related commands could easily be extended. Indeed, almost any command could be invoked, given an appropriate screen to capture.



Code


Program GETSCR:

H Dftactgrp(*NO)
H BndDir('QSNAPI')

* Dynamic Screen Manager prototypes...
* Create input buffer:
D CrtInpBuf pr 10i 0 Extproc('QsnCrtInpBuf')
D InitSize 10i 0 Const
D Increment 10i 0 Const Options(*OMIT)
D Maximum 10i 0 Const Options(*OMIT)
D InpBufHnd 10i 0 Const Options(*OMIT)
D ErrorCode 272 Options(*OMIT)
* Read screen without requiring AID key:
D ReadScreen pr 10i 0 Extproc('QsnReadScr')
D NoBytes 10i 0 Options(*OMIT)
D InpBufHnd 10i 0 Const Options(*OMIT)
D CmdBufHnd 10i 0 Const Options(*OMIT)
D EnvHnd 10i 0 Const Options(*OMIT)
D ErrorCode 272 Options(*OMIT)
* Retrieve pointer to buffer data:
D RtvDtaPtr pr * Extproc('QsnRtvDta')
D InpBufHnd 10i 0
D Data * Options(*OMIT)
D ErrorCode 272 Options(*OMIT)
* Delete buffer:
D DltBuf pr 10i 0 Extproc('QsnDltBuf')
D BufHnd 10i 0
D ErrorCode 272 Options(*OMIT)

D JobCommand s 32
D BufHnd s 10i 0
D NoBytes s 10i 0
D ReturnCode s 10i 0
D Screen ds Based(BufPtr)
D JobName 169 178
D JobUser 192 201
D JobNo 217 222
D SelName s Like(JobName)
D SelUser s Like(JobUser)
D CmdStr s 66
D CmdLen s 15 5 Inz(%Size(CmdStr))

C *Entry Plist
C Parm JobCommand

* Create input buffer.
C Eval BufHnd = CrtInpBuf (%Size(Screen) : *OMIT :
C *OMIT : *OMIT : *OMIT)
* Read screen.
C Eval NoBytes = ReadScreen (*OMIT : BufHnd :
C *OMIT : *OMIT : *OMIT)
* Retrieve pointer to buffer data.
C Eval BufPtr = RtvDtaPtr (BufHnd : *OMIT : *OMIT)
* Build Command string.
C x'00':' ' Xlate JobName SelName
C x'00':' ' Xlate JobUser SelUser
C Eval CmdStr = JobCommand + ' JOB(' +
C JobNo + '/' +
C %Trimr(SelUser) + '/' +
C %Trimr(SelName) + ')'
* Delete buffer.
C Eval ReturnCode = DltBuf (BufHnd : *OMIT)
* Execute command against job.
C Call 'QCMDEXC'
C Parm CmdStr
C Parm CmdLen

C Return
The commands below should be created to invoke the program above:

Command SRV:

CMD PROMPT('Start Service Job')
PARM KWD(COMMAND) TYPE(*CHAR) LEN(32) +
CONSTANT(STRSRVJOB)

Command PRTLOG:

CMD PROMPT('Print Job Log')
PARM KWD(COMMAND) TYPE(*CHAR) LEN(32) +
CONSTANT('DSPJOBLOG OPTION(*PRINT)')