Difference between revisions of "SAP HCM ABAP CLUSTER"

From SapWiki
(Created page with "==Modificar Cluster== *Ejemplo de lectura de cluster con modificacion a tabla BT CLEAR rgdir. REFRESH rgdir. CALL FUNCTION 'CU_READ_RGDIR_NEW' EXPORTING pe...")
 
Line 1: Line 1:
 +
==Lectura de datos de Préstamo==
 +
*----------------------------------------------------------------------*
 +
*      FORM .......
 +
*----------------------------------------------------------------------*
 +
*      copiado de include MP004541
 +
*----------------------------------------------------------------------*
 +
*  -->  p1        text
 +
*  <--  p2        text
 +
*----------------------------------------------------------------------*
 +
form get_loan_results tables  pt_savp structure gt_savp
 +
                      using    pf_pernr
 +
                                pf_dlart
 +
                                pf_objps
 +
                                pf_dbtcu
 +
                      changing pfx_opelo
 +
                                pfx_paylo
 +
                                pfx_abrdt
 +
                                p_cuota
 +
                                pfx_subrc.
 +
 +
  data: ltx_rgdir            like  pc261 occurs 0 with header line,
 +
        ltx_rgdir_o          like  pc261 occurs 0 with header line,
 +
        lsx_rgdir            like  ltx_rgdir,
 +
        lsx_result            type  pay99_result,
 +
        lsx_v0                like line of lsx_result-inter-v0,
 +
        lsx_rt                like line of lsx_result-inter-rt,
 +
        lfx_relid            like  pcl2-relid,
 +
        lfx_molga            like  t500l-molga,
 +
        lsx_t500l            like  t500l,
 +
        lfx_amount            like  q0045-darbt,
 +
        lfx_line              like  sy-tabix,
 +
        lfx_fday              type  d,
 +
        lfx_lday              type  d,
 +
        lfx_opecu            like  q0045-opecu,
 +
        ls_paper              type  pc2paper,
 +
        lf_payment_value_date type datum,
 +
        ls_loid_33            type  pclo_id.                      "Note 834827
 +
  data wa_prest_ipc type zhr_prest_ipc.
 +
*##--BEGIN--##
 +
  clear: pfx_opelo, pfx_paylo, pfx_abrdt, pfx_subrc.
 +
 +
  call function 'CU_READ_RGDIR_NEW'
 +
    exporting
 +
      persnr              = pf_pernr
 +
      check_read_authority = space
 +
    importing
 +
      molga                = lfx_molga
 +
    tables
 +
      in_rgdir            = ltx_rgdir
 +
    exceptions
 +
      others              = 1.
 +
  if sy-subrc <> 0.
 +
    move sy-subrc to pfx_subrc.
 +
    return.
 +
  endif.
 +
 +
  move sy-subrc to pfx_subrc.
 +
 +
* Limitar directorio de cluster al período seleccionado
 +
  call function 'CD_SELECT_DATE_RANGE'
 +
    exporting
 +
      fpper_begda = g_begda
 +
      fpper_endda = g_endda
 +
    tables
 +
      in_rgdir    = ltx_rgdir
 +
      out_rgdir  = ltx_rgdir_o.
 +
 +
  "take only regular and actual periods
 +
  loop at ltx_rgdir_o transporting no fields
 +
                    where void = abap_true
 +
                        or payty <> space
 +
                        or srtza <> 'A'.
 +
    delete ltx_rgdir_o index sy-tabix.
 +
  endloop.
 +
 +
  ltx_rgdir[] = ltx_rgdir_o[].
 +
  sort ltx_rgdir descending by seqnr.
 +
 +
  data(l_lines) = lines( ltx_rgdir ).
 +
  if l_lines = 0.
 +
    pfx_subrc = 9.
 +
    return.
 +
  endif.
 +
 +
*  get relid
 +
  select single * from  t500l
 +
                  into  lsx_t500l
 +
                  where  molga  = lfx_molga.
 +
  move lsx_t500l-relid to lfx_relid.
 +
 +
  data(lflag_loan_exists) = abap_false.
 +
  data lv_subrc type sy-subrc.
 +
 +
  loop at ltx_rgdir into lsx_rgdir
 +
      where fpend >= p0045-begda.  "for performance
 +
 +
    if lflag_loan_exists = abap_true.
 +
      exit. "stop loop at rgdir, because period was found
 +
    endif.
 +
 +
    call function 'PYXX_READ_PAYROLL_RESULT'
 +
      exporting
 +
        clusterid              = lfx_relid
 +
        employeenumber          = pf_pernr
 +
        sequencenumber          = lsx_rgdir-seqnr
 +
        read_only_international = 'X'
 +
        check_read_authority    = ' '
 +
      changing
 +
        payroll_result          = lsx_result
 +
      exceptions
 +
        others                  = 1.
 +
    if sy-subrc <> 0.
 +
      move sy-subrc to pfx_subrc.
 +
    else.
 +
      move sy-subrc to pfx_subrc.
 +
*    get loan result .....
 +
      loop at lsx_result-inter-v0 into lsx_v0 where v0typ = 'L'.
 +
        if pf_dlart = lsx_v0-vinfo+0(4) and
 +
            pf_objps = lsx_v0-vinfo+4(2).
 +
 +
          lflag_loan_exists = abap_true.
 +
          pfx_abrdt = lsx_rgdir-fpend.
 +
 +
          lv_subrc = 1.
 +
          loop at lsx_result-inter-rt into lsx_rt
 +
                                      where v0typ = 'L'
 +
                                      and v0znr = lsx_v0-v0znr
 +
                                      and lgart = '/LLB'.
 +
            if    lsx_rt-betrg = 0.                  "this is a potential period
 +
              "here the loan is already paid back completely
 +
              lv_subrc = 1. "this is equal to that no /LLB exists
 +
              exit. "the loop and check previous period
 +
            else.
 +
* verificar si ya se actualizo por IPC
 +
              select single * into wa_prest_ipc from zhr_prest_ipc where pernr = pf_pernr and
 +
                                                            seqnr = lsx_rgdir-seqnr.
 +
              if sy-subrc <> 0.
 +
                move: lsx_result-inter-versc-waers to lfx_opecu,
 +
                      lsx_rt-betrg                to pfx_opelo.
 +
                lv_subrc = 0.
 +
              else.
 +
                lv_subrc = 1.
 +
                pfx_opelo = 0.
 +
                exit.
 +
              endif.
 +
            endif.
 +
          endloop.
 +
 +
          if lv_subrc = 0.
 +
            loop at lsx_result-inter-rt into lsx_rt
 +
                                        where v0typ = 'L'
 +
                                        and v0znr = lsx_v0-v0znr
 +
                                        and lgart = '/LRP'.
 +
              if    lsx_rt-betrg = 0.                  "this is a potential period
 +
                "here the loan is already paid back completely
 +
                lv_subrc = 1. "this is equal to that no /LLB exists
 +
                exit. "the loop and check previous period
 +
              else.
 +
                move lsx_rt-betrg                to p_cuota.
 +
              endif.
 +
            endloop.
 +
 +
          endif.
 +
 +
        else.                "this loan is not yet processed in payroll
 +
          move '7' to pfx_subrc.
 +
        endif.
 +
      endloop.
 +
 +
    endif.
 +
  endloop.
 +
endform.                              " GET_LOAN_RESULTS
 
==Modificar Cluster==
 
==Modificar Cluster==
 
*Ejemplo de lectura de cluster con modificacion a tabla BT
 
*Ejemplo de lectura de cluster con modificacion a tabla BT

Revision as of 16:52, 26 March 2020

Lectura de datos de Préstamo

  • ----------------------------------------------------------------------*
*       FORM .......
*----------------------------------------------------------------------*
*       copiado de include MP004541
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form get_loan_results tables   pt_savp structure gt_savp
                      using    pf_pernr
                               pf_dlart
                               pf_objps
                               pf_dbtcu
                      changing pfx_opelo
                               pfx_paylo
                               pfx_abrdt
                               p_cuota
                               pfx_subrc.

  data: ltx_rgdir             like  pc261 occurs 0 with header line,
        ltx_rgdir_o           like  pc261 occurs 0 with header line,
        lsx_rgdir             like  ltx_rgdir,
        lsx_result            type  pay99_result,
        lsx_v0                like line of lsx_result-inter-v0,
        lsx_rt                like line of lsx_result-inter-rt,
        lfx_relid             like  pcl2-relid,
        lfx_molga             like  t500l-molga,
        lsx_t500l             like  t500l,
        lfx_amount            like  q0045-darbt,
        lfx_line              like  sy-tabix,
        lfx_fday              type  d,
        lfx_lday              type  d,
        lfx_opecu             like  q0045-opecu,
        ls_paper              type  pc2paper,
        lf_payment_value_date type datum,
        ls_loid_33            type  pclo_id.                      "Note 834827
  data wa_prest_ipc type zhr_prest_ipc.
*##--BEGIN--##
  clear: pfx_opelo, pfx_paylo, pfx_abrdt, pfx_subrc.

  call function 'CU_READ_RGDIR_NEW'
    exporting
      persnr               = pf_pernr
      check_read_authority = space
    importing
      molga                = lfx_molga
    tables
      in_rgdir             = ltx_rgdir
    exceptions
      others               = 1.
  if sy-subrc <> 0.
    move sy-subrc to pfx_subrc.
    return.
  endif.

  move sy-subrc to pfx_subrc.

* Limitar directorio de cluster al período seleccionado
  call function 'CD_SELECT_DATE_RANGE'
    exporting
      fpper_begda = g_begda
      fpper_endda = g_endda
    tables
      in_rgdir    = ltx_rgdir
      out_rgdir   = ltx_rgdir_o.

  "take only regular and actual periods
  loop at ltx_rgdir_o transporting no fields
                    where void = abap_true
                       or payty <> space
                       or srtza <> 'A'.
    delete ltx_rgdir_o index sy-tabix.
  endloop.

  ltx_rgdir[] = ltx_rgdir_o[].
  sort ltx_rgdir descending by seqnr.

  data(l_lines) = lines( ltx_rgdir ).
  if l_lines = 0.
    pfx_subrc = 9.
    return.
  endif.

*   get relid
  select single * from   t500l
                  into   lsx_t500l
                  where  molga  = lfx_molga.
  move lsx_t500l-relid to lfx_relid.

  data(lflag_loan_exists) = abap_false.
  data lv_subrc type sy-subrc.

  loop at ltx_rgdir into lsx_rgdir
      where fpend >= p0045-begda.   "for performance

    if lflag_loan_exists = abap_true.
      exit. "stop loop at rgdir, because period was found
    endif.

    call function 'PYXX_READ_PAYROLL_RESULT'
      exporting
        clusterid               = lfx_relid
        employeenumber          = pf_pernr
        sequencenumber          = lsx_rgdir-seqnr
        read_only_international = 'X'
        check_read_authority    = ' '
      changing
        payroll_result          = lsx_result
      exceptions
        others                  = 1.
    if sy-subrc <> 0.
      move sy-subrc to pfx_subrc.
    else.
      move sy-subrc to pfx_subrc.
*     get loan result .....
      loop at lsx_result-inter-v0 into lsx_v0 where v0typ = 'L'.
        if pf_dlart = lsx_v0-vinfo+0(4) and
           pf_objps = lsx_v0-vinfo+4(2).

          lflag_loan_exists = abap_true.
          pfx_abrdt = lsx_rgdir-fpend.

          lv_subrc = 1.
          loop at lsx_result-inter-rt into lsx_rt
                                      where v0typ = 'L'
                                      and v0znr = lsx_v0-v0znr
                                      and lgart = '/LLB'.
            if    lsx_rt-betrg = 0.                   "this is a potential period
              "here the loan is already paid back completely
              lv_subrc = 1. "this is equal to that no /LLB exists
              exit. "the loop and check previous period
            else.
* verificar si ya se actualizo por IPC
              select single * into wa_prest_ipc from zhr_prest_ipc where pernr = pf_pernr and
                                                           seqnr = lsx_rgdir-seqnr.
              if sy-subrc <> 0.
                move: lsx_result-inter-versc-waers to lfx_opecu,
                      lsx_rt-betrg                 to pfx_opelo.
                lv_subrc = 0.
              else.
                lv_subrc = 1.
                pfx_opelo = 0.
                exit.
              endif.
            endif.
          endloop.

          if lv_subrc = 0.
            loop at lsx_result-inter-rt into lsx_rt
                                        where v0typ = 'L'
                                        and v0znr = lsx_v0-v0znr
                                        and lgart = '/LRP'.
              if    lsx_rt-betrg = 0.                   "this is a potential period
                "here the loan is already paid back completely
                lv_subrc = 1. "this is equal to that no /LLB exists
                exit. "the loop and check previous period
              else.
                move lsx_rt-betrg                 to p_cuota.
              endif.
            endloop.

          endif.

        else.                 "this loan is not yet processed in payroll
          move '7' to pfx_subrc.
        endif.
      endloop.

    endif.
  endloop.
endform.                               " GET_LOAN_RESULTS

Modificar Cluster

  • Ejemplo de lectura de cluster con modificacion a tabla BT
 CLEAR   rgdir.
 REFRESH rgdir.
 CALL FUNCTION 'CU_READ_RGDIR_NEW'
   EXPORTING
     persnr                = i_pernr
   TABLES
     in_rgdir              = rgdir
   EXCEPTIONS
     no_record_found       = 1
     import_mismatch_error = 2
     no_read_authority     = 3
     OTHERS                = 4.
  check sy-subrc = 0.
 DELETE rgdir WHERE fpper NE i_fpper.
 DESCRIBE TABLE rgdir LINES sy-tfill.
 check sy-tfill > 0.
  LOOP AT rgdir.
   ld_pernr = i_pernr.
   ld_seqnr = rgdir-seqnr.
   CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
     EXPORTING
       clusterid                    = 'CL'
       employeenumber               = ld_pernr
       sequencenumber               = ld_seqnr
       read_only_buffer             = ' '
     CHANGING
       payroll_result               = ls_result
     EXCEPTIONS
       illegal_isocode_or_clusterid = 1
       error_generating_import      = 2
       import_mismatch_error        = 3
       subpool_dir_full             = 4
       no_read_authority            = 5
       no_record_found              = 6
       versions_do_not_match        = 7
       OTHERS                       = 8.
* procesar bt
   loop at  ls_result-inter-bt into gs_bt.
     add i_monto to gs_bt-betrg.
     modify ls_result-inter-bt from gs_bt.
   ENDLOOP.
   check sy-subrc = 0.   
   CALL FUNCTION 'PYXX_WRITE_PAYROLL_RESULT'
     EXPORTING
       clusterid                    = 'CL'
       employeenumber               = ld_pernr
       sequencenumber               = ld_seqnr
       payroll_result               = ls_result
     EXCEPTIONS
       illegal_isocode_or_clusterid = 1
       error_generating_export      = 2
       export_error                 = 3
       subpool_dir_full             = 4
       no_update_authority          = 5
       incomplete_result_imported   = 6
       OTHERS                       = 7.
   IF sy-subrc <> 0.
* error
     EXIT.
   ENDIF.
   CALL FUNCTION 'HR_FLUSH_BUFFER_UPDATE_PCLX'
     EXPORTING
       test                = ' '
     EXCEPTIONS
       insert_error        = 1
       no_update_authority = 2
       OTHERS              = 3.
   IF sy-subrc <> 0.
* error
     EXIT.
   ENDIF.