SAP’de Bordro Verilerini Okumak

SAP’de bordro verilerini okuyan örnek bir kodu aşağıda bulabilirsiniz:

 
 

*&———————————————————————*

*&      Form  GET_AMOUNT

*&———————————————————————*

FORM get_amount .

 
 

  DATA:

    lt_rgdir TYPE STANDARD TABLE OF pc261 WITH HEADER LINE,

    lf_result TYPE pay99_result,

    lf_rt TYPE pc207,

    lv_fpper TYPE pc261-fpper.

 
 

* Her bir personel için…

  LOOP AT gt_alv.

 
 

*   Bu personele ait bordro dönemlerini çekelim

    REFRESH lt_rgdir.

    CALL FUNCTION ‘CA_CU_READ_RGDIR_NEW’

      EXPORTING

        persnr                   = gt_alv-pernr

      TABLES

        cu_ca_rgdir              = lt_rgdir

      EXCEPTIONS

        import_mismatch_error_cu = 1

        import_mismatch_error_ca = 2

        no_read_authority_ca     = 3

        no_read_authority_cu     = 4

        error_reading_cu         = 5

        error_reading_ca         = 6

        no_record_found          = 7

        OTHERS                   = 8.

    IF sy-subrc <> 0.

      CALL FUNCTION ‘AIPB_BAPIRET2_FILL’

        EXPORTING

          type   = sy-msgty

          cl     = sy-msgid

          number = sy-msgno

          par1   = sy-msgv1

          par2   = sy-msgv2

          par3   = sy-msgv3

          par4   = sy-msgv4

        IMPORTING

          return = gt_msg.

 
 

      APPEND gt_msg.

    ENDIF.

 
 

*   Seçim ekranında istenen her bir dönem için…

    LOOP AT gr_monat.

*     Bu döneme ait SEQNR’yi alalım

      CONCATENATE p_gjahr gr_monat-low INTO lv_fpper.

      READ TABLE lt_rgdir WITH KEY fpper = lv_fpper.

      CHECK sy-subrc EQ 0.

 
 

*     Personelin bordro detaylarını alalım

      CLEAR lf_result.

 
 

      CALL FUNCTION ‘PYXX_READ_PAYROLL_RESULT’

        EXPORTING

          employeenumber               = gt_alv-pernr

          sequencenumber               = lt_rgdir-seqnr

        CHANGING

          payroll_result               = lf_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

          error_reading_archive        = 8

          error_reading_relid          = 9

          OTHERS                       = 10.

      IF sy-subrc <> 0.

        CALL FUNCTION ‘AIPB_BAPIRET2_FILL’

          EXPORTING

            type   = sy-msgty

            cl     = sy-msgid

            number = sy-msgno

            par1   = sy-msgv1

            par2   = sy-msgv2

            par3   = sy-msgv3

            par4   = sy-msgv4

          IMPORTING

            return = gt_msg.

 
 

        APPEND gt_msg.

      ENDIF.

 
 

*     Bordro kayıtları arasından maaş bilgilerini alıp personel maaş

*     toplamına ekleyelim

      READ TABLE lf_result-inter-rt INTO lf_rt WITH KEY lgart = gc_lgart.” /559

      IF sy-subrc EQ 0.

        ADD lf_rt-betrg TO gt_alv-betrg.

      ENDIF.

 
 

    ENDLOOP” monat

 
 

*   Bu kadar!

    MODIFY gt_alv.

 
 

  ENDLOOP” pernr

 
 

ENDFORM.                    ” GET_AMOUNT

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s