*- Local Declarations
TYPES : BEGIN OF lty_temp,row TYPE char15,
END OF lty_temp.
DATA : lt_temp TYPE TABLE OF lty_temp,
lv_rfcdest TYPE char20,
lv_user_type TYPE char2,
lv_user TYPE sy-uname.
*- Local Constants
CONSTANTS : lc_rfcdest TYPE rfcdes-rfcdest VALUE 'WORKFLOW_LOCAL_',
lc_comma TYPE char1 VALUE ',',
lc_u TYPE char2 VALUE 'U=',
lc_eqal TYPE char1 VALUE '='.
CONCATENATE lc_rfcdest sy-mandt INTO lv_rfcdest.
*- Get the RFC user details from RFCDES table
SELECT SINGLE rfcoptions
FROM rfcdes
INTO @DATA(lv_rfcoptions)
WHERE rfcdest = @lv_rfcdest.
IF sy-subrc IS INITIAL AND lv_rfcoptions IS NOT INITIAL.
*- Split the RFC Options using ','
SPLIT lv_rfcoptions AT lc_comma INTO TABLE lt_temp.
IF lt_temp IS NOT INITIAL.
*- Find the RFC user specifc row in the table
FIND ALL OCCURRENCES OF REGEX lc_u
IN TABLE lt_temp
RESPECTING CASE
RESULTS DATA(lt_result).
IF lt_result IS NOT INITIAL.
ASSIGN lt_result[ 1 ] TO FIELD-SYMBOL(<lfs_result>).
IF sy-subrc IS INITIAL AND <lfs_result> IS ASSIGNED.
ASSIGN lt_temp[ <lfs_result>-line ] TO FIELD-SYMBOL(<lfs_temp>).
IF sy-subrc IS INITIAL AND <lfs_temp> IS ASSIGNED.
SPLIT <lfs_temp>-row AT lc_eqal INTO lv_user_type lv_user.
IF lv_user IS NOT INITIAL.
*- Check whether the RFC user is valid user or not
SELECT SINGLE bname
FROM usr01
INTO @DATA(lv_bname)
WHERE bname = @lv_user.
IF sy-subrc IS INITIAL AND lv_bname IS NOT INITIAL.
ev_rfc_user = lv_bname.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
No comments:
Post a Comment