cancel
Showing results for 
Search instead for 
Did you mean: 

How to Generate a new PERNR using HR_MAINTAIN_MASTERDATA in WD?

Former Member
0 Kudos

Hi Experts;

Can I get some sample code for creating a new PERNR using HR_MAINTAIN_MASTERDATA  FM. ???!!!

I've created  a  some input fields in webdynpro using infotype PA0002 and depending upon those  fields I want to generate a PERNR number .

Plz help me with some sample code ..

Thanks in Adv.

Bunty

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

what am I missing in the below code ??? is the code correct ??? Using the below code how will I get the new PERNR value ??

method ONACTIONSAVE .

    DATA lo_nd_final_node TYPE REF TO if_wd_context_node.

    DATA lo_el_final_node TYPE REF TO if_wd_context_element.

    DATA ls_final_node TYPE wd_this->element_final_node.

   

      DATA lv_inits LIKE ls_final_node-inits.

      DATA lv_nachn LIKE ls_final_node-nachn.

      DATA lv_vorna LIKE ls_final_node-vorna.

       DATA lv_titel LIKE ls_final_node-titel.

       DATA lv_gesch LIKE ls_final_node-gesch.

       DATA lv_natio LIKE ls_final_node-natio.

       DATA lv_famst LIKE ls_final_node-famst.

         DATA lv_gbpas LIKE ls_final_node-gbpas.

         DATA lv_stras LIKE ls_final_node-stras.

          DATA lv_ort01 LIKE ls_final_node-ort01.

          DATA lv_pstlz LIKE ls_final_node-pstlz.

         

           DATA lv_telnr LIKE ls_final_node-telnr.

          DATA lv_locat LIKE ls_final_node-locat.

            DATA lv_usrid LIKE ls_final_node-usrid.

           

      

   

*   navigate from <CONTEXT> to <FINAL_NODE> via lead selection

    lo_nd_final_node = wd_context->get_child_node( name = wd_this->wdctx_final_node ).

*   get element via lead selection

    lo_el_final_node = lo_nd_final_node->get_element(  ).

*   get single attribute

    lo_el_final_node->get_attribute(

      EXPORTING

        name =  `INITS`

      IMPORTING

        value = lv_inits ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `NACHN`

    IMPORTING

      value = lv_nachn ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `VORNA`

    IMPORTING

      value = lv_vorna ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `TITEL`

    IMPORTING

      value = lv_titel ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `GESCH`

    IMPORTING

      value = lv_gesch ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `NATIO`

    IMPORTING

      value = lv_natio ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `FAMST`

    IMPORTING

      value = lv_famst ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `GBPAS`

    IMPORTING

      value = lv_gbpas ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `STRAS`

    IMPORTING

      value = lv_stras ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `ORT01`

    IMPORTING

      value = lv_ort01 ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `PSTLZ`

    IMPORTING

      value = lv_pstlz ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `LAND1`

    IMPORTING

      value = lv_land1 ).

 

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `LOCAT`

    IMPORTING

      value = lv_locat ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `TELNR`

    IMPORTING

      value = lv_telnr ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `USRID`

    IMPORTING

      value = lv_usrid ).

 

DATA lv_new_pernr LIKE ls_final_node-new_pernr.

* get single attribute

  lo_el_final_node->SET_attribute(

    EXPORTING

      name =  `NEW_PERNR`

    IMPORTING

      value = lv_new_pernr ).

CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'

* EXPORTING

*   PERNR                    = '00000000'

*   MASSN                    =

*   ACTIO                    = 'INS'

*   TCLAS                    = 'A'

*   BEGDA                    = SY-DATUM

*   ENDDA                    = '99991231'

*   OBJPS                    =

*   SEQNR                    =

*   SPRPS                    =

*   SUBTY                    =

*   WERKS                    =

*   PERSG                    =

*   PERSK                    =

*   PLANS                    =

*   DIALOG_MODE              = '0'

*   LUW_MODE                 = '1'

*   NO_EXISTENCE_CHECK       = ' '

*   NO_ENQUEUE               = ' '

* IMPORTING

*   RETURN                   =

*   RETURN1                  =

*   HR_RETURN                =

  TABLES

    proposed_values          =

*   MODIFIED_KEYS            =

          .

endmethod.

ramakrishnappa
Active Contributor
0 Kudos

Hi Bunty,

Instead of reading single attribute at a time, you can get whole structure values from node as below


    DATA lo_nd_final_node TYPE REF TO if_wd_context_node.

    DATA lo_el_final_node TYPE REF TO if_wd_context_element.

    DATA ls_final_node TYPE wd_this->element_final_node.

         

    

 

*   navigate from <CONTEXT> to <FINAL_NODE> via lead selection

    lo_nd_final_node = wd_context->get_child_node( name = wd_this->wdctx_final_node ).

*   get element via lead selection

    lo_el_final_node = lo_nd_final_node->get_element(  ).

   lo_el_final_node->get_static_attributes(

          importing

               static_attributes = ls_final_node ).

----------------

Now, ls_final_node can be used where ever required i.e. ls_final_node-inits, ls_final_node-land1, etc

----------------

You need to pass all the required data to function module & pass no_existance_check = X.

CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'

* EXPORTING

*   PERNR                    = ls_final_node-new_pernr

  MASSN                    = '0000'

*   ACTIO                    = 'INS'

*   TCLAS                    = 'A'

*   BEGDA                    = SY-DATUM

*   ENDDA                    = '99991231'

*   OBJPS                    =

*   SEQNR                    =

*   SPRPS                    =

*   SUBTY                    =

*   WERKS                    =

*   PERSG                    =

*   PERSK                    =

*   PLANS                    =

*   DIALOG_MODE              = '0'

*   LUW_MODE                 = '1'

NO_EXISTENCE_CHECK       = 'X'

*   NO_ENQUEUE               = ' '

* IMPORTING

*   RETURN                   =

*   RETURN1                  =

*   HR_RETURN                =

  TABLES

    proposed_values          =

*   MODIFIED_KEYS            =

----------------

Note: for each parameter find out the correct values need to be passed by checking with FUNCTIONAL consultant

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Thank u Mr. Rama for ur valuable response ....

Thanks & Rgds,

Bunty

ramakrishnappa
Active Contributor
0 Kudos

Hi Bunty,

You can also try the below links for sample code

Use Of BAPI HR_MAINTAIN_MASTERDATA For Updating HR DATA

Hope this helps you.

Regards,

Rama

former_member197475
Active Contributor
0 Kudos

Hi Bunty,

Hope the below thread will help you.

ABAP Sample code for HR_MAINTAIN_MASTERDATA | SCN

BR,

RAM.

Former Member
0 Kudos

what am I missing in the below code ??? is the code correct ??? Using the below code how will I get the new PERNR value ??

method ONACTIONSAVE .

    DATA lo_nd_final_node TYPE REF TO if_wd_context_node.

    DATA lo_el_final_node TYPE REF TO if_wd_context_element.

    DATA ls_final_node TYPE wd_this->element_final_node.

  

      DATA lv_inits LIKE ls_final_node-inits.

      DATA lv_nachn LIKE ls_final_node-nachn.

      DATA lv_vorna LIKE ls_final_node-vorna.

       DATA lv_titel LIKE ls_final_node-titel.

       DATA lv_gesch LIKE ls_final_node-gesch.

       DATA lv_natio LIKE ls_final_node-natio.

       DATA lv_famst LIKE ls_final_node-famst.

         DATA lv_gbpas LIKE ls_final_node-gbpas.

         DATA lv_stras LIKE ls_final_node-stras.

          DATA lv_ort01 LIKE ls_final_node-ort01.

          DATA lv_pstlz LIKE ls_final_node-pstlz.

        

           DATA lv_telnr LIKE ls_final_node-telnr.

          DATA lv_locat LIKE ls_final_node-locat.

            DATA lv_usrid LIKE ls_final_node-usrid.

          

     

  

*   navigate from <CONTEXT> to <FINAL_NODE> via lead selection

    lo_nd_final_node = wd_context->get_child_node( name = wd_this->wdctx_final_node ).

*   get element via lead selection

    lo_el_final_node = lo_nd_final_node->get_element(  ).

*   get single attribute

    lo_el_final_node->get_attribute(

      EXPORTING

        name =  `INITS`

      IMPORTING

        value = lv_inits ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `NACHN`

    IMPORTING

      value = lv_nachn ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `VORNA`

    IMPORTING

      value = lv_vorna ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `TITEL`

    IMPORTING

      value = lv_titel ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `GESCH`

    IMPORTING

      value = lv_gesch ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `NATIO`

    IMPORTING

      value = lv_natio ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `FAMST`

    IMPORTING

      value = lv_famst ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `GBPAS`

    IMPORTING

      value = lv_gbpas ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `STRAS`

    IMPORTING

      value = lv_stras ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `ORT01`

    IMPORTING

      value = lv_ort01 ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `PSTLZ`

    IMPORTING

      value = lv_pstlz ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `LAND1`

    IMPORTING

      value = lv_land1 ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `LOCAT`

    IMPORTING

      value = lv_locat ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `TELNR`

    IMPORTING

      value = lv_telnr ).

* get single attribute

  lo_el_final_node->get_attribute(

    EXPORTING

      name =  `USRID`

    IMPORTING

      value = lv_usrid ).

DATA lv_new_pernr LIKE ls_final_node-new_pernr.

* get single attribute

  lo_el_final_node->SET_attribute(

    EXPORTING

      name =  `NEW_PERNR`

    IMPORTING

      value = lv_new_pernr ).

CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'

* EXPORTING

*   PERNR                    = '00000000'

*   MASSN                    =

*   ACTIO                    = 'INS'

*   TCLAS                    = 'A'

*   BEGDA                    = SY-DATUM

*   ENDDA                    = '99991231'

*   OBJPS                    =

*   SEQNR                    =

*   SPRPS                    =

*   SUBTY                    =

*   WERKS                    =

*   PERSG                    =

*   PERSK                    =

*   PLANS                    =

*   DIALOG_MODE              = '0'

*   LUW_MODE                 = '1'

*   NO_EXISTENCE_CHECK       = ' '

*   NO_ENQUEUE               = ' '

* IMPORTING

*   RETURN                   =

*   RETURN1                  =

*   HR_RETURN                =

  TABLES

    proposed_values          =

*   MODIFIED_KEYS            =

          .

endmethod.