FocMsg

FocMsg is a system stack with one A80 column named Msg. When a Maintain Data procedure executes either an external procedure or a Maintain Data procedure on a remote server (that is, a Maintain Data procedure called using the CALL procname command), all of the messages that the called procedure writes to the default output device are automatically copied to the FocMsg stack of the calling procedure. This includes messages issued by TYPE and SAY commands that do not specify a file, and informational and error messages.

If the external procedure calls other external procedures, all messages posted by the chain of external procedures are copied to the same FocMsg stack in the calling Maintain Data procedure. Non-App Studio logic (such as a compiled 3GL program or a CICS transaction) that is called from an external procedure does not copy to FocMsg.

FocMsg is global to each Maintain Data procedure.

Example: Cycling Through All the Messages in FocMsg

You can use FocCount to cycle through all of the messages that have been posted to FocMsg:

COMPUTE Counter/I3=1;
REPEAT FocMsg.FocCount;
   TYPE "<FocMsg(Counter).Msg";
   COMPUTE Counter=Counter+1;
ENDREPEAT

Example: Retrieving Messages Posted by an External Procedure

This example illustrates how to retrieve messages that were posted by an external procedure.

Client Procedure

1.   MAINTAIN FILE MOVIES 
2.   INFER MovieCode Title INTO MoviesInfo; 
3.   EXEC GetMovie INTO MoviesInfo; 
4.   COMPUTE I/I4=1; 
5.   REPEAT 3; 
6.   TYPE 
7.   "Movie code is: << MoviesInfo(I).MovieCode" 
8.   "        Title: << MoviesInfo(I).Title"; 
9.   COMPUTE I=I+1; 
10.  ENDREPEAT 
11.
12.  COMPUTE I=1; 
13.  REPEAT FocMsg.FocCount; 
14.  TYPE "Here are the messages from the server: <<FocMsg(I).Msg"; 
15.  COMPUTE I=I+1; 
16.  ENDREPEAT 
17.  END

External procedure GetMovie

1.   TABLE FILE MOVIES 
2.   PRINT MOVIECODE TITLE 
3.   ON TABLE PCHOLD 
4.   END 
5.   RUN 
6.   -TYPE "Finished with the movies retrieval"