Skip to Content
Technical Articles

My solution to the ABAP Community Coding Challenge

The ABAP challenge dates back to February, however, solutions are still being described and discussed, so guess its time to share my solution 🙂

So, tada:

DATA: lv_string  TYPE string,
      lt_words   TYPE STANDARD TABLE OF string,
      lt_letters TYPE STANDARD TABLE OF string,
      lv_word    TYPE string.

lv_string = `ABАP  is excellent `.

SPLIT lv_string AT | | INTO TABLE lt_words.
DELETE lt_words WHERE table_line = ''.

WRITE: / |Number of words: { lines( lt_words ) }|.

LOOP AT lt_words INTO lv_word.

  WRITE: / |Number of unique characters in the word: { lv_word } -|.

  CLEAR lt_letters.
  WHILE lv_word <> ''.
    APPEND lv_word(1) TO lt_letters.
    lv_word = lv_word+1.
  ENDWHILE.

  SORT lt_letters.
  DELETE ADJACENT DUPLICATES FROM lt_letters.

  WRITE |{ lines( lt_letters ) }|.

ENDLOOP.

 

I spent my time making sure the solution is somewhat 702 compatible, and yes, I like prefixes.

This particular ABAP problem can be solved only with very basic syntax and without database access, so my goal was to run the solution outside the ABAP stack! The heavy lifting for this can be found at https://github.com/abaplint/transpiler, bug reports are welcome, but almost everything outside of the example won’t work 😉

Serverless ABAP?

It’s possible to take the above code, and copy-paste to the leftmost column at https://transpiler.abaplint.org, and it will run the actual code!

transpiler.abaplint.org

transpiler.abaplint.org

 

But why keep it in the browser? It is also possible to deploy to

It contains lots of bugs, but feel free to take it for a spin 🙂

/
transpiler.abaplint.org
Be the first to leave a comment
You must be Logged on to comment or reply to a post.