Friday, December 23, 2011

Function module to insert infotype


HR_INFOTYPE_OPERATION can be used for all the operation on infotypes.  Recently with the decoupled infotypes being introduced there were some instances where the program would give a dump when HR_INSERT_INFOTYPE_OPERATION is used.  (The dump would be something like  CL_HRPA_INFOTYPE_FACTORY======CP ....).

 There are two ways to avoid this dump -
  1)  If its a report then use the following statement in the report -

              LOAD-OF-PROGRAM.
              PERFORM do_nothing(sapfp50p).

 2) Use HR_ECM_INSERT_INFOTYPE.

     Sample code --

     Data: lref_msg TYPE REF TO cl_hrpa_message_list,
              lv_ok TYPE boole_d,
              lt_msg TYPE hrpad_message_tab.

      .....
      .....
     ASSIGN ls_pxxxx TO <record>..

     IF <record> is assigned.

           CREATE OBJECT lref_msg.
           CALL FUNCTION 'HR_ECM_INSERT_INFOTYPE'
           EXPORTING
                  pnnnn           = <record>
                  "no_auth_check   = 'X'
                  message_handler = lref_msg
           IMPORTING
                  is_ok           = lv_ok.

           CALL FUNCTION 'HR_ECM_FLUSH_INFOTYPE'
           EXPORTING
                  nocommit        = ''
                  message_handler = lref_msg
           IMPORTING
                  is_ok           = lv_ok.

          TRY.
              CALL METHOD lref_msg->get_message_list
                     IMPORTING
                            messages = lt_msg.
                     CATCH cx_hrpa_violated_assertion .
           ENDTRY.
    ENDIF.

No comments:

Post a Comment