ABAP Unit Test

And don’t tell me I’m a bore. ABAP unit test worth it!

Here how it was. Once I told you about Test Driven Development methodology, but today I decided to try it in practice how it works in SAP. I created basic OData Service and decided to test it automatically.

Now I want to test it automatically. Earlier I told about SECATT. Today let’s talk about Unit testing. It such a thing which is developed in ABAP and allows to test logic inside of a program. It does not simulate user input but verifies internal procedures, methods, functions for a supposed result. For example, it should always save correct data but never allows to save incorrect data. To implement we create two methods – positive result test and negative result test.

Read More


LSMW errors when you work with files

Sometimes when you load file in LSMW (Read Data step) system throws an error with a code without any human explanation. To understand this I advise you to look at this ABAP code from the standard LSMW program. Having this function module return codes (the same time error codes for LSMW) it would be easier to understand what’s wrong. Here is the list of LSMW errors when you work with text files. This step occurs just before you run convert data in legacy workbench. These return codes represent errors SAP shows us during file read step.

program /SAPDMC/SAP_LSMW_READ_FORMS:
CALL FUNCTION ‘GUI_UPLOAD’
EXPORTING
filename                      = l_filename
filetype                      = l_filetype
codepage                      = l_codepage
*     HAS_FIELD_SEPARATOR           = ‘ ‘
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = ‘X’
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
TABLES
data_tab                      = “l_upload_table”
EXCEPTIONS
file_open_error               = 1
file_read_error               = 2
no_batch                      = 3
gui_refuse_filetransfer       = 4
invalid_type                  = 5
no_authority                  = 6
unknown_error                 = 7
bad_data_format               = 8
header_not_allowed            = 9
separator_not_allowed         = 10
header_too_long               = 11
unknown_dp_error              = 12
access_denied                 = 13
dp_out_of_memory              = 14
disk_full                     = 15
dp_timeout                    = 16
OTHERS                        = 17


Unlock tables in SAP

My students have found really good way to solve problem when two or more consultants want to work with the same table in edit mode.

Author is unknown.

REPORT ZSENQOFF MESSAGE-ID MT.
CALL ‘C_ENQUEUE’ ID ‘OPCODE’ FIELD ‘F’.
CALL ‘C_WRITE_SYSLOG_ENTRY’ ID ‘TYP’ FIELD ‘C’
ID ‘KEY’ FIELD ‘GES’.
MESSAGE S900 WITH ‘Table locking turned off’.

***
REPORT ZSENQON MESSAGE-ID MT.
CALL ‘C_ENQUEUE’ ID ‘OPCODE’ FIELD ‘T’.
CALL ‘C_WRITE_SYSLOG_ENTRY’ ID ‘TYP’ FIELD ‘C’
ID ‘KEY’ FIELD ‘GER’.
MESSAGE S900 WITH ‘Table locking turned on’.

Don’t use in production system. Only for trainings!


Connect to external database

Once I needed to create a program to download data fro external database into my own. It happened to be very easily.

In DBACOCKPIT transaction create a new connection to a database.

And user it in ABAP like this:

EXEC SQL.
CONNECT TO ‘BSK’
ENDEXEC.
EXEC SQL.
SET CONNECTION ‘BSK’
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / ‘current database name’, DBN.
EXEC SQL.
SET CONNECTION DEFAULT
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / ‘current database name’, DBN.

It’s basic Native SQL ? ABAP. Some SAP notes for reference.

Note 178949 – MSSQL: Database MultiConnect
Note 323151 – Several DB connections with Native SQL


Resume parsing

Want to talk about?

It’s a boring time for a recruiter. SAP knows well how to it his job, there is nothing to do about. Position requests from managers are being processed themselves, posted to internal and external web-portals or agencies. Feedbacks are being sent back to managers by themselves and automatically. Everything is integrated. CV is being read from email  [email protected], parsed to bones and stored in candidate database. Interviews are being initiated from a mobile phone, rooms are reserved. Boring, no fun at all.

Everything is clear except CV. We know every resume is made of a typical skeleton, where is personal info, contacts, work experience. Every part could be formalized, parsed to its components and analyzed by a number of factors and variants of appearance.

We understand that First and Last names could match file name, never is written with punctuation characters, always start with a capital letter or are all capital and resides in the top part of a doc.

We also understand that contact phone number has fixed number of digits, patterns are also well known and it’s placed somewhere by name or e-mail address.

We understand that work experience is a consequence of the same type blocks with company, period, position and job functions specification. It’s just a table which can be retrieved from CV somehow. Let’s say exported in XML format, where we can easily find repeating elements that appear more than once.

Read More