Category Archive Blog

Convert internal table to CSV

You can use FM SAP_CONVERT_TO_CSV_FORMAT :

Read More

Display right HTML docker container in selection screen

Code example to display a HTML docker container on the right of a selection screen (to display help for instance).

Read More

ABAP operator MIN & MAX

Use statements NMIN and NMAX.
⚠️ Maximum 9 values can be passed : val1, val2… val9.


    DATA : lv_nb1 VALUE 25,
           lv_nb2 VALUE 50,
           lv_nb3 VALUE 100.

    DATA(lv_nb_max) = nmax( val1 = lv_nb1
                            val2 = lv_nb2
                            val2 = lv_nb3 ).

    DATA(lv_nb_min) = nmin( val1 = lv_nb1
                            val2 = lv_nb2
                            val2 = lv_nb3 ).

    " ==> LV_MAX = 100
    " ==> LV_MIN = 25

Search tag: maximum minimum

Exit screen for PO/PReq (ME21n/ME22n)

Check the following post very well explained : https://sapcodes.com/2015/11/20/screen-exit-me21nme22nme23n-header/

Search tag: commande, achat, d’achat, PO, PReq, purchase, order, requisition, écran

Submit a program in background via job

The submited program with method below can be monitored in SM37.


    DATA: lv_number           TYPE tbtcjob-jobcount,
          lv_name             TYPE tbtcjob-jobname.

    lv_name =  'Relevant Job name'.

    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname          = lv_name
      IMPORTING
        jobcount         = lv_number
      EXCEPTIONS
        cant_create_job  = 1
        invalid_job_data = 2
        jobname_missing  = 3
        OTHERS           = 4.

    IF sy-subrc = 0.
      SUBMIT z_report_to_call  WITH p_par1    = lv_param1
                               WITH p_par2    = lv_par2
                               WITH s_matnr  IN lr_matnr
                               WITH p_flag    = 'X'
                               VIA JOB lv_name NUMBER lv_number
                               AND RETURN.

      IF sy-subrc = 0.
        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            jobcount             = lv_number
            jobname              = lv_name
            strtimmed            = 'X'
          EXCEPTIONS
            cant_start_immediate = 1
            invalid_startdate    = 2
            jobname_missing      = 3
            job_close_failed     = 4
            job_nosteps          = 5
            job_notex            = 6
            lock_failed          = 7
            OTHERS               = 8.
        IF sy-subrc > 1.
          MESSAGE i054(s_cus_img_activity).
          " Background job could not be started.
          " Le job d’arrière-plan n’a pas pu être lancé.
        ENDIF.

      ELSE.
        " Display error returned by SUBMIT of program
        DATA(ls_msg) = cl_abap_submit_handling=>get_error_message( ).
        MESSAGE ID ls_msg-msgid
                TYPE 'I'
                NUMBER ls_msg-msgno
                WITH ls_msg-msgv1 ls_msg-msgv2 ls_msg-msgv3 ls_msg-msgv4
                DISPLAY LIKE ls_msg-msgty.
      ENDIF.
    ENDIF.

Merge PDF files with ABAP

If you want to merge PDF files on SAP server, you will need a third party software installed on SAP Server.
Here is one solution with PDF ToolKit :

Read More

Create tabs on selection screen

Check program DEMO_SEL_SCREEN_WITH_TABSTRIP.

Read More