X Süre Boyunca Kontrol
Bir objenin locklı olup olmadığını veya bir tabloya bir kaydın atılıp atılmadığını belirli bir süre boyunca kontrol etmek gerekebilir.
PERFORM f_check_for_x_minutes USING p_aufnr
`1` "Dakika tipinden kontrol süresini gösterir
CHANGING lv_locked.
*&---------------------------------------------------------------------*
*& Form F_CHECK_FOR_X_MINUTES
*&---------------------------------------------------------------------*
FORM f_check_for_x_minutes USING p_aufnr TYPE aufnr
p_minutes TYPE numc2
CHANGING p_locked TYPE char1.
DATA: lv_runtime TYPE i,
lv_runtime1 TYPE i,
lv_runtime2 TYPE i.
CHECK p_aufnr IS NOT INITIAL.
CLEAR p_locked.
"1 SECOND = 1 MICROSECOND * 1000000
lv_runtime = p_minutes * 60 * 1000000. "X dakika karşılığı
GET RUN TIME FIELD lv_runtime1.
"X dakika boyunca kontrol et
DO.
CLEAR: lv_runtime2.
GET RUN TIME FIELD lv_runtime2.
lv_runtime2 = lv_runtime2 - lv_runtime1.
IF lv_runtime2 > lv_runtime.
p_locked = `X`.
EXIT.
ELSE.
PERFORM f_check_routine USING `01`
p_aufnr
CHANGING p_locked.
IF p_locked IS INITIAL.
EXIT.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. " F_CHECK_FOR_X_MINUTES
*&---------------------------------------------------------------------*
*& Form F_CHECK_ROUTINE
*&---------------------------------------------------------------------*
FORM f_check_routine USING p_no TYPE numc2
p_aufnr TYPE aufnr
CHANGING p_locked TYPE char1.
CASE p_no.
WHEN `01`.
PERFORM f_check_if_order_locked USING p_aufnr
CHANGING p_locked.
WHEN OTHERS.
ENDCASE.
ENDFORM. " F_CHECK_ROUTINE
*&---------------------------------------------------------------------*
*& Form F_CHECK_IF_ORDER_LOCKED
*&---------------------------------------------------------------------*
FORM f_check_if_order_locked USING p_aufnr TYPE aufnr
CHANGING p_locked TYPE char1.
DATA: lt_order_tab TYPE TABLE OF ord_pre,
ls_ord TYPE ord_pre,
lv_flag TYPE rc27x-flg_sel.
CLEAR p_locked.
CLEAR ls_ord.
ls_ord-aufnr = p_aufnr.
APPEND ls_ord TO lt_order_tab.
CALL FUNCTION `CO_ZF_ORDER_READ`
EXPORTING
flg_dialog = ` `
IMPORTING
flg_enqueue_ok = lv_flag
TABLES
aufnr_tab_imp = lt_order_tab
EXCEPTIONS
order_not_found = 1
release_no_change = 2
others = 3
.
IF sy-subrc = 0.
IF lv_flag NE `X`.
p_locked = abap_true.
ENDIF.
ENDIF.
ENDFORM. " F_CHECK_IF_ORDER_LOCKED