A Simple Start – ABAP Existence Check

St. Hellier’s Bay, Auckland with Rangitoto Island in the distance.

This is my first blog post so I thought I would start with something simple – the ABAP existence check. Sometimes you just need to know if a record exists in the database. You don’t actually have to return any data from the database. This is a simple and elegant method to do so.

*& Report zmc_abap_existence_check
REPORT zmc_abap_existence_check.

SELECT SINGLE @abap_true FROM sflight INTO @DATA(lv_found)
WHERE carrid = 'AZ'
  AND connid = '0555'
  AND fldate = '20180531' .

CASE lv_found.
  WHEN abap_true .
    WRITE: / 'Record found' .
  WHEN abap_false .
    WRITE: / 'Record not found' .

The output of the program looks like this:

I found that this can speed up my code a lot in certain use cases. It’s nice and clean not having to declare a variable or work area and then filling it with data you’re not going to use.

Have fun.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close