Function module (Z_USR_INSTANT_CREATION1)

Advertisement
Hi Experts,
Please look into below coding and solve  my problem.
FUNCTION Z_USR_INSTANT_CREATION1.
""Local Interface:
*"  IMPORTING
*"     VALUE(USERNAME1) LIKE  BAPIBNAME-BAPIBNAME
*"     VALUE(ACCTNO) TYPE  /BIC/OIZCUSTOMER
*"     VALUE(LOGONDATA1) LIKE  BAPILOGOND STRUCTURE  BAPILOGOND
*"     VALUE(PASSWORD1) LIKE  BAPIPWD STRUCTURE  BAPIPWD DEFAULT
*"       'initpass'
*"     VALUE(FIRSTNAME) TYPE  /BI0/OINAME
*"     VALUE(LASTNAME) TYPE  /BI0/OINAME3
*"     VALUE(ADDRESS1) LIKE  BAPIADDR3 STRUCTURE  BAPIADDR3 OPTIONAL
*"     VALUE(REF_USER1) LIKE  BAPIREFUS STRUCTURE  BAPIREFUS OPTIONAL
*"     VALUE(IP_V) TYPE  RSINFOPROV DEFAULT 'ZEX_DS01'
*"     VALUE(IP_H) TYPE  RSINFOPROV DEFAULT 'ZEX_DS02'
*"  EXPORTING
*"     VALUE(CREATERRCODE) TYPE  RSRCHANGEFLAG
*"     VALUE(ROLERRCODE) TYPE  RSRCHANGEFLAG
*"  TABLES
*"      RETURN1 STRUCTURE  BAPIRET2
*"      PROFILES1 STRUCTURE  BAPIPROF
*"      RETURN2 STRUCTURE  BAPIRET2
*"      RETURN3 STRUCTURE  BAPIRET2
*"      RETURN4 STRUCTURE  BAPIRET2
  DATA: NEWS(40), pwd(8).
  data : ZACTGRP like BAPIAGR occurs 0 with header line.
Check if the user already exists.
  CALL FUNCTION 'BAPI_USER_EXISTENCE_CHECK'
    EXPORTING
      username = USERNAME1
    IMPORTING
      return   = RETURN1.
WRITE: RETURN1-type, RETURN1-MESSAGE.
  IF sy-subrc EQ 0.
Call Function module to create UserId
*ADDRESS1-FIRSTNAME = 'Sreeni'.
*ADDRESS1-LASTNAME = 'Varadha'.
    ADDRESS1-FIRSTNAME = FIRSTNAME.
    ADDRESS1-LASTNAME = LASTNAME.
   WRITE: /1 '*** FIRST AND LASTNAME PASSED BY JAVA: ', ADDRESS1-FIRSTNAME, ADDRESS1-LASTNAME.
    CALL FUNCTION 'BAPI_USER_CREATE1'
      EXPORTING
        USERNAME  = USERNAME1
        LOGONDATA = LOGONDATA1
        PASSWORD  = PASSWORD1
        ADDRESS   = ADDRESS1
        REF_USER  = REF_USER1
      TABLES
        RETURN    = RETURN2.
*CREATE FAILURE ERROR TYPE IS SENT BACK TO PORTAL
    CREATERRCODE = RETURN2-TYPE.
Call Function module to Deactivate Password
    CALL FUNCTION 'BAPI_USER_CHANGE'
      EXPORTING
        USERNAME  = USERNAME1
        LOGONDATA = LOGONDATA1
        ADDRESS   = ADDRESS1
        REF_USER  = REF_USER1
      TABLES
        RETURN    = RETURN3.
   WRITE: RETURN2-MESSAGE, CREATERRCODE.
   WRITE: RETURN3-MESSAGE.
  ELSE.
User already Exists need to direct send back the return code to java.
   WRITE: RETURN1-MESSAGE.
    CREATERRCODE = RETURN2-TYPE.
  ENDIF.
  clear: zactgrp.
  refresh zactgrp.
  zactgrp-agr_name = 'ZPMUSA_STORE_USER'.
  Zactgrp-from_dat = sy-datum.
  zactgrp-to_dat  = '99991231'.
  append zactgrp.
Call function module to assign role to the User Id
  CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
    EXPORTING
      USERNAME       = USERNAME1
    TABLES
      ACTIVITYGROUPS = zactgrp
      RETURN         = RETURN4.
*ROLE ASSIGN FAILURE ERROR TYPE IS SENT BACK TO PORTAL
  ROLERRCODE = RETURN4-TYPE.
WRITE: ROLERRCODE.
Code to Insert records into ZSTAODS
  DATA: ZSTAODS_ITAB LIKE /BIC/AZSTAODS00 OCCURS 0 WITH HEADER LINE.
  ZSTAODS_ITAB-TCTUSERNM = USERNAME1.
  ZSTAODS_ITAB-TCTADTO   = '99991231'.
  ZSTAODS_ITAB-TCTIOBJNM = 'ZCUSTOMER'.
  ZSTAODS_ITAB-TCTSIGN = 'I'.
  ZSTAODS_ITAB-TCTOPTION = 'EQ'.
  ZSTAODS_ITAB-TCTLOW = ACCTNO.
  ZSTAODS_ITAB-TCTHIGH = ACCTNO.
  ZSTAODS_ITAB-TCTOBJVERS = 'A'.
  ZSTAODS_ITAB-TCTADFROM = SY-DATUM.
  APPEND ZSTAODS_ITAB.
  MODIFY /BIC/AZSTAODS00 FROM TABLE ZSTAODS_ITAB.
  clear: ZSTAODS_ITAB.
Code to Delete records from ZEX_DS01 & ZEX_DS02*
  DELETE FROM /BIC/AZEX_DS0100.
  DELETE FROM /BIC/AZEX_DS0200.
Code to Insert records into ZEX_DS01*
  DATA: ZEX_DS01_ITAB LIKE /BIC/AZEX_DS0100 OCCURS 0 WITH HEADER LINE.
  ZEX_DS01_ITAB-TCTUSERNM = USERNAME1.
  ZEX_DS01_ITAB-TCTADTO   = '99991231'.
  ZEX_DS01_ITAB-TCTIOBJNM = 'ZCUSTOMER'.
  ZEX_DS01_ITAB-TCTSIGN = 'I'.
  ZEX_DS01_ITAB-TCTOPTION = 'EQ'.
  ZEX_DS01_ITAB-TCTLOW = ACCTNO.
  ZEX_DS01_ITAB-TCTHIGH = ACCTNO.
  ZEX_DS01_ITAB-TCTOBJVERS = 'A'.
  ZEX_DS01_ITAB-TCTADFROM = SY-DATUM.
  APPEND ZEX_DS01_ITAB.
  MODIFY /BIC/AZEX_DS0100 FROM TABLE ZEX_DS01_ITAB.
  clear: ZEX_DS01_ITAB.
Code to Insert records into ZEX_DS02*
  DATA: ZEX_DS02_ITAB LIKE /BIC/AZEX_DS0200 OCCURS 0 WITH HEADER LINE.
  ZEX_DS02_ITAB-TCTUSERNM = USERNAME1.
  ZEX_DS02_ITAB-TCTADTO   = '99991231'.
  ZEX_DS02_ITAB-TCTIOBJNM = 'ZCUSTOMER'.
  ZEX_DS02_ITAB-TCTHIENM = 'RETAIL HIERARCHY'.
  ZEX_DS02_ITAB-TCTHIEVERS = 'A'.
  ZEX_DS02_ITAB-TCTHIEDATE  = '99991231'.
  ZEX_DS02_ITAB-TCTNIOBJNM   = 'ZCUSTOMER'.
  ZEX_DS02_ITAB-TCTATYPE = '1'.
  ZEX_DS02_ITAB-TCTACOMPM = '1'.
  ZEX_DS02_ITAB-TCTTLEVEL = '99'.
  ZEX_DS02_ITAB-TCTNODE = ACCTNO.
  ZEX_DS02_ITAB-TCTOBJVERS = 'A'.
  ZEX_DS02_ITAB-TCTADFROM = SY-DATUM.
  APPEND ZEX_DS02_ITAB.
  MODIFY /BIC/AZEX_DS0200 FROM TABLE ZEX_DS02_ITAB.
  clear: ZEX_DS02_ITAB.
Code of RSSM_GENERATE_AUTHORIZATIONS to generate profile from ZEX_DS01 & ZEX_DS02
  TYPE-POOLS: rs.
*TABLES: tobj.
  DATA: l_t_object TYPE rso_t_tlogo,
        l_s_object TYPE rso_s_tlogo.
input parameters
initialize
  DATA: l_display_log TYPE rs_bool.
  IF sy-batch IS INITIAL.
    l_display_log = rs_c_true.
  ELSE.
    l_display_log = rs_c_false.
  ENDIF.
  DATA: l_t_infoprov_auth TYPE rssbr_t_infoprov_auth,
        l_s_infoprov_auth TYPE rssbr_s_infoprov_auth.
  l_s_infoprov_auth-value = ip_v.
  l_s_infoprov_auth-hierarchy = ip_h.
  INSERT l_s_infoprov_auth INTO TABLE l_t_infoprov_auth.
call the function module
  CALL FUNCTION 'RSSB_AUTH_GEN_FROM_INFOPROV'
    EXPORTING
      i_t_infoprov_auth      = l_t_infoprov_auth
      i_appl_log_initialized = rs_c_false
      i_display_log          = l_display_log
      i_detlevel             = '1'
      i_packagesize          = 10000.
*PROFILE GENERATION FAILURE ERROR TYPE IS SENT BACK TO PORTAL
   PROFERRCODE = RETURN5-TYPE.
ENDFUNCTION.
Use of above function module:
This function module is used to create user ID in the system. It checks whether the user exists already, if yes, then it would send back the message for the same. If it doesnu2019t then it would create the user in system. Assign roles, profiles and authorizations for the user.
For ex:  If we have 2 users XXX and YYY in that XXX is existing user and YYY is new user, letu2019s see how this function module will work for these two users
First, it uses BAPI_USER_EXISTENCE_CHECK function module to check whether the ID exists. If it exists(XXX), it would send back the message for the same. If not(YYY), it would go ahead to create the user id by the function module BAPI_USER_CREATE1. After creation of the id, message regarding the same would be sent at the end of execution of function module.
Next it will go for assigning of the roles, generation of profile and authorization to the user ID. Once the function module is finished, it would send out the message for the execution of all functionalities in the output screen.
My Requirement:
what about the internal and DUA (Delegated  User Administrator)  users is that covered with this function module? if not what changes required to function module?
Many thanks in advance
David
Edited by: david Rathod on Sep 24, 2010 10:11 AM
Advertisement

Replay

Hello David,
your question is really unreadable. Kindly format your question and resend.
Regards,
Satyam