× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks all. I used the API similarly to Thomas' example.

On Thu, Apr 22, 2021 at 5:22 AM Thomas Raddatz <thomas.raddatz@xxxxxx>
wrote:

This is a basic example of retrieving the message text of a message
description:

**free
// ================================================================== *
// Retrieve message text with QMHRTVM API
// ================================================================== *
ctl-opt main(main) dftactgrp(*no) actgrp(*new);

dcl-pr main extpgm('RTVMSGTXT');
end-pr;

dcl-pr retrieveMessageText like(string_t) extproc(*dclcase);
i_library char(10) const;
i_msgF char(10) const;
i_msgID char(10) const;
i_msgData char(4096) options(*varsize) const;
end-pr;

// Commonly used templates
dcl-s string_t varchar(2048) template;

dcl-ds qObj_t qualified template;
name char(10);
lib char(10);
end-ds;

dcl-ds errCode_t qualified template;
bytPrv int(10);
bytAvl int(10);
excID char(7);
reserved_1 char(1);
excDta char(256);
end-ds;

// The program entry point
dcl-proc main;
dcl-pi *n;
end-pi;

dcl-s msgText like(string_t);
dcl-s dsplyTxt varchar(50);
dcl-s rc char(1);

msgText = retrieveMessageText(
'QSYS': 'QCPFMSG': 'CPF9811': 'MYPGM MYLIBRARY ');

dsplyTxt = %subst(msgText: 1: 50);

dsply dsplyTxt rc;

end-proc;

// -------------------------------------------------------------------
// Retrieve message text.
// -------------------------------------------------------------------
dcl-proc retrieveMessageText;
dcl-pi *n like(string_t);
i_library char(10) const;
i_msgF char(10) const;
i_msgID char(10) const;
i_msgData char(4096) options(*varsize) const;
end-pi;

// The return value
dcl-s msgText like(string_t);

// Format RTVM0100 of QMHRTVM API
dcl-ds rtvm0100_t qualified template;
bytRet int(10);
bytAvl int(10);
lenMsgRet int(10);
lenMsgAvl int(10);
lenHlpRet int(10);
lenHlpAvl int(10);
data char(4096);
end-ds;

// The Retrieve Message (QMHRTVM) API
dcl-pr QMHRTVM extpgm('QMHRTVM');
o_msgInf char(32767) options(*varsize);
i_length int(10) const;
i_format char(8) const;
i_msgID char(7) const;
i_qMsgF char(20) const;
i_rplData char(32767) const options(*varsize);
i_rpldataLen int(10) const;
i_rplVars char(10) const;
i_rtnCtrlChrs char(10) const;
io_ErrCode char(32767) options(*varsize);
end-pr;

dcl-ds qMsgF likeds(qObj_t);
dcl-ds errCode likeds(errCode_t);
dcl-ds rtvm0100 likeds(rtvm0100_t);

qMsgF.name = i_msgF;
qMsgF.lib = i_library;

QMHRTVM(rtvm0100: %size(rtvm0100): 'RTVM0100': i_msgID: qMsgF:
i_msgData: %len(i_msgData): '*YES': '*NO': errCode);

if (errCode.bytAvl = 0 and rtvm0100.lenMsgRet > 0);
msgText = %subst(rtvm0100.data: 1: rtvm0100.lenMsgRet);
else;
msgText = '';
endif;

return msgText;

end-proc;


Thomas.

-----Ursprüngliche Nachricht-----
Von: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> Im Auftrag von Darryl
Freinkel
Gesendet: Mittwoch, 21. April 2021 21:31
An: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Betreff: Re: I need a way to retrieve messages from a message file and
merge the MSGDTA values into it.

What makes this difficult is there are about 100 places needing different
substitution values and using the replace functions is a lot of work.

I am hoping to find a system api that can do the substitution and return
the complete message.

Doing it this way, I can add a call in a common subroutine in the program
to the api.

I am playing around with the QHRTVMSG api but do not fully understand all
the parameters at this time

Darryl

On Wed, Apr 21, 2021 at 1:08 PM Kevin Bucknum <Kevin@xxxxxxxxxxxxxxxxxxx>
wrote:

The send message api's like QMHSNDPM have places to put the
replacement variables. You could use that and pull the message back
in. Or you can use replace ins SQL, or %scanrpl in RPG.

On Wed, 2021-04-21 at 13:03 -0400, dfreinkel@xxxxxxxxxxxxxxxxx wrote:

I have a requirement to modify a program that uses messages from a
message

file to display errors. The program is old and was cloned from an

interactive program that displayed messages. It is now a batch program
that

sends the messages to nowhere.





I need to retrieve the message description and merge in the replace
values

for &1, &2... where the MSGDTA exists.





I would like to use the SQL function





Select Message_TEXT from QSYS2.MESSAGE_FILE_DATA but need to find a
way to

replace the &1, &2... with the real values.





Any Ideas?





TIA,





Darryl Freinkel


A4G


Telephone: 770.321.8562 Mobile: 678.355.8562







[https://www.medtronsoftware.com/img/MedtronMinilogo.bmp] Kevin
Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://www.medtronsoftware.com



CONFIDENTIALITY NOTICE

This document and any accompanying this email transmission contain
confidential information, belonging to the sender that is legally
privileged. This information is intended only for the use of the
individual or entity named above. The authorized recipient of this
information is prohibited from disclosing this information to any
other party and is required to destroy the information after its
stated need has been fulfilled. If you are not the intended
recipient, or the employee of agent responsible to deliver it to the
intended recipient, you are hereby notified that any disclosure,
copying, distribution or action taken in reliance on the contents of
these documents is STRICTLY PROHIBITED. If you have received this
email in error, please notify the sender immediately to arrange for
return or destruction of these documents.
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
Darryl Freinkel
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.