ibm-midrange - 在 DSPF 中包含带有 MSGID 的动态文本

标签 ibm-midrange rpgle rpg

我正在修改一个交互式程序,使 DSPF 具有输出字段:

MSGERR        80A  O 24  2MSGID(&§MSGID FILE_MSG) 

我将 ID 传递给 MSGID,它工作得很好。

现在我收到一条这样的消息:

VALUE CAN BE: &1, &2, &3

我需要用文本替换 &1、&2、&3。

用现在的方法可以吗? 因为我无法直接在 RPGLE 上操作 MSGERR,因为它不可见。

最佳答案

不,你不能。我更喜欢消息子文件,而不是使用 MSGID、ERRMSGID 等。它看起来像这样:

 A* ========================================================================
 A* Message Subfile
 A* ------------------------------------------------------------------------
 A          R MSGSFL                    SFL
 A                                      SFLMSGRCD(24)
 A            MSGKEY                    SFLMSGKEY
 A            PGMQ                      SFLPGMQ
 A* ------------------------------------------------------------------------
 A* Message Subfile - Control forrmat
 A* ------------------------------------------------------------------------
 A          R MSGCTL                    SFLCTL(MSGSFL)
 A                                      OVERLAY
 A                                      SFLINZ
 A                                      SFLPAG(1)
 A                                      SFLSIZ(2)
 A                                      SFLDSP SFLDSPCTL
 A  52
 AON52                                  SFLEND(*PLUS)
 A            PGMQ                      SFLPGMQ

要使用它,您可以将消息发送到程序消息队列,然后将 MSGCTL 作为屏幕事务的一部分写入。因此,如果您的屏幕上通常有一个名为 RECORD 的记录格式,您可以这样做:

pgmq = <Program Name>;
write msgctl;
exfmt record;

程序消息队列中的任何消息都将显示在显示屏上第 24 行的单行子文件中。该子文件是可滚动的。

您将需要两个子过程来轻松完成此工作,一个用于写入消息,另一个用于清除消息队列。我将其命名为 ClearDspfMsg(pgmq)SendDspfMsg(pgmq: msgid: msgdata)

程序如下:

// ------------------------------------
// Clear Display File Messages
// Clears the messages in the display file message subfile
//
// Parameters:
//  pgmq        - Program message queue. This must be the same as the pgmq
//                specified in the display file.
// ------------------------------------
dcl-proc ClearDspfMsg Export;
  dcl-pi *n;
    pgmq           Char(10) const;
  end-pi;

  dcl-ds ec            LikeDs(errCode_t) Inz(*LikeDs);

  qmhrmvpm(pgmq: 0: '': '*ALL': ec);
  // TODO Provide error checking here
end-proc;

// ------------------------------------
// Send Message to Display File (MSGID)
// Sends a message to the display file message subfile
//
// Parameters:
//  pgmq        - Program message queue. This must be the same as the pgmq
//                specified in the display file.
//  messageId   - The message id of the message to be sent
//  messageData - Message data for replacement values in the message. Format
//                of the message data is defined by the message. This is
//                optional, if missing, blanks are used.
//  messageFile - The qualified name of the message file containing the
//                message. The first 10 characters is the messafe file name,
//                the second 10 characters is the library. This is optional,
//                if blank, CNVMSG in *LIBL is used.
// ------------------------------------
dcl-proc SendDspfMsg Export;
  dcl-pi *n;
    pgmq           Char(10) const;
    messageId      Char(7) const;
    messageData    Varchar(256) const options(*varsize: *nopass);
    messageFile    LikeDs(qualName_t) const options(*nopass);
  end-pi;

  dcl-ds msgf      LikeDs(qualName_t) Inz(*likeds);
  dcl-ds ec        LikeDs(errCode_t) Inz(*likeds);

  dcl-s msgData    Char(256) Inz('');

  if %parms() >= %parmnum(messageData);
    msgData = messageData;
  endif;
  if %parms() >= %parmnum(messageFile);
    msgf = messageFile;
  else;
    msgf.name = 'MSGF';  // This is your default message file
  endif;

  qmhsndpm(messageId: msgf: msgData: %size(msgData): '*INFO': pgmq: 0: '': ec);
  // TODO Provide error checking here
end-proc;

我有 qmhsndpmqmhrmvpm 的原型(prototype),但您可以轻松地在文档中查找这些原型(prototype)以及错误代码参数的格式。

在事务开始时调用 SendDspfgMsg() 发送消息,并调用 ClearDspfMsg() 清除消息队列。 PGMQ 对于所有这些部分应该具有相同的值,并且它会正常工作。

注意:这不适用于 RPG,因为您无权访问子过程。如有必要,将您的程序转换为 RPGLE,它将正常工作。或者在这种情况下使用子例程而不是子过程。

关于ibm-midrange - 在 DSPF 中包含带有 MSGID 的动态文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55265359/

相关文章:

stored-procedures - 存储过程尝试读取未提交的数据,尽管将隔离级别指定为读取已提交

ibm-midrange - 如何在 RPGLE 中获取角色的 EBCDIC 值?

java - 通过 AS400 验证连接

c# - 如何以没有前导零的 yyddd 格式格式化日期

c# - 有没有办法使用 SQL 更改 IBM System i(又名 iSeries/AS400)上的用户密码?

loops - 如何转到 RPGLE 循环中的下一个元素?

web-services - 为什么我不能使用超过 65535 RPG IV 的字符长度

ibm-midrange - 检索数据结构字段的名称

java - 在 RPGLE 中使用 String.format

ibm-midrange - RPGLE中EVAL和MOVE有什么区别