Sunday, November 16, 2014

MEC How to Get the Last API Name, Status and the Error Message

Recently, I've been working with Logging API errors using another custom M3 API (CRKR03) as a part of MEC development. Some API's had returned NOKs with additional white spaces i.e. TABS and Spaces exceeding the field (MESG) length of the CRKR03 that we have used to log errors.

First, let me explain how I've received the API NOK message by setting the ErrorHandling Property of the M3 API to Ignore M3 NOK.


if(!isLastAPICallOK() && getLastMIProgram().trim().equals("PDS001MI"))
{
    g_ErrorMessage = getLastAPIMessage().trim().replaceAll("\\s+", " ");
    ........ 
}  
Some API NOK messages are like the below (Note the additional white spaces)
'Item number 010411 does not exist                     
                                            
                                            
                                            
              WIT0103          ' 

No comments:

Post a Comment