cancel
Showing results for 
Search instead for 
Did you mean: 

Handle empty JSON message in REST receiver adapter

poornimal_nathan
Explorer
0 Kudos

Hi,

I'm trying to implement a scenario where either of 2 mappings will be executed. If there is no JSON message output triggered from any one mapping, then I currently get an error from the target side since my message is empty. I need to make sure there is no error registered on PI side. Can someone help me regarding the same?

Accepted Solutions (0)

Answers (2)

Answers (2)

poornimal_nathan
Explorer
0 Kudos

Hi Harish,

Thanks. I will try this out.

Edit: Harish's extended receiver determination suggestion did the trick.

Harish
Active Contributor
0 Kudos

Hi Poornima,

Please provide more details about your scenario and error.

regards,

Harish

poornimal_nathan
Explorer
0 Kudos

Hi,

It goes like this.

IDoc

|

Segment 1 -> Mapping1 -> JSON1 -> URL1 of target

|

Segment 2 -> Mapping2 -> JSON2 -> URL2 of target

There are different structures for corresponding segments in an IDoc and they will hit different URLs in the target system. Now if there is data in segment 1 then mapping 1 will execute and hit URL1. And same of segment 2. But if there is no data in segment 1, then an empty JSON message is created. This throws an error in PI. I don't want that to happen since data from segment 2 will flow into another URL from the same IDoc.

Harish
Active Contributor
0 Kudos

Hi Poornima,

I believe you have multimapping in SAP PI/PO to create two outputs from same IDOC message from different source segment. So in multi mapping you can put the condition in creation of parant node (message 1 or message 2) if the condition did not met then the output will not be generated. and target interface will not be triggered.

regards,

Harish

poornimal_nathan
Explorer
0 Kudos

Hi Harish,

Thanks for that. I have created 2 separate mappings for this scenario. And the creation of the parent node is based on a complex scenario. So, if I put the condition in RD of the ICO, then the logic might go for a toss. I want to control this from the receiver channel side. Is that possible?

Harish
Active Contributor
0 Kudos

Hi Poornima,

I still not understand how you can call two message mapping from the same source message (IDOC in this case). Can you please details on this.

I believe you must have two receiver interface and are they part of one ICO? If they are then you can put condition interface determination level to stop the message.

regards,

Harish

poornimal_nathan
Explorer
0 Kudos

Hi Harish,

It goes like this.

Mapping1 = IDoc -> JSON1

Mapping2 = IDoc -> JSON2

If there is no segment for JSON1 or JSON2, then an empty message is created. I want to stop it in PI without any message. And yes, both are in the same ICO. I can't enter the condition in receiver determination or interface determination since the logic is complex and is based on the fields in the segments at 2/3 levels. So I pass the IDoc to both mappings. If the message is created, then it will flow to the target system. If not, it should not trigger an error in the PI.

Harish
Active Contributor
0 Kudos

Hi Poornima,

AFAIK - there is no standard way to stop the message in receive channel once it is pass from interface determination step.

If the logic is complex and xpath condition can not fulfill, then you should use the enhance receiver determination to retrieve receiver based on mapping logic. Please refer the below wiki for more details.

Step by Step guide to Explain Enhanced Receiver Determination - Application Server Infrastructure - ...

regards,

Harish