Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

populate the infotype p0015 -additional payments

Former Member
0 Kudos

hi experts,

i am trying to populate the infotype p0015 -additional payments infotype .i know the program for uploading only one wage-type (subtype) in main screen of pa30.

what if i want to upload data for 5 wage type for every pernr ..in one program . how should be the format of the internal table . and one more things .. there is no input field for endda. but i have it in the program ..

the program for upload that i know is give below ..

DATA : P0015 LIKE P0015.

DATA : RETURN LIKE BAPIRETURN1.

DATA : KEY LIKE BAPIPAKEY.

DATA : RETURNE LIKE BAPIRETURN1 .

*----


Values (Change as per Requirement)

P0015-PERNR = '1'.

P0015-BEGDA = '2061101'.

P0015-ENDDA = '2061101'.

P0015-LGART = '3075'.

P0015-PREAS = '01'.

P0015-WAERS = 'INR'.

P0015-BETRG = '2500'.

*----- First Enqu

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0015-pernr

IMPORTING

RETURN = RETURNE.

*----


Update

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0015'

NUMBER = P0015-PERNR

SUBTYPE = P0015-SUBTY

OBJECTID = P0015-OBJPS

LOCKINDICATOR = P0015-SPRPS

VALIDITYEND = P0015-ENDDA

VALIDITYBEGIN = P0015-BEGDA

RECORDNUMBER = P0015-SEQNR

RECORD = P0015

OPERATION = 'INS'

TCLAS = 'A'

DIALOG_MODE = '0'

IMPORTING

RETURN = RETURN

KEY = KEY.

IF RETURN IS NOT INITIAL.

WRITE 😕 'Error Occurred'.

ENDIF.

*----


Dequeue

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = P0015-PERNR

1 REPLY 1

Former Member
0 Kudos

The general schema of the report you need is:

loop at pernr.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'...

loop at lgart.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'...

endloop. "lgart

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'...

endloop. "pernr

You must decide what is the best way to choose a set of personnel numbers (pernr) and a set of wage types (lgart) to satysfy the demands.

The set of employees my be determined by the select options where you must fix one by one all personnel numbers (or ranges of personnel numbers) or by transfer personnel numbers from the external file, as well as by means of logical database (PNP) which lets you to establish employees on the basis of different parameters eg. employment status, employee group, etc. When you use the latter method, replace the first loop by an event get pernr.

The set of wage types may be defined directly in the report the same way you established it for one wage type (replace only the structure with a table). But if you want your report to be more flexible, it is recommended that you transfer all data required to create p0015 record by means of the selection screen or from the external file.

This is of course only for the case that you create the same infotype records for all employees (the same date, the same lgart and the same amount, etc.).

My proposal of the report is:

TABLES: pernr.
DATA : p0015 LIKE p0015.
DATA: BEGIN OF it_0015 OCCURS 0,
        begda LIKE p0015-begda,
        endda LIKE p0015-endda,
        lgart LIKE p0015-lgart,
        preas LIKE p0015-preas,
        waers LIKE p0015-waers,
        betrg LIKE p0015-betrg,
      END OF it_0015.
DATA : return LIKE bapireturn1.
DATA : key LIKE bapipakey.
DATA : returne LIKE bapireturn1 .
PARAMETERS: pa_fexp LIKE rlgrap-filename. "external file name

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_fexp.
  PERFORM get_file_path USING pa_fexp.

START-OF-SELECTION.

  CALL FUNCTION 'WS_UPLOAD'
   EXPORTING
*       CODEPAGE                      = ' '
     filename                      = pa_fexp
     filetype                      = 'DAT'
*       HEADLEN                       = ' '
*       LINE_EXIT                     = ' '
*       TRUNCLEN                      = ' '
*       USER_FORM                     = ' '
*       USER_PROG                     = ' '
*       DAT_D_FORMAT                  = ' '
*     IMPORTING
*       FILELENGTH                    =
    TABLES
      data_tab                      = it_0015
   EXCEPTIONS
     conversion_error              = 1
     file_open_error               = 2
     file_read_error               = 3
     invalid_type                  = 4
     no_batch                      = 5
     unknown_error                 = 6
     invalid_table_width           = 7
     gui_refuse_filetransfer       = 8
     customer_error                = 9
     OTHERS                        = 10
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

GET pernr.

  CLEAR p0015.
  p0015-pernr = pernr-pernr.

*----- First Enqu

  CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
       EXPORTING
            number = p0015-pernr
       IMPORTING
            return = returne.

  LOOP AT it_0015.

    MOVE-CORRESPONDING it_0015 TO p0015.

*------------- Update

    CALL FUNCTION 'HR_INFOTYPE_OPERATION'
         EXPORTING
              infty         = '0015'
              number        = p0015-pernr
              subtype       = p0015-subty
              objectid      = p0015-objps
              lockindicator = p0015-sprps
              validityend   = p0015-endda
              validitybegin = p0015-begda
              recordnumber  = p0015-seqnr
              record        = p0015
              operation     = 'INS'
              tclas         = 'A'
              dialog_mode   = '0'
         IMPORTING
              return        = return
              key           = key.

    IF NOT return IS INITIAL.
      WRITE 😕 'Employee:', p0015-pernr, ', Wage Type:', p0015-lgart, '- Error Occurred'.
    ENDIF.

  ENDLOOP.                                                  " it_0015

*--------- Dequeue
  CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
       EXPORTING
            number = p0015-pernr.

END-OF-SELECTION.
*---------------------------------------------------------------------*
*       FORM get_file_path                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  P_MT                                                          *
*---------------------------------------------------------------------*
FORM get_file_path USING p_mt .
  DATA: up_file LIKE rlgrap-filename.

  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_filename = ' '
            def_path     = ' '
            mask         = ',*.*,*.*.'
            mode         = 'O'
            title        = text-008
       IMPORTING
            filename     = up_file
       EXCEPTIONS
            OTHERS.
  IF sy-subrc EQ 0.              "Only if name has been changed,
    p_mt = up_file.              "copy the new name
  ENDIF.

ENDFORM.                    " get_file_path

NOTE 1:

In the program attributes fill the field "Logical database" with the value "PNP".

NOTE 2:

The line of it_0015 external file must be (separated by tab):

01.11.2006	01.11.2006	3075	01	INR	2500

Regards,

Renata