Skip to Content
author's profile photo Former Member
Former Member

Getting the perner based on the username in portal.

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on May 26, 2011 at 05:32 PM

    HR_GET_EE_FROM_USER_WITHSTATUS

    HR_GET_EMPLOYEES_FROM_USER

    HR_GET_USER_FROM_EMPLOYEE

    Your FM is correct, You can use this.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 26, 2011 at 11:30 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.