* 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   = pernrpernr
    IMPORTING
      molga    = v_molga
    TABLES
      in_rgdir =t_rgdir
    EXCEPTIONS
      OTHERS   = 1.
  IF sysubrc <> 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 sysubrc <> 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 = pernrpernr
        sequencenumber = t_rgdirseqnr
      CHANGING
        payroll_result = <l_payresult>
      EXCEPTIONS
        OTHERS         = 1.
    CASE sysubrc.
      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 syindex.
          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_t558clgart,
                 <l_betrg>          TO lx_t558cbetrg,
                 <l_betpe>          TO lx_t558cbetpe,
                 <l_anzhl>          TO lx_t558canzhl,
                  pernrpernr       TO lx_t558cpernr,
                  t_rgdirseqnr     TO lx_t558cseqnr,
                  v_molga           TO lx_t558cmolga,
                  t_rgdirfpend     TO lx_t558ckeydate.
          APPEND: lx_t558c         TO pt_t558c.
          UNASSIGN <l_rt>.
          CLEAR lx_t558c.
        ENDDO.
        MOVE : pernrpernr          TO lx_t558bpernr,
               t_rgdirseqnr        TO lx_t558bseqnr,
               t_rgdirpayty        TO lx_t558bpayty,
               t_rgdirpayid        TO lx_t558bpayid,
               t_rgdirpaydt        TO lx_t558bpaydt,
               t_rgdirpermo        TO lx_t558bpermo,
               t_rgdirfpper+0(4)   TO lx_t558bpabrj,
               t_rgdirfpper+4(2)   TO lx_t558bpabrp,
               t_rgdirfpbeg        TO lx_t558bfpbeg,
               t_rgdirfpend        TO lx_t558bfpend.
        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_t500lrelid.
    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 sysubrc <> 0.
    CLEAR t_t500l.
    SELECT SINGLE * FROM t500l INTO t_t500lt500l
      WHERE molga= p_molga.
    IF sysubrc <> 0.
      t_t500lmolga= p_molga.
      t_t500lrc    = 4.
    ELSE.
      SELECT SINGLE typename FROM t52relid INTO l_typename
        WHERE relid= t_t500lrelid.
      t_t500lrc= sysubrc.
      IF t_t500lrc = 0.
        CREATE DATA t_t500lpayresult TYPE (l_typename).
        IF sysubrc <> 0.
          t_t500lrc= 4.
          CLEAR t_t500lt500l.
        ENDIF.
      ENDIF.
    ENDIF.
    INSERT tablet_t500l.
  ENDIF.

  ps_t500l    = t_t500lt500l.
  p_payresult =t_t500lpayresult.
  p_rc        = t_t500lrc.

ENDFORM.                                                   “get_t500l

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply