LOCKMSG Tool for COBOL

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

The LOCKMSG tool from the QUSRTOOL library offers programmers a very useful and consistent method for handling record locks. LOCKMSG can sense a locked record condition and then send a message to the workstation operator describing the problem. What really makes the tool effective is that it allows the user to respond to the locked condition three different ways.

o "R" to retry the read operation. o "J" to send a message to the job that holds the lock and request the operator to release the transaction. o "S" to send a message to the system operator describing the problem.

The documentation for the tool describes a technique for using the LOCKMSG in RPG. Unfortunately for COBOL programmers, it doesn't describe how to use the tool in COBOL. In fact, it states "The same technique cannot be used in COBOL."

I was convinced that it could be made to work with COBOL. As a result, I simulated the same technique in COBOL with a few lines of code and one CL program. Operationally, it functions exactly the same way as it does in RPG.

Here's how it can be done.

Create CL program GETPGMMSG, shown in 3.

Create CL program GETPGMMSG, shown in Figure 3.

Simulate the RPG data structure in COBOL that is passed to TAADBFFC (see 4).

Simulate the RPG data structure in COBOL that is passed to TAADBFFC (see Figure 4).

The loop in 5 is performed once and repeated if the file status is equal to "9D" (record locked).

The loop in Figure 5 is performed once and repeated if the file status is equal to "9D" (record locked).

The system sends a CPF5027 message to the COBOL program on a locked-record timeout condition. A call to GETPGMMSG retrieves the text for the message and places it in position 91 of the WS-STATUS area. The error status value can be hard-coded to simulate the RPG error status equivalent because COBOL can monitor directly for a locked-record condition.

The QUSRTOOL CL program, TAADBFFC, receives the working storage area (data structure) as a parameter. It checks to ensure that the specific error status is 01218, which indicates a locked record.

The tool will not fail when called from COBOL, but it may fail in RPG if the error status in the program status data structure is not 01218.


LOCKMSG Tool for COBOL

Figure 3 CL Program GETPGMMSG

 PGM PARM(&MSGTXT) DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(80) RCVMSG PGMQ(*PRV) MSGTYPE(*LAST) MSG(&MSGTXT) ENDPGM 
LOCKMSG Tool for COBOL

Figure 4 WS-STATUS Data Structure

 ..... *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 01 WS-STATUS. 05 FILLER PIC X(90). 05 MSG-TXT PIC X(80). 05 FILLER PIC X(38). 05 STATUS-CODE PIC X(05) VALUE "01218". 05 FILLER PIC X(120). 
LOCKMSG Tool for COBOL

Figure 5 Checking for Record Lock

 ..... *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 PERFORM WITH TEST AFTER UNTIL FILE-STATUS NOT EQUAL "9D" READ PDMOPT IF FILE-STATUS = "9D" CALL "GETPGMMSG" USING MSG-TXT CALL "TAADBFFC" USING WS-STATUS END-IF END-PERFORM. 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: