Code function module runs in SAP EHP 1 for SAP Solution Manager 7.0 SAP_BASIS 701.
In SAP SOLUTION MANAGER 7.1 SAP_BASIS 702 function module is ignored. it can be seen if you set a breakpoint in the function module.
FUNCTION CREATE_USER_HR_INFO.
*"--------------------------------------------------------------------
*"*"Локальный интерфейс:
*"--------------------------------------------------------------------
DATA: su01_mode(5) type c.
field-symbols: <BNAME> like USR02-BNAME.
field-symbols: <ACCNT> like BAPILOGOND-ACCNT.
field-symbols: <CLASS> like USLOGOND-CLASS.
field-symbols: <FUNCTION> like ADDR3_DATA-FUNCTION.
field-symbols: <DEPARTMENT> like ADDR3_DATA-DEPARTMENT.
field-symbols: <su01_mode> like su01_mode.
DATA hr_rfc TYPE STANDARD TABLE OF ZSTR_HR_PERSON_INFO WITH HEADER LINE. " инф-ция о польз-лях, получаемая из HR по RFC
DATA : sys_msg(80) TYPE c,
indx TYPE i.
DATA ADDRESS LIKE TABLE OF BAPIADDR3 WITH HEADER LINE.
DATA ADDRESSX LIKE TABLE OF BAPIADDR3X WITH HEADER LINE.
DATA DEFAULTS LIKE TABLE OF BAPIDEFAUL WITH HEADER LINE.
DATA DEFAULTSX LIKE TABLE OF BAPIDEFAX WITH HEADER LINE.
DATA LOGONDATA LIKE STANDARD TABLE OF BAPILOGOND WITH HEADER LINE.
DATA LOGONDATAX LIKE STANDARD TABLE OF BAPILOGONX WITH HEADER LINE.
DATA RETURN LIKE STANDARD TABLE OF BAPIRET2.
DATA res_lines TYPE i VALUE 0.
assign ('(SAPLSUU5)g_ok_start') to <su01_mode>.
if sy-subrc = 4.
exit.
ENDIF.
*<su01_mode> will have the following values: create = "CREA", change = "CHAN", and delete = "DELE"
* DATA mes TYPE string.
* mes = sy-subrc.
* CONCATENATE 'sy-subrc' mes into mes separated by SPACE .
* MESSAGE mes TYPE 'I'.
if <su01_mode> = 'CREA'.
assign ('(SAPLSUU5)USLOGOND-ACCNT') to <ACCNT>.
assign ('(SAPLSUU5)USR02-BNAME') to <BNAME>.
assign ('(SAPLSUU5)USLOGOND-CLASS') to <CLASS>.
assign ('(SAPLSUU5)ADDR3_DATA-FUNCTION') to <FUNCTION>.
assign ('(SAPLSUU5)ADDR3_DATA-DEPARTMENT') to <DEPARTMENT>.
hr_rfc-PERNR = <ACCNT>.
APPEND hr_rfc.
CALL FUNCTION 'GET_HR_PERSON_INFO' DESTINATION 'PHRCLNT200_HR'
TABLES
PERSON_INFO = hr_rfc
EXCEPTIONS
SYSTEM_FAILURE = 1 MESSAGE sys_msg
COMMUNICATION_FAILURE = 2 MESSAGE sys_msg
.
DESCRIBE TABLE hr_rfc LINES res_lines.
*если по табельному номеру нашлись данные - заполняю ими структуры
if res_lines > 0.
LOOP at hr_rfc.
DEFAULTS-KOSTL = hr_rfc-PLANS.
DEFAULTSX-KOSTL = 'X'.
if hr_rfc-GESCH = '1'.
ADDRESS-TITLE_P = 'Господин'.
else.
ADDRESS-TITLE_P = 'Госпожа'.
ENDIF.
SPLIT hr_rfc-ENAME AT space
INTO ADDRESS-LASTNAME
ADDRESS-FIRSTNAME
ADDRESS-MIDDLENAME.
if <FUNCTION> = ''.
ADDRESS-FUNCTION = hr_rfc-FUNCTION.
ELSE.
ADDRESS-FUNCTION = <FUNCTION>.
ENDIF.
if <DEPARTMENT> = ''.
ADDRESS-DEPARTMENT = hr_rfc-STEXT.
ELSE.
ADDRESS-DEPARTMENT = <DEPARTMENT>.
ENDIF.
ADDRESSX-TITLE_P = 'X'.
ADDRESSX-LASTNAME = 'X'.
ADDRESSX-FIRSTNAME = 'X'.
ADDRESSX-MIDDLENAME = 'X'.
ADDRESSX-FUNCTION = 'X'.
ADDRESSX-DEPARTMENT = 'X'.
ENDLOOP.
endif.
DEFAULTS-LANGU = 8.
DEFAULTS-DCPFM = 'Y'.
DEFAULTS-SPLD = 'LOCL'.
DEFAULTS-SPDB = 'G'.
DEFAULTS-SPDA = 'D'.
APPEND DEFAULTS to DEFAULTS.
DEFAULTSX-LANGU = 'X'.
DEFAULTSX-DCPFM = 'X'.
DEFAULTSX-SPLD = 'X'.
DEFAULTSX-SPDB = 'X'.
DEFAULTSX-SPDA = 'X'.
APPEND DEFAULTSX.
ADDRESS-NAMEFORMAT = '03'.
ADDRESS-NAMCOUNTRY = 'UA'.
APPEND ADDRESS to ADDRESS.
ADDRESSX-NAMEFORMAT = 'X'.
ADDRESSX-NAMCOUNTRY = 'X'.
APPEND ADDRESSX.
LOGONDATA-GLTGV = sy-datum.
LOGONDATA-GLTGB = '99991231'.
LOGONDATA-TZONE = 'EET'.
if <CLASS> = ''.
LOGONDATA-CLASS = 'END_USER'.
ELSE.
LOGONDATA-CLASS = <CLASS>.
ENDIF.
APPEND LOGONDATA.
LOGONDATAX-GLTGV = 'X'.
LOGONDATAX-GLTGB = 'X'.
LOGONDATAX-CLASS = 'X'.
LOGONDATAX-TZONE = 'X'.
APPEND LOGONDATAX.
CALL FUNCTION 'BAPI_USER_CHANGE'
EXPORTING
USERNAME = <BNAME>
ADDRESS = ADDRESS
ADDRESSX = ADDRESSX
DEFAULTS = DEFAULTS
DEFAULTSX = DEFAULTSX
LOGONDATA = LOGONDATA
LOGONDATAX = LOGONDATAX
TABLES
RETURN = RETURN
.
* DATA mes TYPE string.
* mes = sy-subrc.
* CONCATENATE 'sy-subrc' mes into mes separated by SPACE .
* MESSAGE mes TYPE 'I'.
ENDIF.
*ENDIF.
ENDFUNCTION.