HTTP status codes in ABAP

I’ve been working a lot with OData and REST lately, outbound as well as inbound. Some of my code needs to handle HTTP status codes in different ways. Since I didn’t want to hard-code the status codes in my code, I started looking around for standard classes and interfaces which could be of use to me. This blog post is a brief summary of what I found.

Interface IF_HTTP_STATUS

The interface IF_HTTP_STATUS contains a list of status texts in the form of constants of data type STRING. Some examples are:

CONSTANTS reason_200 TYPE string VALUE 'OK' . "#EC NOTEXT
CONSTANTS reason_201 TYPE string VALUE 'Created' . "#EC NOTEXT

This interface is quite handy if you want to present the user with not only a status code but also the corresponding text.

Class CL_REST_STATUS_CODE

The classes CL_REST_STATUS_CODE and /IWCOR/CL_REST_STATUS_CODE also contain constants. The two classes are identical in regard to the constants but have some minor differences in one of the methods.

The constants in these two classes contain the numerical HTTP status codes of data type I. Some examples are:

constants GC_SUCCESS_OK type I value 200 . "#EC NOTEXT
constants GC_SUCCESS_CREATED type I value 201 . "#EC NOTEXT

The classes have some useful static methods as well:

  • Method GET_REASON_PHRASE: Takes in a status code and returns the corresponding status text. The method actually uses interface IF_HTTP_STATUS to accomplish this.
  • Method IS_CLIENT_ERROR: Takes in a status code and returns abap_true if the status code is in the range 400 – 499. Otherwise, the method returns abap_false.
  • Method IS_REDIRECTION: Takes in a status code and returns abap_true if the status code is in the range 300 – 399. Otherwise, the method returns abap_false.
  • Method IS_SUCCESS: Takes in a status code and returns abap_true if the status code is in the range 200 – 299. Otherwise, the method returns abap_false.
  • Method IS_SERVER_ERROR: Takes in a status code and returns abap_true if the status code is in the range 500 – 599. Otherwise, the method returns abap_false.
  • Method IS_ERROR: If one of the methods IS_CLIENT_ERROR and IS_SERVER_ERROR return abap_true, this method also returns abap_true. Otherwise, the method returns abap_false.

Limitations

The interface and the two classes mentioned in this blog post don’t contain constants for every HTTP status code mentioned in the Wikipedia article. However the most common ones are available, and for the use cases I’ve experienced so far the interface and the classes have been sufficient.

Happy coding!

The progress indicator in ABAP reports

I’m sure most of you have been asked to develop a report displaying a progress indicator during the execution of the report. I just developed a migration report which needs several minutes to execute, so I decided to put in a progress indicator.

When running the ATC check with abapOpenChecks for the report I’ve developed, I got an error telling me that function module SAPGUI_PROGRESS_INDICATOR should not be used. Even though this is documented in the documentation of check 53 for abapOpenChecks, an SAP Knowledge Base Search for information on what should be used instead of function module SAPGUI_PROGRESS_INDICATOR didn’t give me any results. The documentation at abapOpenChecks states that class CL_PROGRESS_INDICATOR should be used instead of the function module. I decided to write this short blog post to share this information with the community as well as to provide a tiny code example.

Instead of using the function module like this:

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
  EXPORTING
    percentage = progress_percent
    text       = progress_text.

You can use the class like this:

cl_progress_indicator=>progress_indicate(
    i_text = |Processing: { current_record }/{ total_records }|
    i_output_immediately = abap_true ).

The result isn’t exactly the same since the function module only works with percentages. This could easily be achieved with the class as well, but in this case, I was more interested in seeing how many of the total records had been processed.

Happy coding!

My two first conference talks

I held my two first conference talks earlier this week at the Swedish SAP user group conference SAPSA IMPULS 2019, and in this post I will share some of my experiences. SAPSA IMPULS is a yearly conference targeting people working with SAP solutions in the Nordics, and the event had more than 800 attendees this year. This was a two days event, and I was scheduled to hold two different presentations, one on each day of the conference.

Day 1 – a broader appeal

On the first day I held a presentation titled “How to stay up-to-date within the SAP space with openSAP“. openSAP is an excellent MOOC platform to stay current with the SAP space and acquire new skills. I explained the structure and advantages of using MOOCs in general and openSAP in particular, to expand my knowledge within SAP. I also shared my personal experiences attending about 30 openSAP courses.

I was quite nervous before the talk, since I haven’t really done any public speaking. After having rigged up my computer, there were still about ten minutes to wait for the planned starting time of my talk. I found these ten minutes the most nervous part of the talk, since I was just standing around waiting. Thankfully a former colleague of mine came into the room about five minutes before my talk was to start, and we engaged in some small-talk which helped me relax. Once I got started presenting, my nerves calmed down. There were seven parallel tracks as I was presenting, and my presentation attracted about 70 people. This meant that the room was full, but not crowded. After the presentation, several attendees came forward to discuss some questions they had and they also gave me some positive feedback. I think that the talk was generally well-received.

Before holding my presentation, I had the opportunity to attend the key-note. This enabled me to tie the topic of the key-note back into my own presentation. The key-note was mainly about customer experiences and experience management. Since there is currently a course on the topic on openSAP, The Power of Experience Management, I referenced this in my presentation. Even though that this was just a small detail, I still think that it was a nice bridge between the key-note and my presentation.

I was also able to attend a few other sessions before I held my presentation. This made me realize that I had completely overlooked the fact that I should have included a slide presenting the organization I work for in my presentation. I was able to correct this mistake in the break before my presentation.

Day 2 – the technical niche talk

On the second day, I held a talk titled “Improving your ABAP code quality with open-source tools“. The talk was about how we have improved our code quality through the use of open-source tools at the organization where I work. The tools I explained and demonstrated are:

Since the session was only 20 minutes long, and I had a lot of material to cover, the talk felt a bit rushed. I feel very comfortable with the topic I presented, which probably made me talk a bit more than during my rehearsals of the talk. I felt much more relaxed than on day 1, most likely since the first talk was well received and I had already received positive feedback.

In retrospect, the talk might have been a little too technical for the audience of this conference. However, I still had about 20-25 people showing up. I was approached after this talk with some interesting comments and questions, so even though it was more of a niche talk, I’m happy that I gave it. I also learned a lot as I was preparing for the talk.

Key takeaways

I’m happy to have participated in the conference and to have shared my experiences and knowledge through the two talks. It was a learning experience both when it comes to the subjects I presented as well as regarding the whole process of writing presentation proposals, preparing and finally delivering a talk.

Some of my takeaways are:

  • Start preparing the talks early. I fine-tuned my talks over a period of about two months, and still ended up doing last-minute changes.
  • Ask someone to review your presentation. I asked my manager as well as my colleagues to review the presentations, and this gave me some valuable feedback.
  • Rehears, rehears, rehears. I practiced my talks alone as well as in front of my wife and kids, and it was important for discovering transitions in the presentations which weren’t smooth enough as well as practicing my presentation skills.
  • Try to engage in small-talk and use the opportunity to network ahead of a presentation. This helped me shift into a more talkative mode and made me more relaxed.
  • People want to hear your story. Both of my presentations contained personal stories about why the topics were important to me, and how they helped me to be successful in real-world situations. This made the presentations as well as me as a presenter easier to relate to.
  • Attend the key-note, so that you can relate to it in your own presentation if relevant.
  • Attend other sessions to see how the other presenters are presenting. This helped me fine-tune my presentation.

If you are considering submitting an abstract to a conference, just do it! It’s a fun learning experience!