Category Archive ABAP code

Check if running in update task

Several possibilities.

Use FM TH_IN_UPDATE_TASK:


  DATA : lv_in_updtask TYPE sy-subrc.

  CALL FUNCTION 'TH_IN_UPDATE_TASK' 
    IMPORTING in_update_task = lv_in_updtask. 

  " lv_in_updtask = 1 if running in update task, 
  " else, lv_in_updtask = 0.

Use class CL_SYSTEM_TRANSACTION_STATE:


  IF CL_SYSTEM_TRANSACTION_STATE=>GET_IN_UPDATE_TASK( ) EQ 0 .
   " Code when not running in update task... 
  ENDIF.

Search tag: update process

The type of RETURNING parameter must be fully specified.

Sometimes when compilling class, this error appears.

Fully specification for a table means declare:
✔️ the type of internal table (default STANDARD),
✔️ the key (default WITH DEFAULT KEY).


TYPES ti_table TYPE STANDARD TABLE OF ts_structure WITH DEFAULT KEY.

Search tag: classe, Les paramètres RETURNING doivent être entièrement catégorisés.

Convert material unit

Use FM MD_CONVERT_MATERIAL_UNIT


  CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
    EXPORTING
      i_matnr              = lv_matnr
      i_in_me              = 'PCE'
      i_out_me             = 'PAL'
      i_menge              = lv_qte
    IMPORTING
      e_menge              = lv_nbpal
    EXCEPTIONS
      error_in_application = 1
      OTHERS               = 2.

Code to call adobe form

Use the code below to call an Adobe form from a specific program:
Read More

BADI for PO/PReq management

BADI (SE18) to implement for Purchase requisition or Purchase order management, transactions ME2xN : ME_PROCESS_PO_CUST.

EXIT for tab screen below : LV69AFZZ. Add code in corresponding performs.

Search tag: me21n, me22n, demande, commande, d’achat

Batch input with ABAP

Code example to update FI document – header info in FB02 :
(In that particular case, it should be better to use BAPI)


  DATA : lw_bdc_mode TYPE ctu_mode,
         li_bdcmess  TYPE TABLE OF bdcmsgcoll.

  CLEAR gt_bdcdata.

  " Selection screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '0100'.
  PERFORM bdc_field       USING 'RF05L-BELNR'  pw_belnr.
  PERFORM bdc_field       USING 'RF05L-BUKRS'  pw_bukrs.
  PERFORM bdc_field       USING 'RF05L-GJAHR'  pw_gjahr.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '/00'.         " [Touch Enter]

  " Main screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '0700'.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=VK'.         " [Button to reach header]

  " Header Screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '1710'.
  PERFORM bdc_field       USING 'BKPF-XREF2_HD'   gv_value.      " Value to be changed
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=ENTR'.          " [Validate button]

  " Main screen
  PERFORM bdc_dynpro      USING 'SAPMF05L' '0700'.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=AE'.         " [Save button]

  lw_bdc_mode = 'N'. " <== set A in debug to display screen

  CALL TRANSACTION 'FB02'
    USING gt_bdcdata
    MODE lw_bdc_mode     " N : Screens not displayed
    UPDATE 'S'           " Save synchronous
    MESSAGES INTO li_bdcmess.

 " Get all transaction messages into li_bdcmess.

Read More

TRANSLATE and code inspector

By using TRANSLATE key word, you can have in code inspector, or extended check issues/warnings, the error : “Dangerous use of translate in multilingual system”.

To avoid that :


* Set locale for given language (needed for upper-case translation)
  SET LOCALE LANGUAGE sy-langu.

* Translate to upper-case
  TRANSLATE  TO UPPER CASE.

Restrict select-options

Use FM SELECT_OPTIONS_RESTRICT.

Read More