cancel
Showing results for 
Search instead for 
Did you mean: 

Error Handling in SAP Gateway

Former Member
0 Kudos

Hi Gurus,

I have a question on the Error Handling Methods in SAP Gateway. Can you please help here.

Scenario: I have a successful/Warning message and I want to log into Apps log (IWFND/APPS_LOG) in a Hub Deployment model.

We can raise the Technical exception  / Business Exception using /IWBEP/CX_MGW_TECH_EXCEPTION and /IWBEP/CX_MGW_BUSI_EXCEPTION.

But I think we should not raise an exception if the log is of type Success / Warning.

Can you please help here?

Thanks & Regards,

Mohamed Meeran

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Meeran,

I don't think we need to insert our success/failure messages through some code into the logs which will be logged in IWFND/APPS_LOG.

Those logs are not meant to add our messages sent as part of our business use case.

We do not have any control over here as GW frame will log those to monitor if service is actually successfully fired or failed with appropriate messages.


Suggestion would be to raise an exception when ur Create/Delete/Update fails with all the messaged returned by the back-end logic.


For Create->


On Success- U can maintain separate table which will contain warnings/success messages and return it when along with the data.


On Failure - raise an reception and log the messages into message container.


For Update/Delete, content is not returned if its a Success case.


For Update ->

On Failure - Since no content is returned on success, so raise exception only if failed with all the error messages.

For Delete ->

On Failure - Since no content is returned on success, so raise exception only if failed with all the error messages.


We can insert custom messages into the response header which we get on success during Delete/Update operations but doing this is not advised.


Code snippet to raise exception ->

Regards,

Ashwin




Former Member
0 Kudos

Hi Ashiwn,

Thanks a lot for you response.

As I said earlier, it is a Hub deployment and in my scenario logging into some custom backend table will not be helpful. I found a way to log the messages into application log as below.

*Log Message into Application Log
     lo_logger = /iwfnd/cl_logger=>init_logger(
       iv_userid = sy-uname
       iv_requestguid = lv_request_id
       ).

     lv_msg_handle = lo_logger->get_logger( )->log_step_init(
       iv_msg_id = lc_log_msg_id "Message Class
       iv_msg_number = 001 "Message Id
       iv_agent = lc_log_agent_name "any identifier
       ).

     lv_msg_text = lv_exc_msg.

     lo_logger->get_logger( )->log_message(
       iv_msg_type   = /iwfnd/cl_logger=>info  "Info 'I'/ Success 'S' / Warning 'W' / Error 'E' / Cancel 'A'
       iv_msg_id       = lc_log_msg_id "Message Class
       iv_msg_number   = 001
       iv_msg_text   = lv_msg_text
       iv_agent      = lc_log_agent_name  "any identifier.
       iv_msg_handle = lv_msg_handle
       iv_log_msg_text = abap_true ).
     lo_logger->close_logger).


which is successfully logging the messages in to application log. But can you please kindly advise, why these logs are not meant to add our messages sent as part of our business use case? especially when we need the logs in the Gateway system.


Appreciating your valuable advise.


Thanks & Regards,

Mohamed

AshwinDutt
Active Contributor
0 Kudos

Hello Meeran,

Good that u r able to see messages in logs

Are u not displaying error/success messages on UI5 applications to the end user ?

U would like to just log S/W/E messages is it  and do not want to show to end user ?

We usually display that on screens if any success/error messages are sent from back-end.

We usually create an internal table to capture the return messages from our BE logic and then we send it as a GW response During CREATE operations.

So that is why i said we need not to insert those messages in IWFND/APPS_LOG logs as we already displaying on application.

I think my initial understanding was wrong about the question Now i could understand the scenario.

So in that case i think u can log messages there.

Regards,

Ashwin

Former Member
0 Kudos

Hi Ashwin,

Thanks a lot for your response on this.

May be I was not very clear with my previous reply. The Logs are been captured in the Application Log, but into the Back End system and not in the Front End system. PFA screenshot also on the same.

In my scenario, there are multiple application which is hosted across multiple systems and all of them are hosted via single Gateway system as a Hub Deployment. The Business wants one central place to capture all the messages(Success / Warning / Info / Abort) which makes their monitoring job easy.

Please advise, are these application logs meant to capture logs only in Back End system only?. Whereas I have enabled the application log using class /IWFND/CL_LOGGER (FrontEnd Logger) and ideally the logs should have been captured in the FronEnd system(Gateway System) whereas not captured. Can you please advise, do we have any way to capture the logs in Gateway system ?

Thanks & Regards,

Mohamed Meeran

AshwinDutt
Active Contributor
0 Kudos

Hello Meeran,

Looks like you need to pass the system alias name as to IV_SYSTEM_ALIAS ( System-Alias which is Created between GW and the respective Back-End system ) to the method LOG_MESSAGE.

May be from this framework might extract the GW System Name and then Log the messages in /n/IWFND/APPS_LOG of GW Hub system.

Not very sure. Please check once.

Regards,

Ashwin

Answers (1)

Answers (1)

kammaje_cis
Active Contributor
0 Kudos

Mohamed,

Here you go.

Logging in SAP NetWeaver Gateway - SAP NetWeaver Gateway - SAP Library

See the links inside for logging in various scenarios.

Thanks

Krishna