Home > AS/400 Tips > iSeries programmer tips > Simple screen capture
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Simple screen capture


Nick Hobson
04.22.2002
Rating: -4.06- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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)')

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries CL programming
Taking advantage of CL advancements, starting with V5R3
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help

iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

Application Development
iSeries calling an .exe
Top 10 programmer tips
Formatted work job scheduler
Convert system date and time
Mixing free format code with embedded SQL
SQL update a field in one file from a field in another file
Webcasts for iSeries programmers
Programming advice from the pros
Easy code copying via the drag and drop method
Setting FTP time-outs

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts