The *_SINGLE_READ functions

images/thumbnail.jpg - Thumbnail

When you need to derive a single record from a database table, you normally use SELECT SINGLE, which is like this in its most basic form, as everyone knows:

SELECT SINGLE *
  FROM KNA1
  WHERE KUNNR = '1234567890'.

Of course, if you are interested in just a few fields, ideally you select them explicitly to avoid copying unnecessary data from one side to the other:

DATA: lv_name1 TYPE name1.

SELECT SINGLE name1 INTO lv_name1
  FROM KNA1
  WHERE KUNNR = '1234567890'.

But this is all obvious and I am rambling as none of this is what brings me to this subject today. Today I want to talk about the valuable standard functions that replace SELECT SINGLE. Many of SAP’s main tables have functions that replace it as their job is precisely to derive records from those tables. For example, the function to derive a record of KNA1 is called KNA1_SINGLE_READ:

RICEF is not transgenic rice nor is it part of the UN

images/thumbnail.jpg - Thumbnail

RICEF is an acronym in SAP world which apparently was not invented by SAP. And so it is an unofficial acronym. Which does not mean it is an illegal or secret acronym given that it has become a term in proper usage in more and more projects.

RICEF means Report , Interface , Conversion , Enhancement , Form and, basically, refers to any kind of development that might be needed in a SAP project.

I CTRL-clicked to select a word

images/thumbnail.jpg - Thumbnail

A simple but valuable tip: anywhere in the SAP GUI - including the ABAP Editor - to select a word all you have to do is CTRL-click above it. Cool, no?

Unfortunately it doesn’t work on the Mac Java GUI :-(

(Thank you Sérgio Fraga for the tip)

Greetings from Abapinho.

Instant RANGE - just add water

images/thumbnail.jpg - Thumbnail

I’m going to teach you a magic formula for creating a RANGE that is almost as easy as just adding water.

Imagine that you want to create a RANGE from a database selection to then use it in another SELECT. Obviously you can do it like this:

DATA: lt_kunnr TYPE STANDARD TABLE OF kunnr,
        lr_kunnr TYPE RANGE OF kunnr,
        wa_kunnr LIKE LINE OF lr_kunnr.
FIELD-SYMBOLS: <kunnr> LIKE LINE OF lt_kunnr.

SELECT kunnr
  INTO TABLE lt_kunnr
  FROM kna1.

wa_kunnr-sign = 'I'.
wa_kunnr-option = 'EQ'.
LOOP AT lt_kunnr ASSIGNING <kunnr>.
  wa_kunnr-low = <kunnr>.
  APPEND wa_kunnr TO lr_kunnr.
ENDLOOP.

And here you used 15 lines of code and 4 variables. But now look at this alternative:

LOOP ASSIGNING instead of LOOP INTO

images/thumbnail.jpg - Thumbnail

In the beginning there was INTO. Actually, in the beginning it was not even INTO.

Taking a nap

images/thumbnail.jpg - Thumbnail

Whatever the case, it is necessary to put a program to sleep. And, as with almost everything else, there are several ways to do this, some better than others.

The most standard way to do this in ABAP is as follows:

WAIT UP TO 10 SECONDS.

The advantage of WAIT UP TO N SECONDS is that the process is freed up during these 10 seconds, thereby making it available for those who want it. The big disadvantage is that it makes an implicit COMMIT, which is not always so good. If you don’t mind the COMMIT, this is the best way to make your program fall asleep. Please note that you cannot sleep for 1.5 seconds as the parameter only accepts whole numbers.

Different versions of the same story

images/thumbnail.jpg - Thumbnail

Everyone knows that the SAP versions are a big mess. The lords of Heidelberg who play around with the names they give their things are either an impulsive bunch, are making fun of us, or they must always be in uproar.

Here is a little table to help to unravel them:

AnoUIEditionVersionVersionBASISWebASECCNetWeaver
TerminalR/2--
1992DesktopR/31.0-1.0
DesktopR/32.0, 2.1-2.0, 2.1
1997DesktopR/33.0, 3.13.1I3.1I
1998DesktopR/34.04.0B4.0B
2000DesktopR/34.54.5B4.5B
2001DesktopR/34.64.6B, 4.6C4.6B, 4.6C
2001DesktopR/34.6D4.6D4.6D, 6106.10
2003WebR/3 Enterprise1.104.7x1106206.20NetWeaver (2003)
WebR/3 Enterprise2.004.7x2006306.30NetWeaver (2003)
2005WebmySAP2004-6406.40ECC 5.0NetWeaver 04
2006WebmySAP2005-7007.0 (AS)ECC 6.0NetWeaver 04S

If this isn’t enough to make you confused, then you can find here a very good and detailed presentation on the different versions of SAP and the different capabilities of each one.

On your marks, get set, go!

images/thumbnail.jpg - Thumbnail

Ladies and gentlemen, boys and girls, the race is about to begin.

Introduction

The four competitors are as follows. They are 4 internal tables, of different races and creeds, which will fight for the athletics title of speed LOOP. Here they are:

Competitor 1: DATA: LT_ITEM TYPE TABLE Competitor 2: DATA: LT_ITEM_HASHED TYPE HASHED TABLE Competitor 3: DATA: LT_ITEM_SORTED TYPE SORTED TABLE Competitor 4: DATA: LT_ITEM TYPE TABLE + INTO INDEX

Global macros

images/thumbnail.jpg - Thumbnail

In a previous article we talked about macros, a relatively obscure and little used feature that can be both useful as well as create a huge mess. But these aren’t the only ABAP macros. There are others that are even more obscure and with even greater potential to mix up a system: the global macros.

I don’t know if I should tell you this, as it’s so strange… But, I don’t think it’s a good idea to hide it… Therefore, I’ll tell all.

Start on the right footing

images/thumbnail.jpg - Thumbnail

Normally when you log on to SAP the SAP menu appears. But you can use the function module NAVIGATION_SET_START_TCODE to pre-set an initial transaction. Anyway, it’s better to know it’s there than not to know it’s there, and even better than knowing that it’s not there. Who knows – it could be good for some users. There’s also the function module NAVIGATION_GET_START_TCODE to see what is pre-set.

Greetings from Abapinho.