Need a COBOL QMHRTVM Example

200 pts.
Tags:
COBOL
SQL
Does anyone have a code snippet they would be willing to share that demonstrates the parameter setup and the call for the API QMHRTVM? I am lousy with API's but I need to incorporate this one into two of my SQLCBLLE Programs.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Not exactly a code snippet, but here’s a COBOL example from Chapter 10 (Message APIs) of my book APIs at Work 2nd Edition:

<pre>
PROCESS NOMONOPRC.

IDENTIFICATION DIVISION.
PROGRAM-ID. FigC10_11.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT QSYSPRT ASSIGN TO PRINTER-QSYSPRT.

DATA DIVISION.
FILE SECTION.
FD QSYSPRT.
01 Print-Line PIC X(100).

WORKING-STORAGE SECTION.
COPY QMHRTVM OF QSYSINC-QCBLLESRC REPLACING
==01 QMH-RTVM-RTVM0300==
BY ==01 QMH-RTVM-RTVM0300 IS TYPEDEF==.
COPY QLG OF QSYSINC-QCBLLESRC.
COPY QUSEC OF QSYSINC-QCBLLESRC.

01 Qualified-Message-File.
05 Message-File-Name PIC X(10) VALUE “QCPFMSG”.
05 Message-Library-Name PIC X(10) VALUE “QSYS”.
01 Receiver.
05 Base TYPE QMH-RTVM-RTVM0300.
05 Variable PIC X(10000).
01 Got-One.
05 PIC X(03).
05 Working-Message-ID PIC X(07).
01 Message-Text-Pointer POINTER.
01 Help-Text-Pointer POINTER.
01 New-Word PIC X(10).
01 Length-Word PIC S9(9) BINARY.
01 New-Message-Text PIC X(132).
01 New-Help-Text PIC X(3000).
01 Length-Replacement-Data PIC S9(9) BINARY VALUE 0.
01 CCSID-To PIC S9(9) BINARY VALUE 0.
01 CCSID-Rpl-Data PIC S9(9) BINARY VALUE 0.
01 Hits PIC S9(9) BINARY.
01 Message-Wait PIC X(01).

LINKAGE SECTION.
01 Word PIC X(10).
01 Message-Text PIC X(132).
01 Help-Text PIC X(3000).

PROCEDURE DIVISION USING Word.
MAIN-LINE.
IF ADDRESS OF Word = NULL
DISPLAY “Required word parameter not passed”
ACCEPT Message-Wait
STOP RUN
END-IF
OPEN OUTPUT QSYSPRT
MOVE 0 TO BYTES-PROVIDED OF QUS-EC

* Convert the parameter value to uppercase
MOVE LOW-VALUES TO QLG-CCSID-REQCTLBLK
MOVE 1 TO Type-Of-Request OF QLG-CCSID-REQCTLBLK
MOVE 0 TO CCSID-Of-Input-Data
MOVE 0 TO Case-Request
COMPUTE Length-Word =
FUNCTION LENGTH(FUNCTION TRIMR(Word))
CALL LINKAGE PRC “QlgConvertCase” USING
BY REFERENCE QLG-CCSID-REQCTLBLK,
BY REFERENCE Word,
BY REFERENCE New-Word,
BY REFERENCE Length-Word,
BY REFERENCE QUS-EC

* Get the first message in Qualified-Message-File
CALL “QMHRTVM” USING BY REFERENCE Receiver,
BY CONTENT LENGTH OF Receiver,
BY CONTENT “RTVM0300″,
BY REFERENCE Working-Message-ID,
BY REFERENCE Qualified-Message-File,
BY CONTENT ” “,
BY REFERENCE Length-Replacement-Data,
BY CONTENT “*NO “,
BY CONTENT “*NO “,
BY REFERENCE QUS-EC,
BY CONTENT “*FIRST “,
BY REFERENCE CCSID-To,
BY REFERENCE CCSID-Rpl-Data
PERFORM WITH TEST BEFORE UNTIL
MESSAGE-ID OF Receiver = SPACES
IF LENGTH-MESSAGE-RETURNED OF Receiver > 0
SET Message-Text-Pointer TO ADDRESS OF Receiver
SET Message-Text-Pointer UP BY
OFFSET-MESSAGE-RETURNED OF Receiver
SET ADDRESS OF Message-Text TO Message-Text-Pointer
CALL LINKAGE PRC “QlgConvertCase” USING
BY REFERENCE QLG-CCSID-REQCTLBLK,
BY REFERENCE Message-Text,
BY REFERENCE New-Message-Text,
BY REFERENCE LENGTH-MESSAGE-RETURNED
OF Receiver,
BY REFERENCE QUS-EC
INSPECT New-Message-Text TALLYING Hits
FOR ALL FUNCTION TRIMR(New-Word)
MOVE SPACES TO New-Message-Text
END-IF
IF (Hits = 0) AND (LENGTH-HELP-RETURNED OF Receiver > 0)
SET Help-Text-Pointer TO ADDRESS OF Receiver
SET Help-Text-Pointer UP BY
OFFSET-HELP-RETURNED OF Receiver
SET ADDRESS OF Help-Text TO Help-Text-Pointer
CALL LINKAGE PRC “QlgConvertCase” USING
BY REFERENCE QLG-CCSID-REQCTLBLK,
BY REFERENCE Help-Text,
BY REFERENCE New-Help-Text,
BY REFERENCE LENGTH-HELP-RETURNED
OF Receiver,
BY REFERENCE QUS-EC
INSPECT New-Help-Text TALLYING Hits
FOR ALL FUNCTION TRIMR(New-Word)
MOVE SPACES TO New-Help-Text
END-IF
IF Hits NOT EQUAL 0
MOVE MESSAGE-ID OF Receiver TO Working-Message-ID
WRITE Print-Line FROM Got-One
MOVE 0 TO Hits
END-IF
* Get the next message
CALL “QMHRTVM” USING BY REFERENCE Receiver,
BY CONTENT LENGTH OF Receiver,
BY CONTENT “RTVM0300″,
BY REFERENCE MESSAGE-ID OF Receiver,
BY REFERENCE Qualified-Message-File,
BY CONTENT ” “,
BY REFERENCE Length-Replacement-Data,
BY CONTENT “*NO “,
BY CONTENT “*NO “,
BY REFERENCE QUS-EC,
BY CONTENT “*NEXT “,
BY REFERENCE CCSID-To,
BY REFERENCE CCSID-Rpl-Data
END-PERFORM
CLOSE QSYSPRT
STOP RUN.
</pre>

To try and put the sample program in context, it essentially scans the QCPFMSG *MSGF looking for all messages that contain a given Word in either the first or second level text. Prior to the scan the program also converts all text to uppercase (which is why you see references to the Convert Case API.

Bruce Vining
<a href=”http://www.brucevining.com/”>http://www.brucevining.com/</a>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • FCARPENTER
    Thank you for the example, I really appreciate it. Frank Carpenter
    200 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following