Skip to Content
Personal Insights

The SAP Technical ABAP Interview Question You Might Have Never Heard Of

As many of you know, a technical ABAP interview can be quite a daunting prospect. Today I wanted to help with that and highlight a technical ABAP interview question you might have not prepared for or even heard of. A lot of good interviewers out there will want to get a feel for not only your technical ABAP coding skills but also how you approach relatively abstract problems that may not easily translate directly into code.

 

One such example is the game of FizzBuzz. If you’ve come from other programming languages you might’ve already heard of this but essentially the interviewer would ask you to do the following.

  • Output a table list that runs through a number range e.g. from 1 – 100.
  • Every time a number is exactly divisible by 3 (no remainders) then replace that number with the word “FIZZ”.
  • Every time a number is exactly divisible by 5 (no remainders) then replace that number with the word “BUZZ”.
  • And finally if divisible by both 3 and 5 – replace that number with the word “FIZZBUZZ”.

 

The interviewer will be looking at 3 things:

  • How do you approach a simple problem like this.
    • Do you just quickly slap together something that works in a more or less functional way OR
    • Do you structure things in a more OO fashion with the view of keeping things as readable and maintainable as possible.
  • How familiar you are with both old and new ABAP syntax
  • The complexity of your finished code i.e. is it simple and easy to read or is it quite complex and hard to make out at first glance.

 

There are many ways to approach a problem like this but you can find my attempt in the GitHub repository here:

https://github.com/brandoncaulfield/youtube-abap/blob/master/z_fizzbuzz.abap

 

And also a video demostrating how I put the solution together explaining each step im my logic.

 

If you guys have a different solution please feel free to leave it in the comments below for us all to see ๐Ÿ™‚

 

Thanks for reading!

 

9 Comments
You must be Logged on to comment or reply to a post.
  • Hi Brandon,

    We have a monthly code challenge and one of the earlier challenges was FizzBuzz.

    Simple, but very interesting to see how people come up with different implementations.

    Below is an example of one of our team members solutions.

    I personally agree that code challenges to assess/evaluate potential developers is a great approach.

    Nice blog!

    Cheers,

    James

    class YL_CC_FIZZ_BUZZ_BCUSER definition
      public
      final
      create public .
    
    public section.
        interfaces zif_cc_fizz_buzz.
        aliases fizzbuzz for ZIF_CC_FIZZ_BUZZ~FIZZBUZZ.
    
        interfaces if_oo_adt_classrun.
        aliases main for IF_OO_ADT_CLASSRUN~MAIN.
    protected section.
    private section.
    ENDCLASS.
    
    
    
    CLASS YL_CC_FIZZ_BUZZ_BCUSER IMPLEMENTATION.
      METHOD ZIF_CC_FIZZ_BUZZ~FIZZBUZZ.
        fizzbuzz = cond #( let result = |{ cond #( when number mod 3 = 0 then |Fizz| ) }{ cond #( when number mod 5 = 0 then |Buzz| ) }|
                           in when result ne space then result else number ).
      ENDMETHOD.
    
      METHOD IF_OO_ADT_CLASSRUN~MAIN.
        out->write( reduce #( init text type string
                              for index = 1 until index > 100
                              next text = |{ text }{ fizzbuzz( index ) }\n| ) ).
      ENDMETHOD.
    ENDCLASS.