Skip to Content
0
Former Member
Sep 21, 2006 at 11:32 AM

Error in ABAP report Z_SAP_HR_LDAP

106 Views

Hi All,

I am Getting Syntax error ( Field "'E'" is unknown. it is neither one of specified table nor defined by DATA statement. While executing report mentioned below which uses logical database.

&----


*& Report ZSAPHRDATA *

*& *

&----


*& *

*& *

&----


REPORT Z_SAP_HR_LDAP USING DATABASE PNP.

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.

DATA: mid TYPE sy-msgid VALUE 'LDAPSYNC',

mtype TYPE sy-msgty VALUE 'I',

num TYPE sy-msgno.

  • structure for short ldap-attributes

  • fieldnames must be equal to basis structure LDA_ATTR_L (for RFC-call)

TYPES: BEGIN OF TS_LDAP_ATTR_L,

PERNR LIKE LDA_ATTR_L-PERNR,

ATTR_TAB LIKE LDA_ATTR_L-ATTR_TAB,

ATTR_FIELD LIKE LDA_ATTR_L-ATTR_FIELD,

VALUE LIKE LDA_ATTR_L-VALUE,

END OF TS_LDAP_ATTR_L.

data: attributes type ts_ldap_attr_l occurs 0,

attributes_wa type ts_ldap_attr_l.

infotypes: 0001, 0002.

tables: pernr, rfcdes.

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 'SAPHRLDAP' LIKE LDA_TYPES-LDAPSERVER,

LDAPDEST Default 'LDAPDEST' 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 space keyda keyda.

rp-provide-from-last p0002 space 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 ldap client

  • send attributes

CALL FUNCTION 'SPLDAP_RECEIVE_ATTRIBUTES'

DESTINATION LDAPDEST

EXPORTING

LOGSYS = LOGSYS

SERVERID = LDAPSRV

  • ATTRIBUTES_S = attributes[]

INITIAL_RUN = LDAPINITIALRUN

ATTRIBUTES_L = attributes[]

  • ATTRIBUTES_X = TOTAL_ATTRS_X[].

IMPORTING

RETURN = ERRORS[].

IF NOT ERRORS[] IS INITIAL.

READ TABLE ERRORS INDEX 1 INTO ERRORS_WA.

MESSAGE ID mid TYPE mtype

NUMBER ERRORS_WA-NUMBER

WITH ERRORS_WA-MESSAGE_V1 ERRORS_WA-MESSAGE_V2

ERRORS_WA-MESSAGE_V3 ERRORS_WA-MESSAGE_V4.

endif.