My ABAP code snippets

My ABAP code snippets

Below, my personal code snippets :

Test sy-subrc

Name : ifs
Description : IF sy-subrc = 0.

IF sy-subrc = 0.
%SurroundedText%  | 
ENDIF.

Name : ifsn
Description : IF sy-subrc <> 0.

IF sy-subrc <> 0.
%SurroundedText% | 
ENDIF.

Types

Name : types
Description : TYPES : BEGIN OF $

TYPES : BEGIN OF ts_%TYPE NAME%,
%SurroundedText%          |
        END OF ts_%TYPE NAME%,
        ti_%TYPE NAME% TYPE STANDARD TABLE OF ts_%TYPE NAME%.

Comments management:

Name : begin
Description : BEGIN OF INSERT: 800000$

" BEGIN OF INSERT: 800000%N° ticket%
%SurroundedText%     |
" END OF INSERT: 800000%N° ticket%

Name : begind
Description : BEGIN OF DELETE: 800000$

" BEGIN OF DELETE: 800000%N° ticket%
%SurroundedText%     |
" END OF DELETE: 800000%N° ticket%

SELECT

Name : SELECT1
Description : SELECT … UP TO 1 ROWS

SELECT __fields__ FROM __table__ INTO __var__ UP TO 1 ROWS
  WHERE __field1__ = __cond1__
    AND __field2__ = __cond2__.
ENDSELECT.

READ TABLE

Name : readt
Description : READ TABLE … INTO … WITH KEY $

READ TABLE li_%Table sans prefix% INTO ls_%Table sans prefix% WITH KEY cle| = val. " BINARY SEARCH

Commit / Rollback by BAPI

Name : commitb
Description : BAPI TRANSACTION COMMIT

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
  wait = 'X'.

Name : rollbackb or broll
Description : BAPI TRANSACTION ROLLBACK

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

Try read

Name : tryread
Description : TRY. $ CATCH cx_sy_itab_line_not_found.

TRY.
%SurroundedText%  |
  CATCH cx_sy_itab_line_not_found.
ENDTRY.

Cartouche

Name : &cart
Description : Insérer cartouche

*&---------------------------------------------------------------------*
*& |Report  %Document%
*&
*&---------------------------------------------------------------------*
*======================================================================*
* Description :
* 
* 
* 
*----------------------------------------------------------------------*
* Spec   : SPEC_NAME 
* Auteur : NAME
* Date   : %DateTime%
*======================================================================*
*------------------    LISTE DES MODIFICATIONS    ---------------------*
*-----------------------------------------------------------------------
*   Date    | Développeur  | Description ou cross reference     Change
*                                                              Request
*-----------------------------------------------------------------------
* --/--/--  | xxxx         | xxx                             800000xxxx
*-----------------------------------------------------------------------
*======================================================================*

(Le premier | à coté de Report sert à placer le curseur)

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply