cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping / Adapters: Write files in case of error

Former Member
0 Kudos

Hi pros,

is there any possibility to write an error file to a specified directory (we need this for an external job control system) in the following cases?

  1. Somewhere in the message mapping an error occurs (for example because a value is empty that should not be empty). It would be nice if there would be a mechanism that catches all error, not only for a single field. Is this possible?
  2. The receiver adapter fails, e.g. because of wrong user credentials

Thanks in advance!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I think I joined lately ,below are my views on this .

>>is there any possibility to write an error file to a specified directory (we need this for an external job control system) in the following cases?


Alert framework can take care of all kind of exceptions.So I don't want to invest time and efforts on this by writing custom java code .


I will ask my admin team to create a mail id and I subscribe to Alerts.

I will create an interface Mail to File and writes files to desired loc.

Regards

Venkat

former_member186851
Active Contributor
0 Kudos

For Case 1:

There is a cleanup method(you can see in function tabs of mapping) which will be executed after mapping.You can write logic here to write the file in case if the mapping program fails.

For Case 2:

In case of channel fails,You can configure alerts from alert inbox you can poll and write it as a file.

iaki_vila
Active Contributor
0 Kudos

Hi Raghuraman,

I didn't test to change cleanUp method, have you checked if it works in the case any mapping exception is raised?. If the answer is yes, it could be very helpful to avoid or deal differently in mapping exceptions in some particular scenarios.

Regards.

Former Member
0 Kudos

Case 1: But if an exception is raised, is the cleanup method executed then? If yes, can I get the exception-object?

Case 2: SAP PI 7.31 Java-only. How can I configure an alert?

former_member186851
Active Contributor
0 Kudos

Hello Inaiku,

Yes It works.But In case if the mapping is executed more than one time, I guess there might be some issues.

former_member186851
Active Contributor
0 Kudos

Stefan no exception object will be raised,You can write the file with content " as error in mapping" with some values passed.

If you want to raise exception alerts are best,Ianki villa has already share the link for configuring alerts

Ryan-Crosby
Active Contributor
0 Kudos

Hi Stefan,

One approach I had tried (unsuccessful) was to use the init and cleanup methods in a graphical mapping to store all exceptions in an ArrayList and then in the cleanup if the list was not empty then try to generate a message attachment showing the necessary data and after that is created then throw a StreamTransformationException so the message will go into an error state.  For some reason the attachment was not getting created - but even when no exception was thrown so it's possible it may work in your case.  I had opened an OSS message with SAP and they had suggested that the code I had in place should be working but it was only a like to have solution so we didn't pursue it any further.  As far as #2 I would go with what others have said and count on the alert framework to do the job for you.

Regards,

Ryan Crosby

former_member186851
Active Contributor
0 Kudos

hello,

you can write an file.I have done the same requirement

iaki_vila
Active Contributor
0 Kudos

Hi Stefan,

I don't know why you can generate files if you have the alert monitoring in PI that it can send a mail in case of error, check Michal's example

However, depending your PI version you have a several webservices that you can use to take the monitor logs:

Later you will can generate the files.

From adapter side you can extend it with a module, but i haven't so clear if you have a previous exception you can catch it in the next module.

Regards.