Skip to Content
Personal Insights
Author's profile photo Brandon Caulfield

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!

 

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo James Bungay
      James Bungay

      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.

       

      Author's profile photo Michelle Crapo
      Michelle Crapo

      Nice thanks for sharing the code.  Another great way to do this.

      Author's profile photo Brandon Caulfield
      Brandon Caulfield
      Blog Post Author

      I really like this solution being a big fan of the REDUCE operator ? Thanks for sharing!

      Author's profile photo Michelle Crapo
      Michelle Crapo

      Very nice.  You shared the code and the "why" behind it.  I've not had that question asked to me yet.

      Author's profile photo Brandon Caulfield
      Brandon Caulfield
      Blog Post Author

      Thanks Michelle Crapo, I've also only seen it come up recently so perhaps we might see a bit more in the future. Always best to be prepared!

      Author's profile photo Michelle Crapo
      Michelle Crapo

      I totally agree.

      Author's profile photo Jacques Nomssi Nzali
      Jacques Nomssi Nzali

      FizzBuzz is a Rosetta Code's task with existing ABAP solutions.

      Fun fact: you can use the Scheme solution in ABAP Scheme.

      JNN

      Author's profile photo Brandon Caulfield
      Brandon Caulfield
      Blog Post Author

      That’s incredibly interesting, thank you for sharing!

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Interviewer: So, how would you implement FizzBuzz in ABAP?

      Me: Google-> FizzBuzz site:blogs.sap.com -> jackpot

      That's pretty much my typical approach to ABAP development. 🙂

      Author's profile photo S Abinath
      S Abinath

      Interesting