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

BAPI , BADI , USER EXIT , FUNCTION MODULE

Hi Experts Can any body pls explain me abt BAPI , BADI , USER EXIT , FUNCTION MODULE  and its uses in details . Thanks DevashishDear Deba, Functional Module:Procedure that can only be defined in function groups and outside of classes. Can be called f

Scheduling a BOR or Function module!

HI, I have created a Function module ''Z_RETINT01". For that FM I have created a BOR 'Y_RETINT01'. The Bapi for this FM is 'Y_RETINTERFACE'. Now client want to make it background scheduling.                      Which one i should schedule- The funct

Types Does not Exist Error in Function Module creation

Hi Guys I am trying to replicate the functionality of the below program using a function module. However when I enter the following in the changing tab of the fn mod, I get  error TYPE IT_VBRP does not exist. Parameter name p_it_vbrp like it_vbrp <re

Function Module " /Crystal/GET_FUNCAREA_CATALOG" not found

Good day Masters I am not able to connect to our SAP ECC6.0 because of the below error Function Module " /Crystal/GET_FUNCAREA_CATALOG" not found is this function modules exists on the transport files ? do you think by executing the transport th

Help with a Function-module

Hi again forum:    I have a program and i need to pass basic functionality to a set of funtion module.    I have a description of a internal table in the program, that i need to use in the function-module Example:      PROGRAM " In the top of the pro

How to deassign a employee from a Org. unit by using function module?

Hi, I want to deassign an employee from an orgnization unit in Org. model. Though I know I can do it manually in Org. Model. But since the number is big, I want to do it by using report. So do you which function module I can use to do it? Many thanks

Provide function module as REST webservice

Hello Experts, Is there a way hoe to provide a function module as REST website ? so not as soap webservice. Thanks in advance. RegardsHi, In fact an FM is standard a WS in WebAS 6.2 (what's under the hood of 4.7) and you can consult them via the webs

Functional module for component overview screen in production order

Hi All, My requirement is, If I am replacing component in BOM then same I need to replaced in existing production ordder. My input will be old item code(BOM component), new item code, plant, production order(If I do not give prdn order as input then

How to create textsymbols by using satndard function module?

Hi. Guru's. There is a report in which at first i can read textpool of a another program through standard function module  ( RS_TEXTPOOL_READ  /  BX_AGR_READ_TEXTPOOL  ) and i don't know  how to insert textsymbols into the textpool after reading thro

How to update other infotype from source infotype via function module?

Want in source infotype to call a func.module, which shall update other infotype(s) in background. Have tried out with HR_INFOTYPE_OPERATION, but without success - gives mitchmatch of source it and target it in the internal it buffer tables. How to d

Creating function module related to total length of lay

how to total the planned lengths for all work orders for lay and abandon opertions separatlyHi all,          I am still seraching for the perfect solution, I am looking for the function module to get summarized actual and planned data from COPA, if a

Function module for Change Master (CC01) creation

Hi all, Pl. tell me function module or BAPI for 'Change Master' Creation. It is linked with BOM to record BOM changes. Its Tcode is 'CC01'. Pl. reply. Regards, Darshanatry this... RFC_CREATE_CHANGE_MASTERRead other 4 answers

Function Module to calculate pallets

Hi, I need a Function Module to calculate pallets for free of charge articles while creating a sales order. can someone name any FM for this purpose. Thanks in advanceHi Abhishek, Check FM L_PALLET_SUGGESTION. Hope this helps. Thanks LakshmanRead oth

Can any one suggest me a function module or BAPI for the below requirement.

Hi all, I have a requirement in which i need to send an IDoc for each item of  the delivery document linked to the shipment document. previously i have called the function module in a BADI, but now the requirement has changed.No BADI or USEREXIT has

Function module for weight

Is there a function module to retieve weight of a material by providing the material number and the UoM. Or the material number and the batch number ThankyouPlease check the below FM's and just pass material number,you get material details LEINT_MARA

Regarding how to use the function module *control_form* in scripts

HI friends, Can any one tell why and where do we use the function module control_form in scripts. Can you give me a small scenario how to use in scripts.hi satish, by using this function module we can pass the control commands to FORM THROUGH ABAP/4

Creating a Function module to send XML Byte String

Hi all, I have to create a Function module to get XML byte string.The internal table is dynamic coloums based on how many data selected as a importparameter.from the internal; table data I have to create a XML byte string as a output.Pl help me to pr

Data Services XI3.1 function module files for SAP R/3 is not working

Hi guys, Thank you for the quick response so far. I am very grateful to you all.  I got an issue and will try to explain as detail as I could and  hope ur guys won't mind. :P I pass the functions module to SAP tech guy to install to SAP using CTS  me

Function Module showing Transparent Table access??

Hi Guys, I'm in the process of writing some programs that will archive some of our Custom tables (they are getting very full!). Now, instead of going through ALL the custom tables we created, I'm trying to write a small program that will bring me tab