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: 

HR_MAINTAIN_MASTERDATA

Former Member
0 Kudos

Hi Experts,

Can someone please show me how i can populate the PA0105 structure and UPDATE THE INFOTYPE using FM HR_MAINTAIN_MASTERDATA.
I am supposed to update fields Userid(subtype - 0001), fax(subtype - 0005), telephone number(subtype - 0020),

Mobile(Subtype - CELL).

Please kindly show me, how i can update all the above fields.
Thanks in advance.

Regards,

Snigdha.

2 REPLIES 2

Former Member
0 Kudos

Try sopmething like the code below (please note, it doesn't match your requirement exactly, but the principle is the same):

  PERFORM add_propv USING '0105'  'P0105-SUBTY'      '0002'            '01' CHANGING p_lt_propv.

 
PERFORM add_propv USING '0105'  'P0105-USRTY'      '0002'            '01' CHANGING p_lt_propv.

 
PERFORM add_propv USING '0105'  'P0105-USRID'      p_main-usrid      '01' CHANGING p_lt_propv.



 
CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'

   
EXPORTING

      pernr             
= wa_main-pernr
*            massn              = gv_massn

      actio             
= 'INS'

      tclas             
= 'A'

      begda             
= p_main-begda

      endda             
= '99991231'

      werks             
= p_main-werks

      persg             
= p_main-persg

      persk             
= p_main-persk

      plans             
= p_main-plans

      dialog_mode       
= p_dial

      luw_mode          
= '1' "Leave as 1. It only commits if ALL the infotypescreated 100%
*            no_existence_check = 'X'
*            no_enqueue         = 'X'

   
IMPORTING

     
return             = lwa_return
*      hr_return          = lwa_zhrhrmm_msg

   
TABLES

      proposed_values   
= lt_propv

      modified_keys     
= lt_mod_keys.


FORM add_propv  USING    p_infty TYPE infotyp

                         p_fname
TYPE prop_fname

                         p_fval 
TYPE any

                         p_seqnr
TYPE char2                 "#EC *

               
CHANGING p_propv TYPE zgss_t_pprop.



 
DATA: lwa_propv TYPE pprop.

 
DATA: lv_val TYPE pprop-fval.



  lv_val
= p_fval.

 
CONDENSE lv_val.



 
CHECK NOT lv_val IS INITIAL.



  lwa_propv
-infty = p_infty.

  lwa_propv
-fname = p_fname.

  lwa_propv
-fval  = lv_val.
*  lwa_propv-seqnr = p_seqnr.



 
APPEND lwa_propv TO p_propv.


ENDFORM.                    " ADD_PROPV

Former Member
0 Kudos

Hi,

        Please check this Sample code .

  DATA:  PROPOSED_VALUES    TYPE TABLE OF PPROP,
        WA_PROPOSED_VALUES   TYPE          PPROP,
        RETURN                              LIKE BAPIRET2  OCCURS 0 WITH HEADER LINE ,
        E_ERROR                            LIKE BDCDATA-FVAL .



*
* Fill infotype 0001 fields

  WA_PROPOSED_VALUES-INFTY = '0001'.
  WA_PROPOSED_VALUES-FNAME = 'PA0105-PERNR'.
  WA_PROPOSED_VALUES- FVAL  = 'XXXXXXXX'  . "PERNR.                       " Personnel number
  APPEND WA_PROPOSED_VALUES TO PROPOSED_VALUES.


  WA_PROPOSED_VALUES-INFTY = '0001'.
  WA_PROPOSED_VALUES-FNAME = 'PA0105-SUBTY'.
  WA_PROPOSED_VALUES-FVAL  =  'XXXXXXXXXXXXXX'.                        " Userid
  APPEND WA_PROPOSED_VALUES TO PROPOSED_VALUES.


*
  WA_PROPOSED_VALUES-INFTY = '0005'.
  WA_PROPOSED_VALUES-FNAME = 'PA0105-SUBTY'.
  WA_PROPOSED_VALUES-FVAL  =   'xxxxxxxxxx'.             " value of fax
  APPEND WA_PROPOSED_VALUES TO PROPOSED_VALUES.
*
  WA_PROPOSED_VALUES-INFTY = '0020'.
  WA_PROPOSED_VALUES-FNAME = 'PA0105-SUBTY'.
  WA_PROPOSED_VALUES-FVAL  = 'xxxxxxxxxx'.                      " telephone number
  APPEND WA_PROPOSED_VALUES TO PROPOSED_VALUES.
*
  WA_PROPOSED_VALUES-INFTY = 'CELL'.
  WA_PROPOSED_VALUES-FNAME = 'PA0105-SUBTY'.
  WA_PROPOSED_VALUES-FVAL  = 'XXXXXXXXXXXXX  '.                  " MOBILE NUMBER
  APPEND WA_PROPOSED_VALUES TO PROPOSED_VALUES.
*


*
* Perform PA30 via Maintain_masterdata
  CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
       EXPORTING
            PERNR           = 'XXXXXXXXX'  "PERNR
            ACTIO           = 'INS'                        " Operation find below details
            BEGDA           = 'XXXXXXXX'      "DATUM   date
            DIALOG_MODE     = '2'               "   find below details
       IMPORTING
            RETURN1         = RETURN
       TABLES
            PROPOSED_VALUES = PROPOSED_VALUES.


IF RETURN-TYPE = 'E'.
  IF SY-SUBRC EQ '0'.
    CONCATENATE RETURN-MESSAGE  RETURN-ID RETURN-NUMBER INTO E_ERROR SEPARATED BY SPACE.

    ELSE .

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                        EXPORTING
                          WAIT          = 'X'
*                        IMPORTING
*                          RETURN        =
          .

  ENDIF.
  ENDIF.

Note :

==================================================================================================================

ACTIO       (Operation)

COP                Copy
DEL                 Delete
DIS                   Display
EDQ                 Lock/unlock
INS                  Create
LIS9                 Delimit
MOD                Change                                     " in your case use this one
INSS                 Create for Actions is not converted to Change

=====================================================================================

DIALOG_MODE        (Kind of dialogue)

You can submit one of three values: ‘0’, ‘1’, or ‘2’, which mean the following:

'0' – The change is processed principally in the background. If an error occurs (in other words, an E message or A message), the entire action is canceled and the module returns a corresponding error message in the 'RETURN' structure.
'1' – The change is processed in the background. If an error occurs, the system switches to a dialog box so that the user can correct the entries.
'2' – The change is processed in a dialog box.


Regard's

Smruti