Skip to Content

Demonstrating the use of Catch Throw Action Blocks

Applies to- 12.2.3 Build (177)

Summary

This document explores the exceptional handing feature of SAP MII using catch throw action blocks introduced in MII 12.2. The document takes us step by step showing how to use the catch throw action block and how to handle the exceptions generating during runtime in MII transactions.

Author: Ruchir Batra

Created On: 25 May 2012

Table of Content

Initial Set Up /Introduction to Example Set Up

Configuring the Tracer

Configuring the SAP JCo Start Session

Configuring the Catch /Throw Action Block

Complete Flow Diagram

Testing the Positive Scenario

Testing the Negative Scenario

Conclusion

Initial Set Up /Introduction to Example Set Up

Open up the Work Bench found under Content Development from MII Main Menu.

Create a new transaction in the Work Bench (Catalog Tab). And create a local variable named value and giving it an initial value of 1. Its value will help us determining the process flow through the transaction.

/wp-content/uploads/2012/05/pic1_105271.gif

In our example depicted below, we will be trying to set up a connection between MII and ECC.

We will go through the positive scenario where in successful connection will be established and also the negative scenario where in un-successful connection is established and hence the exception being caught at run time.

Configuring the Tracer

Under the Logging Header on left below, one can find – Tracer block. In Configuration Link- one can link any value to its message text tag (as below).

We are linking the local variable which we created above to Tracer Message tag.

/wp-content/uploads/2012/05/pic2_105350.gif

Configuring the SAP JCo Start Session

We can configure the SAP JCo Start Session giving in details like SAP Server/Client along with Login Credential ie UserId/Password through which it will be able to connect to SAP ECC.

Configuring the Catch /Throw Action Block

The Catch Action Block is set up after the SAP JCo Start Session since we will try to raise the exception through it and can see the exception being caught in Catch Action Block.                                             Similarly, we have Throw Action Block- which is used to throw any message throughout the transaction. It is used to put the transaction into exception state, which is later handled by end of transaction or catch block in transaction (following after the Throw Action Block).

Complete Flow Diagram

/wp-content/uploads/2012/05/pic3_105351.png

Above Part- REF1

Lower Part – REF 2

The above two REF Diagram showcase the complete process flow in the transaction.

Testing the Positive Scenario

We tested a positive scenario by setting up a SAP JCo Start Session with correct credentials and correct SAP System details.

On execution- we found:

Tracer_InitialValue and Tracer_Value represent the value 1 and then since no exception is generated via JCo Session, the execution flow doesn’t pass through the Catch_0 action block and hence it doesn’t reach the tracer Tracer_Catch_Value (extreme left below, REF2).

The Throw action block throws an exception which is caught via Sequence 7, Catch_1 and is traced via tracer in subsequent block.

This is how the process flow takes place and catch/throw action block works for a positive test scenario.

Testing the Negative Scenario

We set up an invalid system details in JCo Start Session so that it fails to connect the system.

On execution – we found:

Tracer_InitialValue and Tracer_Value represent the value 1 and then since an exception is generated via SAP JCo Start Session, it got caught in Catch Action Block and process flow enters the Sequence 4, REF 2 (left below) and Tracer_Catch_Value records the exception message generated by the JCo block. We have mapped Tracer_Catch_Value to Last Error Message of JCo Action block; hence the message can be viewed in the tracer (Tracer_Catch_Value).

The process flow via Sequence 5 for Throw Action block remains the same as of positive test scenario. Since this portion is set up to generate an exception and later catch it. Only thing to note is: The Catch Action Block- ie Sequence 7 is must, if we are setting up a Throw exception logically in our transactional logic.

This demonstrates the use of Catch / Throw Action Block and its use in case of exception generation.

Conclusion

The above two scenario showcase us the use of catch and throw action block and how we can use them in exception handling within MII transactions. They are very useful for runtime exception handling and there use should be taken as best practice for MII projects.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply