Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report Z_SAP_HR_LDAP_1 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT Z_SAP_HR_LDAP_1 .
DATA: PLVAR LIKE OBJEC-PLVAR,
OBJID LIKE HROBJECT-OBJID,
KEYDA LIKE PLOG-BEGDA,
P_OBJECTS LIKE HROBJECT OCCURS 0,
P_OBJECTS_WA LIKE HROBJECT,
S_OBJECTS LIKE HROBJECT OCCURS 0,
S_OBJECTS_WA LIKE HROBJECT,
I1001_ITAB LIKE P1001 OCCURS 0 WITH HEADER LINE,
I1001_ITAB2 LIKE P1001 OCCURS 0 WITH HEADER LINE,
LDAPDESTINATION LIKE LDA_TYPES-LDAPDESTINATION,
LDAPSERVER LIKE LDA_TYPES-LDAPSERVER,
ldapinitialrun like lda_types-flag,
LOGSYS LIKE TBDLS-LOGSYS,
ERRORS LIKE BAPIRET2 OCCURS 0,
ERRORS_WA LIKE BAPIRET2.
* structure for short ldap-attributes
* fieldnames must be equal to basis strucutre LDA-ATTR_S (for RFC_CALL)
TYPES: BEGIN OF TS_LDAP_ATTR_S,
PERNR LIKE LDA_TYPES-PERNR,
ATTR_TAB LIKE LDA_TYPES-ATTR_TABNAME,
ATTR_FIELD LIKE LDA_TYPES-ATTR_FIELDNAME,
VALUE LIKE LDA_TYPES-VALUE_S,
END OF TS_LDAP_ATTR_S.
data: attributes type ts_ldap_attr_s occurs 0,
attributes_wa type ts_ldap_attr_s.
tables: pernr, rfcdes.
infotypes: 0001, 0002.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_TEST default 'X' AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK B1.
Parameters: LDAPSRV Default 'ADS_TESTSERVER' LIKE LDA_TYPES-LDAPSERVER,
* LDAPDEST Default 'LDAPDEST' LIKE rfcdes-rfcdest.
LDAPDEST Default 'LDAP_SAP_ADS_DC_1' LIKE rfcdes-rfcdest.
* ---------------------------------------------------------------------
at selection-screen.
clear: p_objects[], s_objects[], attributes[].
CALL FUNCTION 'RH_GET_PLVAR'
IMPORTING
PLVAR = PLVAR
EXCEPTIONS
no_plvar = 1
OTHERS = 2.
if sy-subrc <> 0.
MESSAGE E015(HRLDAP).
endif.
KEYDA = sy-datum.
* --------------------------------------------------------------------
get pernr.
rp-provide-from-last p0001 '' keyda keyda.
rp-provide-from-last p0002 '' keyda keyda.
ATTRIBUTES_WA-PERNR = p0001-pernr.
* lastname
attributes_wa-attr_tab = 'EMPLOYEE'.
attributes_wa-attr_field = 'LASTNAME'.
attributes_wa-value = p0002-nachn.
append attributes_wa to attributes.
* firstname
attributes_wa-attr_tab = 'EMPLOYEE'.
attributes_wa-attr_field = 'FIRSTNAME'.
attributes_wa-value = p0002-vorna.
append attributes_wa to attributes.
* sAMAccountName
attributes_wa-attr_tab = 'EMPLOYEE'.
attributes_wa-attr_field = 'SAMACCOUNTNAME'.
* --------------------------------
* Using the employee number a unique name is created
* for the sAMAccountName
* --------------------------------
concatenate 'E' p0001-pernr into attributes_wa-value.
append attributes_wa to attributes.
* other attributes have to added here.
* for each additional attribute an appropriate field
* has to defined in the structure EMPLOYEE
* for example you can choose the following:
*
* attributes_wa-attr_tab = 'EMPLOYEE'.
* attributes_wa-attr_field = 'TELEPHONE'.
*
* if you want to transfer the telephone number
* of an employee from SAP HR to Active Directory
* In the web Application Server an appropriate mapping
* has to be defined using transaction LDAP for each new
* attribute (here called TELEPHONE).
* ---------------------------------------------------------------------
end-of-selection.
* get own logical system
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
OWN_LOGICAL_SYSTEM = LOGSYS
EXCEPTIONS
OWN_LOGICAL_SYSTEM_NOT_DEFINED = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
* TODO: Komprimierung sy-mandt: 3 -> 2 Stellen !!!
CONCATENATE SY-SYSID SY-MANDT INTO LOGSYS.
ENDIF.
loop at attributes into attributes_wa.
write: / ATTRIBUTES_WA-PERNR , attributes_wa-attr_tab.
write: attributes_wa-attr_field ,attributes_wa-value.
endloop.
IF P_TEST = 'X'.
EXIT.
ENDIF.
* ---------------------------------------------------------------------
* send attributes to sap user store ???????
* send attributes