Difference between revisions of "SAP HCM ABAP CLUSTER"

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