Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Michael_Keller
Active Contributor
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

Michael

 

 
6 Comments
joltdx
Active Contributor

Wat.

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.
ENDIF.
APPEND ls_data TO lt_grouped_table.
ENDLOOP.

" 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... 😁😁

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

By the way: Nice to read from you, jolt242.
joltdx
Active Contributor
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!
marco_hammel2
Participant
Hi keller.m ,

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 €. 🤷
ennowulff
Active Contributor
I would like to have something like
DATA myObject TYPE REF TO cl_something ALLOW INITIAL.

or
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.
Michael_Keller
Active Contributor
0 Kudos
Such as "METHODS meth DEFAULT IGNORE|FAIL"?

(Link to SAP Docu)

 
Labels in this area