Category Archive Blog

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

Idoc transactions

Use transaction WEDI in session manager to display list of available transactions about idoc (non-exhaustive list) :

Search tags : WE02

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

Transport ALV Layout Variants

You can save your ALV layout variant in customising transport order with function module (SE37) : LT_VARIANTS_TRANSPORT.

In table T_VARIANTS, specify your report name (T_VARIANTS-REPORT) and variant name (T_VARIANTS-VARIANT) your want to transport.

Search tag: mise en forme, grille, variante

SAP color codes

You can get the color codes in SAP with program: SHOWCOLO.

Declare constant with initial value

This is the only way to declare initial value in a constant :


CONSTANTS : c_matnr_empty    TYPE matnr VALUE IS INITIAL.

Insert data into sorted table

With a sorted table, it is not possible to use statement APPEND to add line in a table.
APPEND will resquest to add the line at the end, which will perturbate the sort of table.
Use statement INSERT, which will automatically manage in which index will be inserted the line.

Use this code:


  DATA : li_table TYPE SORTED TABLE OF ts_structure WITH NON-UNIQUE KEY key_field,
         ls_table TYPE ts_structure.

  INSERT ls_table INTO TABLE li_table.

 

Search tag: table triée, insérer