Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 950

Re: How much ABAP740 (read: functional ABAP programming) is too much?

$
0
0

Now, that's why I answered in the blog discussion ABAP News for 7.40, SP08 - FOR Expressions , with the question if expressions really make sense in that case ...


The answer to the above question "how much functional ABAP is too much" should be:


You use functional ABAP for two reasons:


  • you can code easier
  • your programs become better readable


In the moment, one of the above breaks, you don't use functional ABAP, but split into several statements

Of course this is also a question of taste, your skills and your human reader's skills.


I'm using functional ABAP productively, but I don't overdo it (as in some examples demonstrating the capabilities).


A typical all day example goes as follwos. What looks better?


DATA language TYPE string.

IF sy-langu = 'D'.

   language = 'DE'.

ELSE.

   language = 'EN'.

ENDIF.

cl_abap_docu_external=>get_abap_docu_for_adt(

    EXPORTING

      language language

   IMPORTING

     html      =     DATA(html) ).


or



cl_abap_docu_external=>get_abap_docu_for_adt(

    EXPORTING

      language COND #( WHEN sy-langu = 'D' THEN `DE` ELSE `EN` )

   IMPORTING

     html      =     DATA(html) ).


Clearly the second, I got rid of helper variable language and the IF block. It was much easier for me to write that down because I coded the condition where I need it and the code is much better readable than in the old style.


Other typical example for language dependency:



DATA text TYPE string.

IF sy-langu = 'D'.

   text = `Hallo`.

ELSE.

   text = `Hello`.

ENDIF.

DATA(html) `<html><body>` &&

               text &&

`</body></html>`.


vs.


DATA(html) `<html><body>` &&

               COND #( WHEN sy-langu = 'D' THEN 'Hallo' ELSE 'Hello' ) &&

`</body></html>`.


KISS!


Its the little things that count ...
















Viewing all articles
Browse latest Browse all 950

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>