• ^_^函数创建用户并分配权限


    "李渊 测试 创建用户 函数BAPI_USER_CREATE1
    
    DATA:LS_DATA   TYPE BAPILOGOND,
         LS_ADDR   TYPE BAPIADDR3,
         LS_DEFU   TYPE BAPIDEFAUL,
         LS_PWD    TYPE BAPIPWD,
         GT_RETURN TYPE TABLE OF BAPIRET2,
         GW_RETURN LIKE LINE OF GT_RETURN,
         GV_DEST   TYPE RFCDEST,
         GT_FILE   TYPE TABLE OF BAPIPROF,
         GW_FILE   LIKE LINE OF GT_FILE.
    
    CALL FUNCTION 'CRM_OFI_GET_RFCDEST'
      IMPORTING
        EV_RFCDEST       = GV_DEST
      EXCEPTIONS
        NO_RFCDEST       = 1
        MULTIPLE_RFCDEST = 2
        OTHERS           = 3.
    IF SY-SUBRC <> 0.
    ENDIF.
    
    "LODIN DATA
    LS_DATA-GLTGV = SY-DATUM - 1.
    LS_DATA-GLTGB = SY-DATUM + 1.
    LS_DATA-USTYP = 'A'.
    "set efault data
    LS_DEFU-LANGU = 'E'.
    LS_DEFU-SPLD = 'LP01'.
    LS_DEFU-DATFM = '4'.
    LS_DEFU-DCPFM = 'X'.
    LS_DEFU-TIMEFM = '0'.
    "set password
    LS_PWD-BAPIPWD = '123456'.
    "set name
    LS_ADDR-LASTNAME = 'Lee'.
    "call func create user
    CALL FUNCTION 'BAPI_USER_CREATE1' DESTINATION GV_DEST
      EXPORTING
        USERNAME  = 'ANDY01'
    *   NAME_IN   =
        LOGONDATA = LS_DATA
        PASSWORD  = LS_PWD
        DEFAULTS  = LS_DEFU
        ADDRESS   = LS_ADDR
      TABLES
        RETURN    = GT_RETURN.
    
    READ TABLE GT_RETURN INTO GW_RETURN WITH KEY TYPE = 'E'.
    IF SY-SUBRC = 0.
      MESSAGE ID GW_RETURN-ID TYPE GW_RETURN-TYPE NUMBER GW_RETURN-NUMBER.
    ELSE.
      REFRESH:GT_RETURN.
      GW_FILE-BAPIPROF = 'SAP_ALL'.
      GW_FILE-BAPITYPE = 'C'.
      GW_FILE-BAPIAKTPS = 'X'.
      APPEND GW_FILE TO GT_FILE.
      GW_FILE-BAPIPROF = 'SAP_NEW'.
      GW_FILE-BAPITYPE = 'C'.
      GW_FILE-BAPIAKTPS = 'X'.
      APPEND GW_FILE TO GT_FILE.
      "assign sap_all to user
      CALL FUNCTION 'BAPI_USER_PROFILES_ASSIGN' DESTINATION GV_DEST
        EXPORTING
          USERNAME = 'ANDY01'
        TABLES
          PROFILES = GT_FILE
          RETURN   = GT_RETURN.
      READ TABLE GT_RETURN INTO GW_RETURN WITH KEY TYPE = 'E'.
      IF SY-SUBRC = 0.
        WRITE 'Assign Profile to User error'.
      ELSE.
      ENDIF.
    ENDIF.
  • 相关阅读:
    easyUI日期框,默认显示今天,今天以后的日期不能选
    vue实现下拉框全选和输入匹配
    【转载】CSS flex属性深入理解
    ES6学习之二
    Centos7(Firewall)防火墙命令
    DeDeCMS模板标签(2)
    DeDeCMS模板标签(1)
    常用js正则表达式大全
    linux yum 命令
    Linux软链接和硬链接
  • 原文地址:https://www.cnblogs.com/sapSB/p/8462141.html
Copyright © 2020-2023  润新知