Wednesday, October 29, 2014

Destination None? Seriously?

I have been around for a while, working with SAP and debugging quite considerable amounts of coding.
There was one piece I never really understood, but always took for granted, which is the statement 'Destination None' after a call function. Destination None sound a little like the road to nowhere...

When working with SAP ABAP, you have several options for building up your coding and calling other pieces of coding, such as 'Submit, Call Method, Call Transaction, Call Function, call-ICT, call transformation, perform etc.

Some are old, some are new, some are good, some are not.
Personally, I prefer an object oriented approach, and definitely dislike call transaction and submit. But maybe that's just taste, and sometimes, you just have to use what SAP has delivered.

So in the end, we can use a mix of calls, procedures, methods and functions to eventually get to Rome.

Of course, the different roads have different features, which can be used to the programmers benefit. For instance, 'Call function' has some features that can come in handy.

Some background on functions in ABAP.

We probably all know that you can call remote functions directly. Basically, calling a remote function allows you to step synchronously to another system, perform a function there, and get back.


That's an easy one. The function will be called in the system specified by parameter 'dest'.


This one is a little more expert... This is the asynchronous brother of the first option, where 'dest' again is the system the function will be called in.

Destination None.

So, to get back on the original topic, I sometimes noticed a 'remote' function call to a destination called 'NONE'. I never really understood why someone would do this. Why would you tell the system to call a function in another system, and then use the current system as the destination (destination NONE in SM59 will always point to the current system)?

The answer lies in something called 'SAP LUW' (not to be confused with database LUW). When coding in ABAP, all code that is processed will normally be within a single 'Logical Unit of Work' (LUW). 
Calling functions, creating objects, calling methods will not change this. This is a good thing, as this allows you to have a continuous flow through your code, with the system remembering previous steps and data operations.

In some cases, you might want to force using a different LUW, for instance if you are sure that whatever happens in the function you are calling, you wouldn't want that to influence what you currently have in memory.

In this case, you can use Call Function <function> Destination 'NONE'. The function will be called, but your current processing will not be affected.