Skip to Content

The problem recently we have come across was handling runtime exceptions while implementing java mapping program to map and validate source EDI messages to target. Since we develop our java mapping in external IDE (like NWDS, eclipse) and use it as mapping program, but the exceptions raised during mapping are not caught unless we handle it explicitly also provide message trace in SXMB_MONI. 

Sample Business Case:

We need to get the source EDI message, validate it and map to the target structure. While validating the time we need to throw runtime exceptions with specific message, provide message trace in SXMB_MONI to find where exactly the validation failed in mapping.  

Problem Faced: 

While mapping, the exceptions raised in java program are not caught and also it became difficult to trace in SXMB_MONI for any kind of messages.

The follwoing statement

AbstractTrace trace = (AbstractTrace) param.get (StreamTransformationConstants.MAPPING_TRACE);

 Throws NullPointerException while executing in NWDS. 

Solution:

Normally while mapping, the exceptions raised are of type StreamTransformationException, in our java program we need to throw this exception explicitly using the following statement in catch block. 

throw new StreamTransformationException(“”, exeption_obj);

In order to provide message trace with any fields from our program in SXMB_MONI, we need to use MessageTrace/AbstractTrace

But using these in NWDS causes NullPointerException as we need to call the setParameter  method explicitly.Mapping frame calls this methods implicitly, we need not to worry about this Exception and we can use our mapping program in our mapping .

 

Steps while programming:

  1. Implement your mapping program, when ever handling exceptions throw StreamTransformationException in catch block.
  2. Create Instance for MappingTrace or AbstactTrace (as shown in above statement).
  3. Add your message by using method’s of above classes by category (Info/Warning/Debug).
  4. Pass the fields from the program to trace message, in order to check the status in SXMB_MONI.

 

 Exception Raised While Testing Maping 

image 

MessageTrace In SXMB_MONI

image

To report this post you need to login first.

4 Comments

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

    1. PrasannaKrishna Mynam Post author
      The reference of AbstractTrace is to be initialized with the Hashmap’s parameter constant
      StreamTransformationConstants.MAPPING_TRACE.
      setParameter() is used to initialize or crate the instance for HashMap.

      Eg:-

      //Creating reference to the Map
      Map param=null;

      setParameter(Map param){
      this.param = param;
      if(param == null)
           this.param = new HashMap();
      }

      //Later part of our program we assign constant parameter to AbstractTrace

      AbstractTrace trace = null;
      trace =     (AbstractTrace) param.get(
      StreamTransformationConstants.MAPPING_TRACE);

      (0) 
      1. sachin kotalwar
        hi Prasanna,
        I was looking for a something which will not give error in NWDI. I wish SAP would have given an option to write output of ‘trace’ to console for testing in NWDI 🙂
        sachin
        (0) 

Leave a Reply