Previous Topic: Manipulate and Extract Data

Next Topic: Using Mapping Services

Use a Map in NCL Processing

After a map is defined, it can be used to interpret the contents of MDOs in NCL.

The following example demonstrates how MDOs can be used for the encapsulation and transmission of data in NCL.

Procedure A can receive messages from procedure B, and perform some desired action on some of the data in the message. If the action is completed successfully, procedure A will return the modified data to the initial sender (procedure B), with a message indicating the operation was successful. If the action is not completed successfully, procedure A will carry out some extra error processing and then return a message to the sender indicating that the operation was unsuccessful.

The message data is mapped with a map that contains the following components:

ACTION

The action to be performed.

ASN.1 Type: GraphicString

DATA

The data on which to perform the action.

ASN.1 Type: OCTET STRING

ACTIONRESULT

The result of the action processing.

ASN.1 Type: ENUMERATED

Procedure A could be as follows:

.RECEIVELOOP
   &INTREAD MDO=ACTIONPARMS  -* Read the MDO from the sender
   &ASSIGN VARS=SENDER FROM MDO=$INT.SOURCE.NCLID
                             -* Extract the senders NCLID
                             -* from the system MDO, $INT,
                             -* which is always set after an
                             -* &INTREAD operation, and is
                             -* mapped by the $MSG system map
   &ASSIGN VARS=ACTION FROM MDO=ACTIONPARMS.ACTION
                             -* Extract the type of
                             -* action to be performed
   &ASSIGN VARS=ACTIONDATA FROM MDO=ACTIONPARMS.DATA
                             -* Extract the data on which
                             -* to perform the action
-EXEC ACTPROC ACTION=&ACTION ACTIONDATA=&ACTIONDATA
                             -* Call proc to carry out
                             -* action
   &IF &RETCODE EQ 0 &THEN + -* Check return code from action
      &DO
         &ASSIGN MDO=ACTIONPARMS.DATA FROM VARS=ACTIONDATA
                             -* Set modified data in MDO
         &ASSIGN MDO=ACTIONPARMS.ACTIONRESULT DATA=OK
                             -* Set result of action in MDO
         &WRITE NCLID=&SENDER MDO=ACTIONPARMS
                             -* Return modified MDO to caller
      &DOEND
   &ELSE +
      &DO
         &GOSUB .ERRORPROC    -* Do error processing
         &ASSIGN MDO=ACTIONPARMS.ACTIONRESULT DATA=FAIL
                             -* Set results of action in MDO
         &WRITE NCLID=&SENDER MDO=ACTIONPARMS
                             -* Return MDO to caller
      &DOEND
&GOTO .RECEIVELOOP           -* Loop to process next message

You can see that Mapping Services greatly simplifies the NCL required to process complicated data formats. Often, externally-sourced data has a format which is awkward to manage in NCL. In these situations, Mapping Services can prove to be a very useful tool.