Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

* Through this document, we can understand that how to fetch a payresult data of an employee number irrespective of  country grouping.

* Basically we developers used to search for a corresponding deep structure of a country grouping, in order to fetch and display the employee payresult.

* But we can find the structure through his molga & relid, same logic we are doing here through programming.

* Because of this, we can use the same for different country grouping employees.

Here we have used the dynamic internal table concept. This will make our work easier.

&---------------------------------------------------------------------*
*&     Form  READ_PAYROLL_RESULT
*&---------------------------------------------------------------------*
*       Read the Payroll Result
*----------------------------------------------------------------------*
FORM read_payroll_result CHANGING pt_t558b TYPE table
                                  pt_t558c  TYPE  table.


DATA            l_payresult   TYPE REF TO data.

FIELD-SYMBOLS   <fs_fields>   TYPE dfies,
                    <fs_orgeh>    LIKE LINE OF t_orgeh,
                     <l_payresult> TYPE ANY.

  DATA          : lx_t558c   TYPE ty_t558c,
                  lx_t558b   TYPE ty_t558b.

  DATA          : lv_lines   TYPE numc2.

  FIELD-SYMBOLS : <l_pay>   TYPE hrpay99_rt,
                  <l_betrg>  TYPE maxbt,
                  <l_betpe>  TYPE betpe,
                  <l_lgart>  TYPE lgart,
                  <l_anzhl>  TYPE pranz,
                  <l_rt>     TYPE pc207.

  CLEAR : v_molga, v_relid, t_rgdir[].

  CALL FUNCTION 'HR_PCLX_INIT_BUFFER'
    EXCEPTIONS
      OTHERS = 0.

  CALL FUNCTION 'CU_READ_RGDIR_NEW'
    EXPORTING
      persnr   = pernr-pernr
    IMPORTING
      molga    = v_molga
    TABLES
      in_rgdir =t_rgdir
    EXCEPTIONS
      OTHERS   = 1.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.

  IF t_rgdir[]IS INITIAL.
    EXIT.
  ENDIF.

  IF v_molgaIS INITIAL.
    EXIT.
  ENDIF.

  PERFORM get_relidUSING    v_molga
                    CHANGING v_relid l_payresult v_rc.

  IF v_rc<> 0.
    EXIT.
  ENDIF.

  UNASSIGN <l_payresult>.


  ASSIGN l_payresult->* TO <l_payresult>.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.

  LOOP AT t_rgdirWHERE fpbeg GE c_begdaAND fpend LE c_endda.
    CLEAR <l_payresult>.
    CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
      EXPORTING
        clusterid      = v_relid
        employeenumber = pernr-pernr
        sequencenumber = t_rgdir-seqnr
      CHANGING
        payroll_result = <l_payresult>
      EXCEPTIONS
        OTHERS         = 1.
    CASE sy-subrc.
      WHEN 0.
        UNASSIGN <l_pay>.
        ASSIGN COMPONENT 'INTER-RT' OF STRUCTURE <l_payresult> TO <l_pay>.
        CHECK <l_pay>IS ASSIGNED.
        lv_lines =LINES( <l_pay>).
        DO lv_linesTIMES.
          READ TABLE <l_pay> ASSIGNING <l_rt>INDEX sy-index.
          CHECK <l_rt>IS ASSIGNED.
          ASSIGN COMPONENT 'LGART'  OF STRUCTURE <l_rt>TO <l_lgart>.
          ASSIGN COMPONENT 'BETPE'  OF STRUCTURE <l_rt>TO <l_betpe>.
          ASSIGN COMPONENT 'BETRG'  OF STRUCTURE <l_rt>TO <l_betrg>.
          ASSIGN COMPONENT 'ANZHL'  OF STRUCTURE <l_rt>TO <l_anzhl>.
          CHECK <l_lgart>           IS ASSIGNED   AND
                <l_betpe>           IS ASSIGNED   AND
                <l_betrg>           IS ASSIGNED   AND
                <l_anzhl>           IS ASSIGNED.
          MOVE : <l_lgart>          TO lx_t558c-lgart,
                 <l_betrg>          TO lx_t558c-betrg,
                 <l_betpe>          TO lx_t558c-betpe,
                 <l_anzhl>          TO lx_t558c-anzhl,
                  pernr-pernr       TO lx_t558c-pernr,
                  t_rgdir-seqnr     TO lx_t558c-seqnr,
                  v_molga           TO lx_t558c-molga,
                  t_rgdir-fpend     TO lx_t558c-keydate.
          APPEND: lx_t558c         TO pt_t558c.
          UNASSIGN <l_rt>.
          CLEAR lx_t558c.
        ENDDO.
        MOVE : pernr-pernr          TO lx_t558b-pernr,
               t_rgdir-seqnr        TO lx_t558b-seqnr,
               t_rgdir-payty        TO lx_t558b-payty,
               t_rgdir-payid        TO lx_t558b-payid,
               t_rgdir-paydt        TO lx_t558b-paydt,
               t_rgdir-permo        TO lx_t558b-permo,
               t_rgdir-fpper+0(4)   TO lx_t558b-pabrj,
               t_rgdir-fpper+4(2)   TO lx_t558b-pabrp,
               t_rgdir-fpbeg        TO lx_t558b-fpbeg,
               t_rgdir-fpend        TO lx_t558b-fpend.
        APPEND lx_t558b             TO pt_t558b.
        CLEAR  : lx_t558b.
      WHEN OTHERS.
        CONTINUE.
    ENDCASE.
  ENDLOOP.

ENDFORM.                    " READ_PAYROLL_RESULT
*&--------------------------------------------------------------------*
*&     Form  get_relid
*&--------------------------------------------------------------------*
*       Read the RELID Value
*----------------------------------------------------------------------*
FORM get_relid USING    value(p_molga) TYPE molga
               CHANGINGp_relid        TYPE relid_pcl
                        p_payresult    TYPE REF TO data
                        p_rc           TYPE sysubrc.

  DATA: ls_t500l   TYPE t500l,
        l_payresult TYPE REF TO data.

  PERFORM get_t500lUSING p_molga
                    CHANGING ls_t500l l_payresult p_rc.

  IF p_rcEQ 0.
    p_relid     = ls_t500l-relid.
    p_payresult =l_payresult.
  ELSE.
    CLEAR: p_relid, p_payresult.
  ENDIF.

ENDFORM.                    "get_relid
*&--------------------------------------------------------------------*
*&     Form  get_t500l
*&--------------------------------------------------------------------*
*       Read the T5001 Values
*----------------------------------------------------------------------*
FORM get_t500l USING    value(p_molga) TYPE molga
               CHANGINGps_t500l       TYPE t500l
                        p_payresult    TYPE REF TO data
                        p_rc           TYPE sysubrc.

  DATA: l_typename TYPE typename.

  READ TABLE  t_t500l WITH TABLE KEY molga = p_molga.

  IF sy-subrc <> 0.
    CLEAR t_t500l.
    SELECT SINGLE * FROM t500l INTO t_t500l-t500l
      WHERE molga= p_molga.
    IF sy-subrc <> 0.
      t_t500l-molga= p_molga.
      t_t500l-rc    = 4.
    ELSE.
      SELECT SINGLE typename FROM t52relid INTO l_typename
        WHERE relid= t_t500l-relid.
      t_t500l-rc= sy-subrc.
      IF t_t500l-rc = 0.
        CREATE DATA t_t500l-payresult TYPE (l_typename).
        IF sy-subrc <> 0.
          t_t500l-rc= 4.
          CLEAR t_t500l-t500l.
        ENDIF.
      ENDIF.
    ENDIF.
    INSERT tablet_t500l.
  ENDIF.

  ps_t500l    = t_t500l-t500l.
  p_payresult =t_t500l-payresult.
  p_rc        = t_t500l-rc.

ENDFORM.                                                   "get_t500l