BDC to insert Wage Type in Infotype 0008 (Basic Pay)

Addition of new WageTypes to Infotype 0008 often comes as an urgent requirement. Instead of adding WageTypes to individuals, we can upload it through a BDC.

Insert Wage Type In Infotype0008

BDC Source Code:

*&———————————————————————*
*& Report  ZHR_BDC_0008_INSERT                                         *
*&                                                                     *
*&———————————————————————*
*& About: the BDC inserts a new Wage Type into the infotype0008 for    *
*&        Per.No. provided in flat file.                               *
*&———————————————————————*
*& BDC / Flat File Structure:                                          *
*&———————————————————————*
*& PersonnelNo  BeginDate EndDate WageType  Amount                     *
*&———————————————————————*
*&———————————————————————*

REPORT  ZHR_BDC_0008_INSERT no standard page heading line-size 255.

DATA : BDCTAB LIKE BDCDATA OCCURS 100 WITH HEADER LINE.

DATA BEGIN OF itab1 OCCURS 0.
        INCLUDE STRUCTURE p0001.
DATA END OF itab1.
DATA BEGIN OF itab7 OCCURS 0.
        INCLUDE STRUCTURE p0007.
DATA END OF itab7.
DATA BEGIN OF itab8 OCCURS 0.
        INCLUDE STRUCTURE p0008.
DATA END OF itab8.
DATA BEGIN OF itabn OCCURS 0.
        INCLUDE STRUCTURE pbwla.
DATA END OF itabn.
DATA: pos(2).

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK K1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP 1.
PARAMETERS : READFILE like rlgrap-filename DEFAULT
             ‘c:\textfile.txt’ LOWER CASE.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK K1.

data: begin of record OCCURS 10,
      pernr like PA0001-pernr,
      begda like PA0001-begda,
      endda like PA0001-endda,
      lgart like PA0008-lga01,
      amount(12),
      end of record.

start-of-selection.

  PERFORM OPEN_GROUP.
  PERFORM UPLOAD.

  if record[] is NOT INITIAL.
*do.
    LOOP AT record.
*read dataset dataset into record.
      if sy-subrc <> 0. exit. endif.
      data: tbegda(10),
            tendda(10).
      write: record-begda to tbegda,
             record-endda to tendda.
      data: wgtype(20),
            amount(20).
* Get Personnel Data
      PERFORM GET_PERS_DATA.
      clear: pos.
      LOOP AT itabn where endda = ’99991231′.
        pos = pos + 1.
      ENDLOOP.
* Move to new line
      pos = pos + 1.
* Setting position in Table Control
      concatenate ‘Q0008-LGART(‘ pos ‘)’ into wgtype.
      concatenate ‘Q0008-BETRG(‘ pos ‘)’ into amount.
      perform bdc_dynpro      using ‘SAPMP50A’ ’1000′.
      perform bdc_field       using ‘BDC_OKCODE’
                                    ‘=COP’.
      perform bdc_field       using ‘RP50G-PERNR’
*                              ’1341′.
                                     record-pernr.
*perform bdc_field       using ‘RP50G-TIMR6′
*                              ‘X’.
      perform bdc_field       using ‘BDC_CURSOR’
                                    ‘RP50G-CHOIC’.
      perform bdc_field       using ‘RP50G-CHOIC’
                                    ’8′.
      perform bdc_dynpro      using ‘MP000800′ ’2040′.
      perform bdc_field       using ‘BDC_OKCODE’
                                    ‘/00′.
      perform bdc_field       using ‘P0008-BEGDA’
*                              ’01.04.2010′.
                                     tbegda.
      perform bdc_field       using ‘P0008-ENDDA’
*                              ’31.12.9999′.
                                     tendda.
*perform bdc_field       using ‘P0008-TRFAR’
*                              ‘SK’.
*perform bdc_field       using ‘P0008-BSGRD’
*                              ’100.00′.
*perform bdc_field       using ‘P0008-TRFGB’
*                              ‘SK’.
*perform bdc_field       using ‘P0008-DIVGV’
*                              ’100.00′.
*perform bdc_field       using ‘P0008-TRFGR’
*                              ‘JT MGR’.
*perform bdc_field       using ‘P0008-TRFST’
*                              ‘GE’.
*perform bdc_field       using ‘P0008-ANCUR’
*                              ‘INR’.
*perform bdc_field       using ‘Q0008-IBBEG’
*                              ’25.05.2010′.
*perform bdc_field       using ‘P0008-WAERS’
*                              ‘INR’.
*perform bdc_field       using ‘Q0008-LGART(07)’
*                              ’1MDA’.
*perform bdc_field       using ‘Q0008-LGART(07)’
*                              ’1MDA’.
      perform bdc_field       using  wgtype
                                     record-lgart.
*perform bdc_field       using ‘Q0008-BETRG(07)’
*                              ‘               500′.
      perform bdc_field       using  amount
                                     record-amount.
      perform bdc_dynpro      using ‘MP000800′ ’2040′.
      perform bdc_field       using ‘BDC_CURSOR’
                                    ‘P0008-BEGDA’.
      perform bdc_field       using ‘BDC_OKCODE’
                                    ‘=UPD’.
      perform bdc_field       using ‘P0008-BEGDA’
*                              ’01.04.2010′.
                                     tbegda.
      perform bdc_field       using ‘P0008-ENDDA’
*                              ’31.12.9999′.
                                     tendda.
*perform bdc_field       using ‘P0008-TRFAR’
*                              ‘SK’.
*perform bdc_field       using ‘P0008-BSGRD’
*                              ’100.00′.
*perform bdc_field       using ‘P0008-TRFGB’
*                              ‘SK’.
*perform bdc_field       using ‘P0008-DIVGV’
*                              ’100.00′.
*perform bdc_field       using ‘P0008-TRFGR’
*                              ‘JT MGR’.
*perform bdc_field       using ‘P0008-TRFST’
*                              ‘GE’.
*perform bdc_field       using ‘P0008-ANCUR’
*                              ‘INR’.
*perform bdc_field       using ‘Q0008-IBBEG’
*                              ’25.05.2010′.
*perform bdc_field       using ‘P0008-WAERS’
*                              ‘INR’.
*perform bdc_transaction using ‘PA30′.
      CALL FUNCTION ‘BDC_INSERT’
          EXPORTING
               TCODE             = ‘PA30′
*         POST_LOCAL       = NOVBLOCAL
*         PRINTING         = NOPRINT
           TABLES
                DYNPROTAB        = BDCTAB
*    EXCEPTIONS
*         INTERNAL_ERROR   = 1
*         NOT_OPEN         = 2
*         QUEUE_ERROR      = 3
*         TCODE_INVALID    = 4
*         PRINTING_INVALID = 5
*         POSTING_INVALID  = 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.
      REFRESH BDCTAB.
    endloop.

    CALL FUNCTION ‘BDC_CLOSE_GROUP’
*    EXCEPTIONS
*         NOT_OPEN    = 1
*         QUEUE_ERROR = 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.
*perform close_group.
*perform close_dataset using dataset.
  endif.
*&———————————————————————*
*&      Form  BDC_DYNPRO
*&———————————————————————*
*       text
*———————————————————————-*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR BDCTAB.
  BDCTAB-PROGRAM  = PROGRAM.
  BDCTAB-DYNPRO   = DYNPRO.
  BDCTAB-DYNBEGIN = ‘X’.
  APPEND BDCTAB.

ENDFORM.                    “BDC_DYNPRO

*&———————————————————————*
*&      Form  BDC_FIELD
*&———————————————————————*
*       text
*———————————————————————-*
FORM BDC_FIELD USING FNAM FVAL.
*  IF FVAL <> NODATA.
  CLEAR BDCTAB.
  BDCTAB-FNAM = FNAM.
  BDCTAB-FVAL = FVAL.
  APPEND BDCTAB.
*  ENDIF.
ENDFORM.                    “BDC_FIELD
*&———————————————————————*
*&      Form  UPLOAD
*&———————————————————————*
*       text
*———————————————————————-*
FORM UPLOAD .

  CALL FUNCTION ‘UPLOAD’
    EXPORTING
      FILENAME                = READFILE
      FILETYPE                = ‘DAT’
    TABLES
      DATA_TAB                = record
    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.

ENDFORM.                    ” UPLOAD

*&———————————————————————*
*&      Form  OPEN_GROUP
*&———————————————————————*
*       text
*———————————————————————-*
FORM OPEN_GROUP .

  CALL FUNCTION ‘BDC_OPEN_GROUP’
      EXPORTING
           CLIENT              = SY-MANDT
           GROUP               = sy-uname “‘HR_DELIMT’
           KEEP                = ‘X’
           USER                = SY-UNAME
      EXCEPTIONS
           CLIENT_INVALID      = 1
           DESTINATION_INVALID = 2
           GROUP_INVALID       = 3
           GROUP_IS_LOCKED     = 4
           HOLDDATE_INVALID    = 5
           INTERNAL_ERROR      = 6
           QUEUE_ERROR         = 7
           RUNNING             = 8
           SYSTEM_LOCK_ERROR   = 9
           USER_INVALID        = 10
           OTHERS              = 11
            .

ENDFORM.                    ” OPEN_GROUP
*&———————————————————————*
*&      Form  GET_PERS_DATA
*&———————————————————————*
*       text
*———————————————————————-*
FORM GET_PERS_DATA .
  CLEAR : itab1,itab7,itab8,itabn.
  REFRESH : itab1,itab7,itab8,itabn.

  CALL FUNCTION ‘RP_FILL_WAGE_TYPE_TABLE_EXT’
    EXPORTING
      begda                        = record-begda “i0008-begda
      endda                        = ’99991231′
      infty                        = ’0008′
      tclas                        = ‘A’
      pernr                        = record-pernr “i0008-pernr
    TABLES
      pp0001                       = itab1
      pp0007                       = itab7
      pp0008                       = itab8
      ppbwla                       = itabn
    EXCEPTIONS
      error_at_indirect_evaluation = 1
      OTHERS                       = 2.

ENDFORM.                    ” GET_PERS_DATA

Note: The WageTypes should be updated one at a time (i.e., run BDC for all employee for a specific Wage Type. Execute it from SM35. Now repeat the process for another WageType).

BDC Source Code: BDC Insert WageType in Infotype 0008

You might also be interested in these posts:

  1. ABAP HR program to download Employee data
  2. Macros in ABAP-HR Programming – I
  3. MM02 BDC – Select Specific Material Master View
  4. Displaying Icons in ALV Grid using ABAP
  5. Create HR Report Category in SAP

3 Responses to “BDC to insert Wage Type in Infotype 0008 (Basic Pay)”
Medicine Ball Exercises Posted on May 26, 2010 at 8:59 PM

This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!

dental hygienist Posted on June 14, 2010 at 7:46 AM

Great site. A lot of useful information here. I’m sending it to some friends!

CNA Practice Test Posted on June 15, 2010 at 12:15 PM

My cousin recommended this blog and she was totally right keep up the fantastic work!

Post a Comment