SAP/ABAP

Lock ABAP program.

Denise 2014. 10. 27. 09:32

1. Dialog / Background 모두 가능.

FUNCTION zlock_program.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_PROG) TYPE  CSEQUENCE
*"     REFERENCE(IV_LOCK) TYPE  BOOLE_D DEFAULT ' '
*"  EXPORTING
*"     REFERENCE(EV_SUBRC) TYPE  SY-SUBRC
*"----------------------------------------------------------------------

  DATA : lv_name TYPE indx-srtfd,
         lv_text TYPE char100.

  lv_name = iv_prog.

  CASE iv_lock.
    WHEN 'X'.
      CALL FUNCTION 'ENQUEUE_ESINDX'
        EXPORTING
          mode_indx      = 'E'
          mandt          = sy-mandt
          relid          = 'ZZ'
          srtfd          = lv_name
        EXCEPTIONS
          foreign_lock   = 1
          system_failure = 2
          OTHERS         = 3.

      ev_subrc = sy-subrc.
      IF sy-subrc <> 0.
        CONCATENATE lv_name 'is currently running by' sy-msgv1
               INTO lv_text
          SEPARATED BY space.

        IF sy-batch IS NOT INITIAL.
          WRITE /: lv_text.
        ENDIF.
        MESSAGE lv_text TYPE 'E'.
      ENDIF.
    WHEN OTHERS.
  ENDCASE.


ENDFUNCTION.


'SAP > ABAP' 카테고리의 다른 글

Save Smartform Output in PDF format without code  (0) 2014.11.19
Remove special char using hex or char.  (0) 2014.11.19
SAPscript Control Tables  (0) 2014.10.24
Convert Internal date to External date ( date, month )  (0) 2014.09.24
Function for Stock  (0) 2014.09.19