
Code vs. Vacancy
We came across a current job posting on LinkedIn that made us smile. In this article, we reverse engineer them.
Table of contents
While browsing LinkedIn, we came across a job posting that we don't want to withhold from you. There they are looking for an ABAP developer with ABAP Coding, here one would assume that only people who have an idea of the subject matter and understand the example would apply.
Introduction
First, let's look at the ad. At first glance, it looks like valid code, except that it's wrapped in bullet points, so it wouldn't be interpretable by the compiler.
Let's take the challenge and validate whether the code was written by a developer or just made up by HR. We assemble the original objects using reverse engineering.
Analysis
In the first analysis, an object of a class is created, if you look at the individual methods of the class, you quickly realize that this class has no interface. At least none is used for the calls, the instantiation runs directly via the class using an inline declaration. With this we can determine what data type the reference "lo_employee" will have.
Class
In the first step, let's create the class. Since it is an execution, we still implement the interface to make a console application out of it.
We now have an empty shell to insert the code:
CLASS zcl_rewe_digital_employee DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_rewe_digital_employee IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
ENDMETHOD.
ENDCLASS.
In the next step we can take over the coding from the job advertisement, but you should make sure to remove the dots here so that we don't get any errors in the compiler. Of course, we are still rewarded with a lot of error messages, because we are still missing a few things:
Refactoring
Next, we should now start refactoring the code to get an activatable class. In the first step we create all the methods, for this we can use the refactoring tools from the ABAP Development Tools (ADT).
After querying the method and the parameters, the method is created in the private area of the class. Furthermore, it is noticeable that the ADTs have slightly changed the code:
lo_employee->connect_to( 'Experten' ) ( 'Workshops/Schulungen' ) ( 'Community' ) ) ).
lo_employee->add_content( 'SAP Learning Hub' ) ( 'Lernzeit' ) ( 'Dev-Buddy' ) ) ).
The brackets and the VALUE statement have disappeared, the refactoring doesn't seem to work properly in this case. But we can first create all the methods in this way and later simply insert the original code again. However, since the methods are called from outside, we still have to set them from PRIVATE to PUBLIC.
After all methods have been created, we still have to define a returning parameter for all methods used with CHECK. CHECK expects a comparison, since none is listed after the check, a boolean value is most likely returned. Accordingly, we need a returning parameter of type ABAP_BOOL or ABAP_BOOLEAN.
Typs
Now that all methods are defined and set to public, we can start typing. The methods have importing parameters and there is an obvious type that is used in the second section to generate the features. This seems to be a structure that will be filled in the following bullet points. Most are simple tables that accept texts, although you cannot use the STRING type here. The literals used can only be used together with fields of type CHAR, other types lead to error messages. The "Training" field is of type ABAP_BOOL because the inline function XSDBOOL is used here, which returns a boolean value. This would generate the following types from the sample code:
TYPES:
tt_char TYPE STANDARD TABLE OF char40 WITH EMPTY KEY,
tt_language TYPE STANDARD TABLE OF char2 WITH EMPTY KEY,
BEGIN OF tt_employee_features,
Personality TYPE tt_char,
Attributes TYPE tt_char,
Experience TYPE tt_char,
Optional_Experience TYPE tt_char,
Nice_to_Have TYPE tt_char,
Languages TYPE tt_language,
Training TYPE abap_bool,
END OF tt_employee_features.
Complete class
As always, here is the complete example, which can also be run and debugged. Only one should not expect any output in this state:
CLASS zcl_rewe_digital_employee DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
TYPES:
tt_char TYPE STANDARD TABLE OF char40 WITH EMPTY KEY,
tt_language TYPE STANDARD TABLE OF char2 WITH EMPTY KEY,
BEGIN OF tt_employee_features,
Personality TYPE tt_char,
Attributes TYPE tt_char,
Experience TYPE tt_char,
Optional_Experience TYPE tt_char,
Nice_to_Have TYPE tt_char,
Languages TYPE tt_language,
Training TYPE abap_bool,
END OF tt_employee_features.
METHODS:
has_sap_business_processes
RETURNING VALUE(rd_result) TYPE abap_bool,
want_to_use_technology
IMPORTING
it_data TYPE tt_char
RETURNING VALUE(rd_result) TYPE abap_bool,
validate_periodically
IMPORTING
it_data TYPE tt_char
RETURNING VALUE(rd_result) TYPE abap_bool,
connect_to
IMPORTING
it_data TYPE tt_char,
add_content
IMPORTING
it_data TYPE tt_char,
add_new_employee
IMPORTING
is_data TYPE tt_employee_features.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_rewe_digital_employee IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA:
ld_studies TYPE abap_bool,
ld_training TYPE abap_bool.
DATA(lo_employee) = NEW zcl_rewe_digital_employee( ).
CHECK lo_employee->has_sap_business_processes( ).
CHECK lo_employee->want_to_use_technology( VALUE #( ( 'BTP' ) ( 'RAP' ) ( 'ODATA' ) ( 'S/4 HAHA' ) ) ).
CHECK lo_employee->validate_periodically( VALUE #( ( 'Qualität' ) ( 'Beratung' ) ( 'Optimale Lösung' ) ) ).
lo_employee->connect_to( VALUE #( ( 'Experten' ) ( 'Workshops/Schulungen' ) ( 'Community' ) ) ).
lo_employee->add_content( VALUE #( ( 'SAP Learning Hub' ) ( 'Lernzeit' ) ( 'Dev-Buddy' ) ) ).
DATA(lt_your_features) = VALUE zcl_rewe_digital_employee=>tt_employee_features(
Personality = VALUE #( ( 'Sorgfalt' ) ( 'Zuverlässigkeit' ) ( 'Engagement' ) ( 'Mut' ) ( 'Verantwortung' ) ( 'Teamgeist' ) )
Attributes = VALUE #( ( 'mutig' ) ( 'wissbegierig' ) ( 'offen' ) ( 'etwas wagen' ) ( 'proaktiv' ) )
Experience = VALUE #( ( 'ABAP' ) ( 'ABAP OO' ) )
Optional_Experience = VALUE #( ( 'SAP Module FI, SD, CO' ) ( 'Schnittstellen IDOC, REST' ) ( 'RAP' ) ( 'Webdynpro' ) ( 'ABAP Unit' ) )
Nice_to_Have = VALUE #( ( 'S/4 HANA' ) ( 'Agile Skills' ) )
Languages = VALUE #( ( 'DE' ) ( 'EN' ) )
Training = xsdbool( ld_studies = abap_true OR ld_training = abap_true )
).
lo_employee->add_new_employee( lt_your_features ).
ENDMETHOD.
METHOD has_sap_business_processes.
ENDMETHOD.
METHOD want_to_use_technology.
ENDMETHOD.
METHOD validate_periodically.
ENDMETHOD.
METHOD connect_to.
ENDMETHOD.
METHOD add_content.
ENDMETHOD.
METHOD add_new_employee.
ENDMETHOD.
ENDCLASS.
Mistakes
Overall, the coding is most likely coming from a developer and not from the HR department itself. Naming the type doesn't feel right as this is actually a structure and not a table. The two variables for training seem to have been defined locally, the correct definition is still missing or has to be completed by the applicant.
Conclusion
Perhaps the applicant should also keep his eyes open and the mistakes found bring plus points with a new employer. Basically, the code was solidly written in Modern ABAP and would ultimately work when run. In the end, all that remains to be said is that the variable names and method names appear to be the headings, the fixed values are the requirements and content.
Source
LinkedIn