Difference between revisions of "SAP HCM OM"

From SapWiki
Line 158: Line 158:
 
  ENDFORM.                    "delete_infotype
 
  ENDFORM.                    "delete_infotype
 
.
 
.
.
+
 
.
 
 
  PERFORM delete_infotype USING ls_p9005
 
  PERFORM delete_infotype USING ls_p9005
 
                       CHANGING l_subrc.
 
                       CHANGING l_subrc.

Revision as of 16:59, 11 April 2020

Transacciones

  1. PP01 Actual.datos plan (guiado por menú)
  2. PO10 Actualizar unidad de organización
  3. PO03 Actualizar función
  4. PO13 Actualizar posición
  5. PO01 Actualizar puesto de trabajo
  • Reportes
  1. RHGRENZ0 - Delimitar objetos
  2. RHCHECKRELATIONS - Borrado de enlaces sin objetos existentes
  3. RHCHECK1 - Verif.consistencia base datos

FM OM Infotypes

RH_OBJECT_CREATE

CALL FUNCTION 'RH_OBJECT_CREATE'
  EXPORTING
    plvar               = '01'
    otype               = 'S'
    short               = ls_p1000-short
    stext               = ls_p1000-stext
    begda               = p_begda
    endda               = p_endda
    vtask               = 'B'
  IMPORTING
    objid               = p_objid_new
  EXCEPTIONS
    text_required       = 1
    invalid_otype       = 2
    invalid_date        = 3
    error_during_insert = 4
    error_ext_number    = 5
    undefined           = 6
    OTHERS              = 7.
IF sy-subrc <> 0.
  ROLLBACK WORK.
  p_subrc = 7.
  RETURN.
ENDIF.
 

RH_DELETE_OBJECT

FORM borrar_relaciones USING p_objid.

  DATA: lt_p1001 TYPE TABLE OF p1001 WITH HEADER LINE,
        l_objid  TYPE p1000-objid.

  CALL FUNCTION 'RH_READ_INFTY'
    EXPORTING
      plvar                = '01'
      otype                = 'ZT'
      objid                = p_objid
      infty                = '1001'
      istat                = '1'
    TABLES
      innnn                = lt_p1001
*     OBJECTS              =
    EXCEPTIONS
      all_infty_with_subty = 1
      nothing_found        = 2
      no_objects           = 3
      wrong_condition      = 4
      wrong_parameters     = 5
      OTHERS               = 6.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  LOOP AT lt_p1001 WHERE sclas = 'ZI'.
    MOVE lt_p1001-sobid TO l_objid.

    CALL FUNCTION 'RH_DELETE_OBJECT'
      EXPORTING
        plvar                        = '01'
        otype                        = 'ZI'
        objid                        = l_objid
        vtask                        = 'B'
      EXCEPTIONS
        error_during_delete          = 1
        no_authorization             = 2
        corr_exit                    = 3
        buffer_upd_with_foreign_data = 4
        OTHERS                       = 5.
  ENDLOOP.

  CALL FUNCTION 'RH_UPDATE_DATABASE'
    EXPORTING
      vtask        = 'D'
      commit_flg   = 'X'  "VWMCOMMIT
      clear_buffer = ' '
    EXCEPTIONS
      corr_exit    = 04.
ENDFORM.                    " BORRAR_

RH_INSERT_INFTY

FORM insert_infty USING p_p TYPE any
               CHANGING p_subrc TYPE sy-subrc.

  DATA: wplog_record_tab TYPE TABLE OF wplog,
        wplog_record     TYPE          wplog.

  FIELD-SYMBOLS <wplog> TYPE c.

  ASSIGN p_p TO <wplog> CASTING.
  wplog_record = <wplog>.

  APPEND wplog_record TO wplog_record_tab.

  CALL FUNCTION 'RH_INSERT_INFTY'
    EXPORTING
      vtask               = 'B'
    TABLES
      innnn               = wplog_record_tab
    EXCEPTIONS
      no_authorization    = 1
      error_during_insert = 2
      repid_form_initial  = 2
      corr_exit           = 2
      OTHERS              = 2.

  p_subrc = sy-subrc.

ENDFORM.                    "insert_infty

PERFORM insert_infty USING ls_P1010
                  CHANGING l_subrc.
IF l_subrc <> 0.
  ROLLBACK WORK.
  p_subrc = 5.
  RETURN.
ENDIF.

RH_DELETE_INFTY

FORM delete_infotype USING p_p TYPE any
                  CHANGING p_subrc TYPE sy-subrc.
  DATA: wplog_record_tab TYPE TABLE OF wplog,
        wplog_record     TYPE          wplog.

  FIELD-SYMBOLS <wplog> TYPE c.

  ASSIGN p_p TO <wplog> CASTING.
  wplog_record = <wplog>.

  APPEND wplog_record TO wplog_record_tab.

  CALL FUNCTION 'RH_DELETE_INFTY'
    EXPORTING
      vtask               = 'B'
    TABLES
      innnn               = wplog_record_tab
    EXCEPTIONS
      error_during_delete = 1
      no_authorization    = 2
      delete_first_record = 3
      corr_exit           = 4
      OTHERS              = 5.
  p_subrc = sy-subrc.

ENDFORM.                    "delete_infotype

.

PERFORM delete_infotype USING ls_p9005
                     CHANGING l_subrc.
IF l_subrc <> 0.
  ROLLBACK WORK.
  p_subrc = 5.
  RETURN.
ENDIF.

Leer Descripción de Objeto RH_OBJECT_DESCRIPTION_READ_2

FORM read_description USING p_objid
                            p_otype
                            p_begda
                            p_endda
                            p_subty
                            p_seqnr
                    CHANGING p_longtext TYPE wcb_tdline_tab.

  DATA: i1002 TYPE TABLE OF p1002,
        i1002_exp TYPE TABLE OF p1002_exp WITH HEADER LINE,
         objects TYPE TABLE OF hrobject WITH HEADER LINE.
  DATA ls_longtext LIKE LINE OF p_longtext.

  objects-plvar = c_actual.
  objects-otype = p_otype.
  objects-objid = p_objid.
  APPEND objects.

* read appraisal information and rating description
  CALL FUNCTION 'RH_OBJECT_DESCRIPTION_READ_2'
       EXPORTING
*           LANGU         = SY-LANGU
            begda         = p_begda
            endda         = p_endda
            subty         = p_subty
       TABLES
            i1002         = i1002
            i1002_exp     = i1002_exp
            OBJECTS       = OBJECTS
       exceptions
            nothing_found = 1
            infty_empty   = 2
            undefined     = 3
            OTHERS        = 4.
  IF sy-subrc <> 0.
    CLEAR: i1002,
           i1002_exp.
  ENDIF.


  LOOP AT i1002_exp WHERE subty <> p_subty OR seqnr <> p_seqnr
                       OR begda <> p_begda OR endda <> p_endda.
    DELETE i1002_exp INDEX sy-tabix.
  ENDLOOP.

  LOOP AT i1002_exp.
    MOVE i1002_exp-tline TO ls_longtext.
    APPEND ls_longtext TO p_longtext.
  ENDLOOP.
ENDFORM.                    "read_description
.
.
.

DATA: lt_p1002    TYPE TABLE OF p1002 WITH HEADER LINE,
      lt_relation TYPE hri1001_tab,
      lt_longtext TYPE wcb_tdline_tab.
DATA ls_p1002 LIKE LINE OF lt_p1002.
DATA l_subrc TYPE sy-subrc.

CALL FUNCTION 'RH_READ_INFTY'
  EXPORTING
    plvar                = '01'
    otype                = 'S'
    objid                = p_objid
    infty                = '1002'
  TABLES
    innnn                = lt_p1002
  EXCEPTIONS
    all_infty_with_subty = 1
    nothing_found        = 2
    no_objects           = 3
    wrong_condition      = 4
    wrong_parameters     = 5
    OTHERS               = 6.

LOOP AT lt_p1002 INTO ls_p1002 WHERE istat = '1'.
ENDLOOP.
IF sy-subrc = 0.
  PERFORM read_description IN PROGRAM zhr_sindicato_rutinas
                    USING p_objid
                          ls_p1002-otype
                          ls_p1002-begda
                          ls_p1002-endda
                          ls_p1002-subty
                          ls_p1002-seqnr
                 CHANGING lt_longtext[].
ENDIF.

RH_OBJECT_DESCRIPTION_WRITE

CALL FUNCTION 'RH_OBJECT_DESCRIPTION_WRITE'
  EXPORTING
    plvar                = '01'
    otype                = 'S'
    objid                = p_objid
    begda                = ls_p1002-begda
    endda                = ls_p1002-endda
    subty                = ls_p1002-subty
    vtask                = 'B'
  TABLES
    ptxt1002             = lt_longtext
  EXCEPTIONS
    object_not_found     = 1
    description_required = 2
    no_authority         = 3
    error_during_insert  = 4
    invalid_date         = 5
    undefined            = 6
    OTHERS               = 7.
IF sy-subrc <> 0.
  ROLLBACK WORK.
  l_subrc = 5.
  RETURN.
ENDIF.