Web Dynpro Application to update the Communication details of the employee into HR Infotype 105

...Previous

Use the following code to update the data into Infotype 105.

Since these data are individual subtypes on the Infotype 105 the same function module is used 4 times in this method.

BAPI_EMPLOYEE_ENQUEUE–Tolock the employee before inserting a record into the infotype

HR_INFOTYPE_OPERATION– To update the record into the infotype. Based on the requirement this can be used to insert, delete and change the record in an Infotype.

BAPI_EMPLOYEE_DEQUEUE– To unlock the employee after inserting the record into the Infotype.

Since each input filed of this example are individual subtype of infotype 105 the FM HR_INFOTYPE_OPERATIONis used 4 times with different subtypes as per the input fields.

Source Code inside Submit method:

METHOD onactionsubmit .


  
DATA: it_pa105 TYPE STANDARD TABLE OF p0105,
      wa_pa105 
TYPE p0105,
      ls_bapireturn1_tab_e  
TYPE bapireturn1, " For  enque messages
      ls_bapireturn1_tab_d  
TYPE bapireturn1, " For  enque messages
      return_1 
TYPE bapireturn1,
      return_2 
TYPE bapireturn1,
      return_3 
TYPE bapireturn1,
      return_4 
TYPE bapireturn1,
      
key TYPE bapipakey,
      lv_msg1 
TYPE string.

*   get message manager
  
DATA lo_api_controller     TYPE REF TO if_wd_controller.
  
DATA lo_message_manager    TYPE REF TO if_wd_message_manager.

  lo_api_controller ?= wd_this->wd_get_api( ).

  
CALL METHOD lo_api_controller->get_message_manager
    RECEIVING
      message_manager = lo_message_manager.

  
DATA lo_nd_node_details TYPE REF TO if_wd_context_node.

  
DATA lo_el_node_details TYPE REF TO if_wd_context_element.
  
DATA ls_node_details TYPE wd_this->element_node_details.

*   navigate from <CONTEXT> to <NODE_DETAILS> via lead selection
  lo_nd_node_details = wd_context->get_child_node( name = wd_this->wdctx_node_details ).

*   @TODO handle non existant child
*   IF lo_nd_node_details IS INITIAL.
*   ENDIF.

*   get element via lead selection
  lo_el_node_details = lo_nd_node_details->get_element( ).
*   @TODO handle not set lead selection
  
IF lo_el_node_details IS INITIAL.
  
ENDIF.

*   get all declared attributes
  lo_el_node_details->get_static_attributes(
    
IMPORTING
      static_attributes = ls_node_details ).


  
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
    
EXPORTING
      
number = ls_node_details-pernr
    
IMPORTING
      
return = ls_bapireturn1_tab_e.


  
IF ls_bapireturn1_tab_e-message IS NOT INITIAL.

*     report message
    
CALL METHOD lo_message_manager->report_warning
      
EXPORTING
        message_text = ls_bapireturn1_tab_e-
message.

  
ELSE.

" Updating Subtype 0010 Official mail id in Infotype 105

    wa_pa105-pernr = ls_node_details-pernr.
    wa_pa105-begda = sy-datum.
    wa_pa105-endda = 
'99991231'.
    wa_pa105-subty = 
'0010'.“ Subtype for Official mail id can be hardcode.
    wa_pa105-usrid_long = ls_node_details-official_id.

    
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
  
EXPORTING
    infty                  =  
'0105'
    
number                 =  wa_pa105-pernr
    subtype                =  wa_pa105-subty
*   OBJECTID               =
*   LOCKINDICATOR          =
   validityend             =  wa_pa105-begda
   validitybegin           =  wa_pa105-endda
   recordnumber            =   
'001'
    record                 =  wa_pa105
    operation              = 
'INS'
    tclas                  = 
'A'
*   DIALOG_MODE            = '0'
*   NOCOMMIT               =
*    VIEW_IDENTIFIER        =
*   SECONDARY_RECORD       =
 
IMPORTING
   
return                 = return_1
   
key                    = key.

    
CLEAR wa_pa105.

" Updating Subtype 0030 Personal mail id in Infotype 105

    wa_pa105-pernr = ls_node_details-pernr.
    wa_pa105-begda = sy-datum.
    wa_pa105-endda = 
'99991231'.
    wa_pa105-subty = 
'0030'.
    wa_pa105-usrid_long = ls_node_details-personal_id.

    
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
  
EXPORTING
    infty                  =  
'0105'
    
number                 =  wa_pa105-pernr
    subtype                =  wa_pa105-subty
*   OBJECTID               =
*   LOCKINDICATOR          =
   validityend             =  wa_pa105-begda
   validitybegin           =  wa_pa105-endda
   recordnumber            =   
'001'
    record                 =  wa_pa105
    operation              = 
'INS'
    tclas                  = 
'A'
*   DIALOG_MODE            = '0'
*   NOCOMMIT               =
*    VIEW_IDENTIFIER        =
*   SECONDARY_RECORD       =
 
IMPORTING
   
return                 = return_2
   
key                    = key.

    
CLEAR wa_pa105.

" Updating Subtype 400 Official Mobile number in Infotype 105

    wa_pa105-pernr = ls_node_details-pernr.
    wa_pa105-begda = sy-datum.
    wa_pa105-endda = 
'99991231'.
    wa_pa105-subty = 
'0400'.
    wa_pa105-USRID= ls_node_details-official_mobile.

    
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
  
EXPORTING
    infty                  =  
'0105'
    
number                 =  wa_pa105-pernr
    subtype                =  wa_pa105-subty
*   OBJECTID               =
*   LOCKINDICATOR          =
   validityend             =  wa_pa105-begda
   validitybegin           =  wa_pa105-endda
   recordnumber            =   
'001'
    record                 =  wa_pa105
    operation              = 
'INS'
    tclas                  = 
'A'
*   DIALOG_MODE            = '0'
*   NOCOMMIT               =
*    VIEW_IDENTIFIER        =
*   SECONDARY_RECORD       =
 
IMPORTING
   
return                 = return_3
   
key                    = key.

    
CLEAR wa_pa105.

    
" Updating Subtype 0005 FAX in Infotype 105

    wa_pa105-pernr = ls_node_details-pernr.
    wa_pa105-begda = sy-datum.
    wa_pa105-endda = 
'99991231'.
    wa_pa105-subty = 
'0005'.
    wa_pa105-USRID= ls_node_details-fax.

 
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
  
EXPORTING
    infty                  =  
'0105'
    
number                 =  wa_pa105-pernr
    subtype                =  wa_pa105-subty
*   OBJECTID               =
*   LOCKINDICATOR          =
   validityend             =  wa_pa105-begda
   validitybegin           =  wa_pa105-endda
   recordnumber            =   
'001'
    record                 =  wa_pa105
    operation              = 
'INS'
    tclas                  = 
'A'
*   DIALOG_MODE            = '0'
*   NOCOMMIT               =
*    VIEW_IDENTIFIER        =
*   SECONDARY_RECORD       =
 
IMPORTING
   
return                 = return_4
   
key                    = key.

    
CLEAR wa_pa105.

  
ENDIF.


  
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
    
EXPORTING
      
number = ls_node_details-pernr
    
IMPORTING
      
return = ls_bapireturn1_tab_d.

  
IF return_1 IS INITIAL AND return_2 IS  INITIAL
 
AND return_3  IS  INITIAL AND return_4  IS INITIAL.

*   report message
    
CALL METHOD lo_message_manager->report_success
      
EXPORTING
        message_text = 
' Successfully updated'.

  
ELSE.

*     report message
    
CALL METHOD lo_message_manager->report_error_message
      
EXPORTING
        message_text = 
' Not updated Successfully'.

  
ENDIF.

ENDMETHOD

Click here to continue...

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image