Category Archive Blog

Status tables in SAP

Table JEST to see active and inactive status on objects.

Table TJ02 (and text table TJ02T) for internal status.

Table TJ30 (and text table TJ30T) for external status.

 
Example to change status with BAPI
Read More

Write special characters with ABAP

Use class : CL_ABAP_CHAR_UTILITIES.

Example, write a carriage return (Carriage Return and Line Feed) :


WRITE : 'Line 1', CL_ABAP_CHAR_UTILITIES=>CR_LF, 'Line 2'.

FM to check if executed in dialog mode

FM to check if Gui is active :


DATA : lw_gui_actif TYPE c.
  CALL FUNCTION 'GUI_IS_AVAILABLE'
    IMPORTING
      return = lw_gui_actif.

FM to check if code is executed in dialog mode :


DATA : lw_is_dialog TYPE xfeld.
CALL FUNCTION 'ZFM_CHECK_DIALOG_MODE'
  IMPORTING
    ew_is_dialog = lw_is_dialog.  " = X si en mode Dialog, vide sinon

Read More

Create an ALV with FM REUSE_ALV_GRID_DISPLAY

Abap code example to display an ALV with FM REUSE_ALV_GRID_DISPLAY.

Read More

Generate random string with ABAP

Use FM : GENERAL_GET_RANDOM_STRING.

Example :


  DATA : lw_guid TYPE string.

  CALL FUNCTION 'GENERAL_GET_RANDOM_STRING'
    EXPORTING
      number_chars  = 32
    IMPORTING
      random_string = lw_guid.

Convert date to external format

Convert date to default external format :


DATA : lw_date_ext TYPE char10,
       lw_date TYPE datum. 
WRITE lw_date TO lw_date_ext.

Other way to do that since 7.40 :


DATA lv_date TYPE d value '20190718'.
DATA(l_user_format) = |{ lv_date DATE = USER }|. "RAW, ISO, USER, ENVIRONMENT
WRITE l_user_format.

Convert date to specified external format :


DATA : lw_date_ext TYPE char10,
       lw_date     TYPE datum.

  CALL FUNCTION 'SLS_MISC_CONVERT_TO_DATE'
    EXPORTING
      p_date        = lw_date
      p_date_format = 'DD.MM.YYYY'
    IMPORTING
      p_date_string = lw_date_ext.

See also Convert date to internal format.

Convert date to internal format

With 7.40 :


DATA : lw_date_ext TYPE char10,
       lw_date TYPE datum.

lw_date = |{ lw_date_ext+6(4) }{ lw_date_ext+3(2) }{ lw_date_ext(2) }|.

With FM :


DATA : lw_date_ext TYPE char10,
       lw_date     TYPE datum.

  CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    EXPORTING
      date_external = lw_date_ext    " ==> 10.10.2017
    IMPORTING
      date_internal = lw_date        " ==> 20171010
    EXCEPTIONS
      date_external_is_invalid = 1.

See also Convert date to external format.

Increase line size of report

Synthax to increase line size of report :
(To be specified at begining of report with report name declaration)


  REPORT zreport_name LINE-SIZE 130.

Activate conditions and formulas for pricing

Use program RV80HGEN.

Sometimes the standard automatically add this report in transport request (TR).
If not done automatically, you can add it manually in your workbench TR :
Display the object list of your transport request or task. Switch to Change mode, insert row :

R3TR | XPRA | RV80HGEN

Read More