cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP HR 'PYXX_WRITE_PAYROLL_RESULT'

Hi, gurus.

I have a problem with my ABAP code. My program take the payrolls and chage is for random quantities.

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

DATA: ltd_rgdir TYPE STANDARD TABLE OF pc261,
        ltd_payroll TYPE pay99_result,
        ls_temp_wrbtr TYPE wrbtr_bi,
        ltd_rt TYPE STANDARD TABLE OF pc207,
        ls_molga TYPE molga,
        ltd_object_list TYPE STANDARD TABLE OF hrpystruc,
        ls_relid TYPE pcl2-relid."relid_pcl.

  FIELD-SYMBOLS: <fs_rgdir> TYPE pc261,
                 <fs_rt> TYPE pc207.
  CALL FUNCTION 'CU_READ_RGDIR'
    EXPORTING
      persnr                   = pernr-pernr
    TABLES
      in_rgdir                 = ltd_rgdir
   EXCEPTIONS
     no_record_found          = 1
     OTHERS                   = 2.

  CALL FUNCTION 'PYXX_GET_RELID_FROM_PERNR'
    EXPORTING
      employee                          = pernr-pernr
   IMPORTING
     relid                             = ls_relid
     molga                             = ls_molga
*   EXCEPTIONS
*     ERROR_READING_INFOTYPE_0001       = 1
*     ERROR_READING_MOLGA               = 2
*     ERROR_READING_RELID               = 3
*     OTHERS                            = 4
            .

  LOOP AT ltd_rgdir ASSIGNING <fs_rgdir>.
    CLEAR:ltd_payroll,ltd_rt[].
    CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
      EXPORTING
          clusterid                          = ls_relid "'IN'
          employeenumber                     = pernr-pernr
          sequencenumber                     = <fs_rgdir>-seqnr
          read_only_international            = 'X'
       CHANGING
         payroll_result                  = ltd_payroll
       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.

    ltd_rt[] = ltd_payroll-inter-rt[].

    LOOP AT ltd_rt ASSIGNING <fs_rt>.
      CALL FUNCTION 'RANDOM_AMOUNT'
        EXPORTING
          rnd_min    = '100'
          rnd_max    = '3000'
          valcurr    = 'PEN'
        IMPORTING
          rnd_amount = ls_temp_wrbtr.

      REPLACE ALL OCCURRENCES OF ',' IN ls_temp_wrbtr WITH ''.
      CONDENSE ls_temp_wrbtr.

      IF <fs_rt>-betrg > 0.
        <fs_rt>-betrg = ls_temp_wrbtr.
      ENDIF.
    ENDLOOP.

    ltd_payroll-inter-rt[] = ltd_rt[].

    CALL FUNCTION 'PYXX_RESOLVE_PERSON_STRUCTURE'
      EXPORTING
        molga                         = ls_molga
        get_internat_struct           = 'X'
      TABLES
        object_list                   = ltd_object_list
*     EXCEPTIONS
*       DDICTYPE_DOES_NOT_EXIST       = 1
*       OTHERS                        = 2
             .
    CALL FUNCTION 'PYXX_WRITE_PAYROLL_RESULT'
      EXPORTING
        clusterid                    = ls_relid
        employeenumber               = pernr-pernr
        sequencenumber               = <fs_rgdir>-seqnr
        payroll_result               = ltd_payroll
*        client                       = sy-mandt

      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.
*       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    CALL FUNCTION 'HR_FLUSH_BUFFER_UPDATE_PCLX'
*       EXPORTING
*         TEST                      =
*         CLIENT                    =

     EXCEPTIONS
       insert_error              = 1
      no_update_authority       = 2
       OTHERS                    = 3
            .
    IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDLOOP.

On CALL FUNCTION 'PYXX_WRITE_PAYROLL_RESULT' sy-subrc = 6 . I can't update payrolls. I don't know what value I need to update successfully payrolls.

- Andres

Accepted Solutions (0)

Answers (2)

Answers (2)

antoine_foucault
Active Contributor

cool idea program.

could you try and give it a go with cl_hr_pay_access/cl_hr_pay_result if you are familiar with classes?

some hints:

instantiate:

  CREATE OBJECT lr_hr_pay_access
    EXPORTING
      check_authorization = abap_false
    EXCEPTIONS
      type_error          = 1
      OTHERS              = 2.

read:

  lr_hr_pay_access->read_cluster_dir( 
                    EXPORTING pernr            = iv_pernr 
                              access_cluster   = abap_true
                              ix_read_arch     = abap_false 
                    IMPORTING cluster_dir      = lt_rgdir 
                   EXCEPTIONS no_entries_found = 1 
                              OTHERS           = 2 ).

read specific result:

  lo_hr_pay_access->read_pa_result( 

                   EXPORTING pernr = iv_pernr 

                            period = ls_rgdir 

                  IMPORTING payroll_result = lr_hr_pay_result ).

access RT table

lr_hr_pay_result->inter-rt 

write to buffer:

* Write result to buffer --------------------------------------------- *
      lr_hr_pay_access->write_pa_result( 
                   EXPORTING pay_result = lr_hr_pay_result 
                  EXCEPTIONS no_authorization = 1 
                             write_error      = 2 
                             OTHERS           = 3 ).

push buffer to db:

             lr_hr_pay_access->write_to_database( 
                         EXCEPTIONS no_authorization = 1 
                                    write_error      = 2 
                                    OTHERS           = 3 ).

He voila.... I am sure you can work out the missing piece out of your code... should be easy enough.... you might also want to update version table (under inter structure) to reflect that something was manipulated in this result.

good luck.

Antoine

matt
Active Contributor
0 Kudos

ltd_payroll does not contain all the information needed to update payroll.

0 Kudos

What information do I need at ltd_payroll to update it ?

Regards,

-Andres

matt
Active Contributor
0 Kudos

Well, without knowing your data, that's impossible for me to answer. You should debug and find where the error is raised. Near there, you should see the condition that causing the error to be raised.

0 Kudos

Hi, Matthew.

Thanks for your answer. Are there another function in HR to update payrolls after to read them ?

Regards,

-Andres