BDC-用户锁定及有效期设置程序

*&---------------------------------------------------------------------*
*& Report ZPMRP032
*&---------------------------------------------------------------------*
*&用户锁定及有效期设置程序--Creat by Bruce King220200527
*&将ZPMRP029及ZPMRP030结合起来,并使用BDC录屏形式控制程序*
*&增加了新建后不立即登录的排除*
*&---------------------------------------------------------------------*
REPORT ZPMRP032.
TABLES:USR02.
TYPES:BEGIN OF TY_DATA,
        BNAME TYPE USR02-BNAME,
        TRDAT TYPE USR02-TRDAT,
      END OF TY_DATA.
DATA:LT_BNAME TYPE STANDARD TABLE OF TY_DATA.

DATA:ITAB_BDCTAB TYPE TABLE OF BDCDATA WITH HEADER LINE.
DATA:P_MODE TYPE CHAR1 VALUE 'N',
     P_UPDA TYPE CHAR1 VALUE 'L'.
DATA LV_MESS TYPE STRING.
DATA BEGIN OF MESSTAB OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF MESSTAB.
DATA:ZTIME TYPE USR02-GLTGB.
ZTIME = SY-DATUM.

PARAMETERS:P_BACK AS CHECKBOX."后台
SELECT-OPTIONS:S_BNAME FOR USR02-BNAME."前台用户名

START-OF-SELECTION.
  IF P_BACK NE 'X'.
    LOOP AT S_BNAME.
      PERFORM USER_LOCK USING S_BNAME-LOW."用户锁定
      PERFORM MODIFY_DATE USING S_BNAME-LOW SY-DATUM."用户有效期设置
      CLEAR:S_BNAME.
    ENDLOOP.
  ELSE.
    PERFORM GET_NAME."取得三个月前到现在当前时间没有登录的用户名
    LOOP AT LT_BNAME ASSIGNING FIELD-SYMBOL(<FS_BNAME>).
      PERFORM USER_LOCK USING <FS_BNAME>-BNAME.
      PERFORM MODIFY_DATE USING <FS_BNAME>-BNAME SY-DATUM.
    ENDLOOP.
  ENDIF.
FORM USER_LOCK USING P_S_BNAME TYPE USR02-BNAME.
  DATA:MSG1 TYPE STRING.
  DATA:MSG2 TYPE STRING.
  REFRESH ITAB_BDCTAB[].
  REFRESH MESSTAB[].
  PERFORM BDC_DYNPRO      USING 'SAPLSUID_MAINTENANCE' '1050'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
        'SUID_ST_BNAME-BNAME'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
        '=LOCK'.
  PERFORM BDC_FIELD       USING 'SUID_ST_BNAME-BNAME'
        P_S_BNAME.
  PERFORM BDC_DYNPRO      USING 'SAPLSUID_MAINTENANCE' '1500'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
        'G_STATTEXT'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
        '=LOCK'.
*PERFORM bdc_transaction USING 'SU01'.

  CALL TRANSACTION 'SU01' USING ITAB_BDCTAB
        MODE      P_MODE
        UPDATE    P_UPDA
        MESSAGES INTO MESSTAB.

  READ TABLE MESSTAB WITH KEY MSGTYP = 'E'.
  IF P_BACK NE 'X'.
    IF SY-SUBRC EQ 0.
      MSG1 = |用户{ S_BNAME-LOW }锁定失败|.
      MESSAGE MSG1 TYPE 'I'.
    ELSE.
      MSG2 = |用户{ S_BNAME-LOW }锁定成功|.
      MESSAGE MSG2 TYPE 'I'.
    ENDIF.
    CLEAR:MSG1,MSG2.
  ENDIF.
ENDFORM.

FORM MODIFY_DATE USING P_S_BNAME TYPE USR02-BNAME P_DATE TYPE SY-DATUM.
  DATA:MSG3 TYPE STRING.
  DATA:MSG4 TYPE STRING.
  REFRESH ITAB_BDCTAB[].
  REFRESH MESSTAB[].
  PERFORM BDC_DYNPRO      USING 'SAPLSUID_MAINTENANCE' '1050'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
        'SUID_ST_BNAME-BNAME'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
        '=CHAN'.
  PERFORM BDC_FIELD       USING 'SUID_ST_BNAME-BNAME'
        P_S_BNAME.
  PERFORM BDC_DYNPRO      USING 'SAPLSUID_MAINTENANCE' '1100'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
        '=LOGO'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
        'SUID_ST_NODE_PERSON_NAME_EXT-TITLE_MEDI'.
*  PERFORM bdc_field       USING 'SUID_ST_NODE_PERSON_NAME-NAME_LAST'
*        record-NAME_LAST_002.
  PERFORM BDC_DYNPRO      USING 'SAPLSUID_MAINTENANCE' '1100'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
        '=UPD'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
        'SUID_ST_NODE_LOGONDATA-GLTGB'.
*  PERFORM bdc_field       USING 'SUID_ST_NODE_LOGONDATA-USTYP'
*        record-USTYP_003.
  PERFORM BDC_FIELD       USING 'SUID_ST_NODE_LOGONDATA-GLTGB'
        P_DATE.
  CALL TRANSACTION 'SU01' USING ITAB_BDCTAB
        MODE      P_MODE
        UPDATE    P_UPDA
        MESSAGES INTO MESSTAB.
  IF P_BACK NE 'X'.
    READ TABLE MESSTAB WITH KEY MSGTYP = 'E'.
    IF SY-SUBRC EQ 0.
      MSG3 = |用户{ S_BNAME-LOW }有效期修改失败|.
      MESSAGE MSG3 TYPE 'I'.
    ELSE.
      MSG4 = |用户{ S_BNAME-LOW }有效期修改成功|.
      MESSAGE MSG4 TYPE 'I'.
    ENDIF.
    CLEAR:MSG3,MSG4.
  ENDIF.
ENDFORM.

FORM BDC_DYNPRO  USING   NAME VALUE.
  CLEAR ITAB_BDCTAB.
  ITAB_BDCTAB-PROGRAM = NAME.
  ITAB_BDCTAB-DYNPRO  = VALUE.
  ITAB_BDCTAB-DYNBEGIN = 'X'.
  APPEND ITAB_BDCTAB.
ENDFORM.                    "BDC_DYNPRO
*&---------------------------------------------------------------------*
*&      FORM  BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD  USING    NAME VALUE.
  CLEAR ITAB_BDCTAB.
  ITAB_BDCTAB-FNAM = NAME.
  ITAB_BDCTAB-FVAL = VALUE.
  APPEND ITAB_BDCTAB.
ENDFORM.                    "BDC_FIELD

FORM GET_NAME .
  DATA:ZDATE TYPE SY-DATUM.
  CALL FUNCTION 'CCM_GO_BACK_MONTHS'
    EXPORTING
      CURRDATE   = SY-DATUM
      BACKMONTHS = 3
    IMPORTING
      NEWDATE    = ZDATE.
  SELECT BNAME TRDAT FROM USR02 INTO CORRESPONDING FIELDS OF TABLE LT_BNAME
    WHERE TRDAT < ZDATE AND GLTGB = '00000000' AND UFLAG <> '64' AND ERDAT < ZDATE."增加被锁定的不取出来,继续增加建立后不立即登录的排除
ENDFORM.

 

上一篇:hbase-site.xml 配置文件详解


下一篇:Perform Easily CodeForces - 1413C