Skip to Content
Personal Insights
Author's profile photo Michael Keller

Null-Safe Navigation Operator

Dear community, have you ever heard of the “Null-Safe Navigation Operator”? Me not which isn’t bad either. I can’t know everything, especially when it’s fairly new. I came across the term on a blog together with an example like that:

" old syntax 
IF lv_object IS NOT INITIAL.

" new syntax
IF lv_object?.

That caught my attention (not because of the Hungarian notation). I know the “Safe Navigation Operator” which is available in various programming languages to avoid the “Pyramid of doom“. So some kind of syntactic sugar.

I was interested in the example because I wouldn’t use IS NOT INITIAL on a reference variable. In this case IS BOUND would be my choice. Also, I wouldn’t expect ABAP language designers to put a “?.” combination at the end of an statement. That looks a bit strange.

After some research: I couldn’t find anything about this in the official latest ABAP keyword documentation (ABAP for Cloud Development). Also, I could not develop a syntactically error-free example on the SAP BTP ABAP Trial Environment.

Either there is an innovation for ABAP coming in the near/far future or the information is … simply wrong. Who knows the truth? 🙂

Oh, there is another “interesting” example on the mentioned blog that doesn’t work for me:

" old syntax
IF lv_condition = 'X'.

" new syntax
IF lv_condition = 'X' ? 'Yes' : 'No'.


Many thanks for reading and stay healthy




Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Jörgen Lindqvist
      Jörgen Lindqvist


      I think that blog post is full of "simply wrong" mixed with a bit of confusion and sprinkled with wat on top...

      For instance, what has this got to do with optional parameters?

      " Old Syntax:
      CALL METHOD lo_object->method.
      " New Syntax:
      lo_object->method( ).


      How is this old syntax method chaining?

      " Old Syntax
      CALL METHOD lo_object1->method1.
      CALL METHOD lo_object2->method2.
      " New Syntax
      lo_object1->method1( )->method2( ).


      But my personal favorite might be the "GROUP Operator for Grouping":

      " Old Syntax:
      SORT lt_table BY field.
      LOOP AT lt_table INTO ls_data.
        IF lv_group <> ls_data-field.
          lv_group = ls_data-field.
          APPEND INITIAL LINE TO lt_grouped_table ASSIGNING FIELD-SYMBOL(<fs>).
          <fs>-group_field = lv_group.
        APPEND ls_data TO lt_grouped_table.
      " New Syntax:
      lt_grouped_table = lt_table GROUP BY ( field ) ASCENDING INTO TABLE @DATA(result).

      Wait, what?

      I think I could comment on each of the bullets in that blog post, but I'll just carry on with my day now, riding on the wave of laughter and confusion after getting my brain woken up you and that blog post... 😁😁

      Author's profile photo Michael Keller
      Michael Keller
      Blog Post Author

      AIGAC = [A]rtificial [I]ntelligence [G]enerated [A]BAP [C]onfusion? 😉

      By the way: Nice to read from you, Jörgen Lindqvist.

      Author's profile photo Jörgen Lindqvist
      Jörgen Lindqvist

      Thank you ☺️

      Probably. I tried using pretty vague prompts in both GPT-3.5 and GPT-4 but couldn't get it to hallucinate at this level though... 😅

      PSA: Beware of the hallucinations people!

      Author's profile photo Marco Hammel
      Marco Hammel

      Hi Michael Keller ,

      That's a another nice example of what could possibly go wrong when it comes to the implementation of control flows in ABAP. To be honest, I've given up on trying to catch all the dangerous things in the SAP community sold as sliced bread create with of for the use of large language models and machine learning.

      Disclaimer: Machine learning is not the problem, but how most people currently using it!

      Please find another example where I believe the developers didn't even try to understand me here. It's imperative when developing software to understand the protocols a software should use and support. This belongs to all layers of the software and the services it uses.

      Well, never mind. My team can easily get day rates above 2k€ when called for forensics or emergency help but managers get stingy to send their developers to a training for 700 €. 🤷

      Author's profile photo Enno Wulff
      Enno Wulff

      I would like to have something like

      DATA myObject TYPE REF TO cl_something ALLOW INITIAL.


      myObject = NEW #( ) ALLOW INITIAL.


      so that any command on myObject will return initial values if it is not bound.

      That would save all these CHECK myObject IS BOUND inquiries.

      Author's profile photo Michael Keller
      Michael Keller
      Blog Post Author


      (Link to SAP Docu)