Difference between revisions of "SAP HCM TIME"

From SapWiki
Line 75: Line 75:
 
               .
 
               .
  
 +
====Ejemplo: leer saldo de vacaciones====
 +
<nowiki>FORM get_saldo_vaca USING p_pernr TYPE p0000-pernr
 +
                CHANGING p_saldo TYPE pc2bf-anzhl
 +
                          p_begda type p2001-begda.
 +
 +
  DATA: lt_zes TYPE STANDARD TABLE OF pc2b6 WITH HEADER LINE,
 +
        lt_ab  TYPE STANDARD TABLE OF pc20i WITH HEADER LINE,
 +
        lt_zl  TYPE STANDARD TABLE OF  pc2bf WITH HEADER LINE.
 +
 +
  DATA: ls_b2_key  TYPE pc2b0,
 +
        ls_keytable TYPE ptm_clst_perview.
 +
 +
  DATA lt_pcl2 TYPE TABLE OF pcl2.
 +
  DATA ls_pcl2 LIKE LINE OF lt_pcl2.
 +
  DATA l_srtfdlow TYPE pcl2-srtfd.
 +
  DATA l_srtfdhigh TYPE pcl2-srtfd.
 +
 +
  CONCATENATE p_pernr '18000101' INTO l_srtfdlow.
 +
  CONCATENATE p_pernr '99991231' INTO l_srtfdhigh.
 +
 +
  SELECT * FROM pcl2 INTO TABLE lt_pcl2 WHERE relid EQ 'B2'
 +
                    AND srtfd BETWEEN l_srtfdlow AND l_srtfdhigh
 +
                    AND srtf2 EQ '00'
 +
                    ORDER BY PRIMARY KEY.                "#EC PORTABLE
 +
  IF sy-subrc = 0.
 +
* leer ultimo
 +
    LOOP AT lt_pcl2 INTO ls_pcl2.
 +
    ENDLOOP.
 +
    ls_b2_key = ls_pcl2-srtfd.
 +
    MOVE-CORRESPONDING ls_pcl2 TO ls_keytable.
 +
    MOVE-CORRESPONDING ls_b2_key TO ls_keytable.
 +
 +
    CALL FUNCTION 'HR_TIME_RESULTS_GET'
 +
      EXPORTING
 +
        get_pernr = p_pernr
 +
        get_pabrj = ls_keytable-pabrj
 +
        get_pabrp = ls_keytable-pabrp
 +
      TABLES
 +
        get_zes  = lt_zes
 +
        get_ab    = lt_ab
 +
        get_zl    = lt_zl.
 +
 +
    LOOP AT lt_zl WHERE lgart = '5T12'.
 +
      ADD lt_zl-anzhl TO p_saldo.
 +
    ENDLOOP.
 +
 +
    p_begda = ls_pcl2-aedtm.
 +
 +
  ENDIF.
 +
 +
ENDFORM.                    "get_saldo_vaca</nowiki>
 
====Leer mensajes====
 
====Leer mensajes====
 
     CALL FUNCTION 'HR_FORMS_TIM_GET_B2_RESULTS'
 
     CALL FUNCTION 'HR_FORMS_TIM_GET_B2_RESULTS'

Revision as of 17:38, 30 November 2020

Codigos

Leer Plan de Horario de Trabajo

Ejemplo: Reporte RPTPSH10

DATA: psp LIKE ptpsp  OCCURS 0 WITH HEADER LINE.

 CLEAR:psp.
 REFRESH:psp[].
 CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'
     EXPORTING
       pernr                   = pernr-pernr
       begda                   = pn-begda
       endda                   = pn-endda
       switch_activ            = '0'
       i0001_i0007_error       = '0'
       read_cluster            = 'X'
     TABLES
       perws                   = psp
   EXCEPTIONS
      error_occured           = 1
      abort_occured           = 2
      OTHERS                  = 3.

 call function 'HR_WORK_SCHEDULE_TIMES'
      exporting
           pernr                   = pernr-pernr
           begda                   = pn-begda
           endda                   = pn-endda
      tables
          i0001                   = p0001
          i0007                   = p0007
          i2003                   = p2003
*         I0049                   =
           perws                   = psp
          daygen                  =  daygen
          dayint                  =  dayint
    exceptions
         error_occured           = 1
         perws_error             = 2
         others                  = 3
           .

* horario teórico
   CALL FUNCTION 'HR_READ_TIMEDATA_PSP'
     EXPORTING
       begin_date            = p_begda
       end_date              = p_endda
       person_id             = p_pernr
     TABLES
       pers_avail            = lt_psp
     EXCEPTIONS
       no_capacity_available = 1
       no_integration_activ  = 2
       timeinfo_error        = 3
       OTHERS                = 4.

Leer Cluster de Tiempos

   CALL FUNCTION 'HR_TIME_RESULTS_GET'
     EXPORTING
       get_pernr = l_pernr
       get_pabrj = l_pabrj   "año
       get_pabrp = l_pabrp   "periodo
     TABLES
       get_zes   = gt_zes
       get_pt    = gt_pt
       get_vert  = gt_vert
       get_ab    =  gt_ab
    EXCEPTIONS
      no_period_specified         = 1
      wrong_cluster_version       = 2
      no_read_authority           = 3
      cluster_archived            = 4
      technical_error             = 5
      OTHERS                      = 6
             .

Ejemplo: leer saldo de vacaciones

FORM get_saldo_vaca USING p_pernr TYPE p0000-pernr
                 CHANGING p_saldo TYPE pc2bf-anzhl
                          p_begda type p2001-begda.

  DATA: lt_zes TYPE STANDARD TABLE OF pc2b6 WITH HEADER LINE,
        lt_ab  TYPE STANDARD TABLE OF pc20i WITH HEADER LINE,
        lt_zl  TYPE STANDARD TABLE OF  pc2bf WITH HEADER LINE.

  DATA: ls_b2_key   TYPE pc2b0,
        ls_keytable TYPE ptm_clst_perview.

  DATA lt_pcl2 TYPE TABLE OF pcl2.
  DATA ls_pcl2 LIKE LINE OF lt_pcl2.
  DATA l_srtfdlow TYPE pcl2-srtfd.
  DATA l_srtfdhigh TYPE pcl2-srtfd.

  CONCATENATE p_pernr '18000101' INTO l_srtfdlow.
  CONCATENATE p_pernr '99991231' INTO l_srtfdhigh.

  SELECT * FROM pcl2 INTO TABLE lt_pcl2 WHERE relid EQ 'B2'
                    AND srtfd BETWEEN l_srtfdlow AND l_srtfdhigh
                    AND srtf2 EQ '00'
                    ORDER BY PRIMARY KEY.                 "#EC PORTABLE
  IF sy-subrc = 0.
* leer ultimo
    LOOP AT lt_pcl2 INTO ls_pcl2.
    ENDLOOP.
    ls_b2_key = ls_pcl2-srtfd.
    MOVE-CORRESPONDING ls_pcl2 TO ls_keytable.
    MOVE-CORRESPONDING ls_b2_key TO ls_keytable.

    CALL FUNCTION 'HR_TIME_RESULTS_GET'
      EXPORTING
        get_pernr = p_pernr
        get_pabrj = ls_keytable-pabrj
        get_pabrp = ls_keytable-pabrp
      TABLES
        get_zes   = lt_zes
        get_ab    = lt_ab
        get_zl    = lt_zl.

    LOOP AT lt_zl WHERE lgart = '5T12'.
      ADD lt_zl-anzhl TO p_saldo.
    ENDLOOP.

    p_begda = ls_pcl2-aedtm.

  ENDIF.

ENDFORM.                    "get_saldo_vaca

Leer mensajes

   CALL FUNCTION 'HR_FORMS_TIM_GET_B2_RESULTS'
     EXPORTING
       pernr                 = l_pernr
       begda                 = l_begda
       endda                 = l_endda
     IMPORTING
       tim_b2                = ls_b2
     EXCEPTIONS
       wrong_cluster_version = 1
       no_read_authority     = 2
       cluster_archived      = 3
       technical_error       = 4
       OTHERS                = 5.
    LOOP AT ls_b2-ft_fehler INTO ls_fehler .
* do whatever
     select single * from t555f WHERE error = ls_fehler-error
                                  and errty = ls_fehler-errty.
.
.
.
   ENDLOOP.

Ampliaciones (SMOD/CMOD)

PTIMTMW : Campos específicos del cliente en table controls del TMW (transaccion PTMW)

ejemplo EXIT_SAPLHRTIM00DVEXIT_001 asignar nombre a columna HRS1
COLUMNS_TITLES-HRS1_TITLE = 'Mi columna'.  
ejemplo EXIT_SAPLHRTIM00DVEXIT_002 calcular valor para columna HRS1
    CALL FUNCTION 'HR_TIME_RESULTS_GET'
     EXPORTING
       get_pernr = im_pernr
       get_pabrj = im_date+0(4)
       get_pabrp = im_date+4(2)
     TABLES
       get_pt    = gt_pt
    EXCEPTIONS
      no_period_specified         = 1
      wrong_cluster_version       = 2
      no_read_authority           = 3
      cluster_archived            = 4
      technical_error             = 5
      OTHERS                      = 6
             .
 LOOP AT gt_pt WHERE ldate EQ im_date.
 * do whatever
 ...
 ...
 ENDLOOP.
 columns_entries-hrs1 = l_hora.

Transacciones gestión de tiempos