SAP HCM ABAP CLUSTER TIME

From SapWiki

ejemplo 1

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