* ab ABAP 7.54
DATA field TYPE p decimals 2.
field += 4.
field -= 2.
field *= 3.
field /= 2.
*obsolet: ADD, SUBSTRACT, MULTIPLY, DIVIDE
Category: SAP
SAP
[ABAP] Display a database table
cl_salv_gui_table_ida=>create( iv_table_name = 'SFLIGHT' )->fullscreen( )->display( ).
Example report in your system: SALV_IDA_DISPLAY_DATA_SIMPLE
[ABAP] Alpha conversion
DATA(lv_matnr) = VALUE matnr( 0000000001 ).
DATA(character_string) = VALUE string( ).
character_string = |Your Material Number is { lv_matnr ALPHA = IN }|. "Adds leading zeros
character_string = |Your Material Number is { lv_matnr ALPHA = OUT }|. "Removes leading zeros
[ABAP Env] Create Data Model & OData Service
Recently I worked through the tutorial on creating a travel bookings app in the SAP Cloud Platform ABAP Environment.
Find a good introduction and overview on this topic here: Getting Started with ABAP in the Cloud – Part I
And the travel bookings app tutorial here: Getting Started with ABAP in the Cloud – Part II
These are my notes on the steps needed to create the data model and publish it as oData service.
# | Layer | Nomenclature | Description |
---|---|---|---|
1 | Database Table | ZTABLE | Place your raw data first |
2 | Data Definition (Interface View) | ZI_ | Relation between different tables (e.g. currency or text table) |
3 | Projection View (Consumption View) | ZC_ | Configure the UI depending on your scenario. Use different projection views for different usages of the same interface view and the same physical table. |
4 | Service Definition | ZSD_ | Expose the projection view (and underlying associations like currency, country…) as service |
5 | Service Binding | ZSB_ | How to we want to make the service available? Defines the binding type (OData V2 / OData V4) Activate it with the “Activate” Button within the editor window. Select the Entity and hit “Preview…” to see whtat we defined in our projection view. |
If you’ve done this, you are able to view the data in a generated Fiori Elements app. But if you also want to create, edit, delete data, you’ll have to add some behavior functionality.
6 | Behavior Definition on Data Definition | ZI_ | Created on top of the Data Definition. Will get the same name es the Data Definition. Implementation Type: Managed Defines the operations create, delete, edit. |
7 | Behavior Implementation on Definition View | ZBP_I_ | The code for the behavior… For the travel app tutorial, some logic for a generated unique key and field validation. The class inherits from cl_abap_behavior_handler. |
8 | Behavior Definition on Projection View | ZC_ | Created on top of the Projection View. Will get the same name es the Projection View. Defines the operations create, delete, edit. |
[ABAP] Select-Option for ALV Layout


SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-b03.
PARAMETERS: p_vari TYPE slis_vari.
SELECTION-SCREEN END OF BLOCK b3.
INITIALIZATION.
"Load default layout
DATA: ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
ls_key-report = sy-repid.
ls_layout = cl_salv_layout_service=>get_default_layout( s_key = ls_key
restrict = '1' ).
p_vari = ls_layout-layout.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
"Value Help
DATA: ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
ls_key-report = sy-repid.
ls_layout = cl_salv_layout_service=>f4_layouts( s_key = ls_key
restrict = '1' ).
p_vari = ls_layout-layout.
[ABAP] Fill table rows into range table
DATA(pernrs) = VALUE pernr_tab( ( |00000001| )
( |00000002| )
( |00000003| ) ).
DATA(lr_pernr) = VALUE cchry_pernr_range( FOR pernr IN pernrs ( sign = 'I'
option = 'EQ'
low = pernr
high = '' ) ).
"Append row to range
APPEND VALUE #( option = 'EQ'
sign = 'I'
low = pernr ) TO lr_pernr.
[ABAP] Read IT0008 lgart values
Oldschool abap…
DATA: BEGIN OF i0008,
lgart LIKE p0008-lga01,
betrg LIKE p0008-bet01,
anzhl LIKE p0008-anz01,
eitxt LIKE p0008-ein01,
opken LIKE p0008-opk01,
indbw LIKE p0008-ind01,
END OF i0008.
rp-provide-from-last p0008 space pn-begda pn-endda.
DO 40 TIMES
VARYING i0008-lgart FROM p0008-lga01 NEXT p0008-lga02
VARYING i0008-betrg FROM p0008-bet01 NEXT p0008-bet02
VARYING i0008-anzhl FROM p0008-anz01 NEXT p0008-anz02
VARYING i0008-eitxt FROM p0008-ein01 NEXT p0008-ein02
VARYING i0008-opken FROM p0008-opk01 NEXT p0008-opk02
VARYING i0008-indbw FROM p0008-ind01 NEXT p0008-ind02.
IF i0008-lgart = '2001'.
EXIT.
ENDIF.
ENDDO.
[FI] Transactions
FPE3 | Beleg anzeigen |
FPL9 | Konto Anzeigen |
FBL3N | offene Posten für Sachkonten |
FS00 | Kontenplan anlegen |
[SAP] SAP Gui login with single click in KeePass
Just paste the following string into the URL field when creating a new entry in KeePass. You only have to replace three parameters manually:
- system
- sysname
- language
The two parameters system
and sysname
have to match exactly the system settings in your SAP Gui.
cmd://sapshcut -maxgui -system=E01 -sysname="SAP Dev System" -client=100 -user={USERNAME} -pw={PASSWORD} -language=DE

With a single click on the URL string or by using the shortcut CTRL + U, the SAP Gui will open and log you in.

You can find out more about the parameters for the sapshcut program, by opening the Windows Power Shell and entering
start sapshcut /?

Of course, you could also log in via command line or via batch script (.bat), but this would require to write/store your password in clear text.
start sapshcut -maxgui -system=E01 -sysname="SAP Dev System" -client=011 -user=testuser -pw=testpassword -language=DE
[ABAP] Radiobutton with label (comment) and input field

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01.
* Schnittstelle
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_server RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 6(26) text-t01 FOR FIELD p_server.
PARAMETERS: p_sname(8) TYPE c DEFAULT ''.
SELECTION-SCREEN END OF LINE.
* Filename (optional)
PARAMETERS: p_fname TYPE j_3sdsn.
* Lokale Datei
PARAMETERS: p_local RADIOBUTTON GROUP rad1 DEFAULT 'X'.
* Dateiauswahl
PARAMETERS: p_up TYPE dxfile-filename DEFAULT ''.
SELECTION-SCREEN END OF BLOCK b1.