在DSPF中具有带有MSGID的动态文本

时间:2019-03-20 16:09:47

标签: ibm-midrange rpgle rpg

我正在修改一个交互式程序,其DSPF带有一个Output字段:

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

我将一个ID传递给MSGID,它可以正常工作。

现在我收到这样的消息:

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

我需要用TEXT替换&1,&2,&3。

是否可以使用当前方法? 因为我看不到RPGLE上的MSGERR,所以无法直接对其进行操作。

1 个答案:

答案 0 :(得分:4)

不,您不能。而不是使用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的原型,但是您可以很容易地在文档中查找这些原型以及错误代码参数的格式。

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

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