Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error in ABAP report Z_SAP_HR_LDAP

Former Member
0 Kudos

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.

8 REPLIES 8

Former Member
0 Kudos

hi rohit,

to serve u better , double click on the error and pls point the line of error

Former Member
0 Kudos

Hi

iam getting error on below line

concatenate ‘E’ p0001-pernr into attributes_wa-value.

append attributes_wa to attributes.

0 Kudos

hi,

Check the concatenate syntax .. i.e, concatenate statement works for only character variables.

Regards,

Santosh

0 Kudos
this looks strange ,

I copied to my system and tried , first i got the error what u had got ,

then i just removed <b>'E'</b> in the concatenate statement and added again , now it works , do the same and try ur luck



copy paste this and try


*&---------------------------------------------------------------------*
*& 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.

0 Kudos

Hello,

check the lenght of the receiving field, the type is

" VALUE LIKE LDA_ATTR_L-VALUE." check if there is enough length to do this.

If this is not the problem, move 'E' it to a temp variable and then try to concatenate it.

Thanks

Thirumal

0 Kudos

I think the issue is with the quotes .. just make sure you are using 'E' instead of `E`..

~Suresh

Former Member
0 Kudos

Hi

Its better if u debug the program to find where exactly the error is coming.

Regards

Haritha

Former Member
0 Kudos

concatenate ‘E’ p0001-pernr into attributes_wa-value.

place E in single quotes 'E'.