cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the perner based on the username in portal.

Former Member
0 Kudos

Hai all,

I want to pass the pernr based on the userid of the employee.. am using the below code. is it the rite way... If am wrong pls correct me.

Am new to Webdynpro ABAP.

CALL FUNCTION 'HR_GET_EMPLOYEES_FROM_USER'

EXPORTING

USER = SY-UNAME

BEGDA = '19000101'

ENDDA = '99991231'

IV_WITH_AUTHORITY = 'X'

TABLES

EE_TAB = LV_USER.

IF NOT LV_USER is INITIAL.

READ TABLE LV_USER INTO LS_USER INDEX 1.

IF sy-subrc = 0.

DATA lo_nd_service TYPE REF TO if_wd_context_node.

DATA lo_el_service TYPE REF TO if_wd_context_element.

DATA ls_service TYPE wd_this->Element_service.

DATA lv_pernr TYPE wd_this->Element_service-pernr.

  • navigate from <CONTEXT> to <SERVICE> via lead selection

lo_nd_service = wd_context->get_child_node( name = wd_this->wdctx_service ).

  • @TODO handle non existant child

  • IF lo_nd_service IS INITIAL.

  • ENDIF.

  • get element via lead selection

lo_el_service = lo_nd_service->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_service IS INITIAL.

ENDIF.

  • @TODO fill attribute

  • lv_pernr = 1.

  • set single attribute

lo_el_service->set_attribute(

name = `PERNR`

value = ls_user-pernr ).

Thanks in Advance,

Nalla.B

Accepted Solutions (1)

Accepted Solutions (1)

siddharthrajora
Product and Topic Expert
Product and Topic Expert
0 Kudos

HR_GET_EE_FROM_USER_WITHSTATUS

HR_GET_EMPLOYEES_FROM_USER

HR_GET_USER_FROM_EMPLOYEE

Your FM is correct, You can use this.

Answers (1)

Answers (1)

Lukas_Weigelt
Active Contributor
0 Kudos

Hi Nalla,

I always do it like this:

DATA: lv_uname TYPE pa0105-usrid.
DATA: lv_pernr TYPE p0105-pernr.


  CALL FUNCTION 'RP_GET_PERNR_FROM_USERID'
    EXPORTING
      begda     = lv_begda
      endda     = lv_endda
      usrid     = lv_uname
      usrty     = '0001'
    IMPORTING
      usr_pernr = lv_pernr.

I'm curious, why do you ask whether you do it correct? I mean, if you do it correct you'll get the Pernr, if you don't, you won't

I've never used the FM you used for getting Pernr, but if it works out like this, it should be OK.

best regards, Lukas