cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to delay IDOC transfer

former_member335553
Active Contributor
0 Kudos

Hi

I have gone through this link on the time delay . When trying to implement it isn't working

Please advise if I am missing something .

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/05/01/how-to-delay-use-wait-step-messag...

My scenario is IDOC to IDOC where on the receiver side I would need a delay of a minute.

public String TimeDelay(String Timevar, Container container) throws StreamTransformationException{

{

try

{

Thread.sleep(60000);

}

catch(InterruptedException ie)

{}

return Timevar;

}}

This delay udf is inserted to the top root node.

FIDCCP02 ----> Delay UDF -------> FIDCCP02

But on the receiver SAP system I get the IDOCS at the same time

Thanks

Anusha

Accepted Solutions (1)

Accepted Solutions (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Anusha,

                   Instead of mapping to the root node , try bringing the UDF to element level. Thus is there is a direct mapping such as

field1(source)--------->field2(target)

here you insert the UDF

public String TimeDelay(String field1, Container container) throws StreamTransformationException{

{

  

    MappingTrace mt = container.getTrace();

    mt.addInfo();

    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

    Date date = new Date();

  try

     {

           mt.addInfo("Current Time: "+dateFormat.format(date)); 

            Thread.sleep(60000);

     }

     catch(InterruptedException ie)

     {}

    

    date = new Date();

    mt.addInfo("Final Time: "+dateFormat.format(date)); 

    return field1;

}

Now put this UDF in Mapping

field1(source)---->UDF---->field2(target).

using trace print the current time before you call Thread.sleep() method and another time after the method is called. Test this using test tab and check if this works. In the blog author mentions to map the UDF to root node but I feel this should also work.

Regards

Anupam

Answers (5)

Answers (5)

bravon33
Explorer
0 Kudos

Hi All,

We have got this to work in our test area by following the instructions in the blog.

When trying it out with one or two messages, we can see the messages appearing in the Scheduled column of Message Monitor whilst the time delay is happening.

However, my concern with this is if we have many messages coming through at the same time (maybe 50+ at the same time), then won't there be an issue with the maximum number of mapping (?) threads that can be used at any one time? And, if so, wouldn't this impact the performance of SAP PI overall and could, therefore, impact other interface messages that may be processing at the same time?

So maybe there is a better way to delay the IDoc transfer where ccBPM isn't an option? I have heard we can use BPM but would that be over complicating the process?

Many Thanks,
Gareth

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

just try this code an let me know if works

String a;

      try

       {                 Thread.sleep (60000);        }

       catch (InterruptedException ie){}

      return a;

use this UDF in between the main nodes to insert the delay

please try it

also check in the SXI_MONITOR if the delay works. you should see some mapping with a delay of a minute betwwen them.

Regards

ambrish_mishra
Active Contributor
0 Kudos

Hi Anusha,

IMO, you should apply this UDF on the IDoc node so that it induces a delay on each Idoc creation.

That should work

Hope it helps!

Ambrish

PS: I agree with Raja here that is is not a best practice.

You can also go for an alternate solution after discussion with the process team.

collect the IDocs in ECC and run a background job every 5 mins to process the IDocs.

Message was edited by: Ambrish Mishra

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

have you try to configure this under communication channel monitoring (top right corner) --> availability time planning.

you can avoid to create an maintain in the future  the UDF

re

regards

former_member335553
Active Contributor
0 Kudos

Sorry I am unable to get you , This UDF is done in the ESR and IDOC receiver channel(ABAP stack adapter ) so no RWB use

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

sorry i assumed that you are in PI 7.3 ussing  ICO.

My misstake

Regards

rajasekhar_reddy14
Active Contributor
0 Kudos

Why don't you try using wait method in ccBPM, using thread sleep code snippet not a best practice .