You are on page 1of 6

*&---------------------------------------------------------------------*

*& 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
perform bdc_field
perform bdc_field
*
*perform bdc_field
*
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
*
perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
*perform bdc_field
*
perform bdc_field

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=COP'.
using 'RP50G-PERNR'
'1341'.
record-pernr.
using 'RP50G-TIMR6'
'X'.
using 'BDC_CURSOR'
'RP50G-CHOIC'.
using 'RP50G-CHOIC'
'8'.
using 'MP000800' '2040'.
using 'BDC_OKCODE'
'/00'.
using 'P0008-BEGDA'
'01.04.2010'.
tbegda.
using 'P0008-ENDDA'
'31.12.9999'.
tendda.
using 'P0008-TRFAR'
'SK'.
using 'P0008-BSGRD'
'100.00'.
using 'P0008-TRFGB'
'SK'.
using 'P0008-DIVGV'
'100.00'.
using 'P0008-TRFGR'
'JT MGR'.
using 'P0008-TRFST'
'GE'.
using 'P0008-ANCUR'
'INR'.
using 'Q0008-IBBEG'
'25.05.2010'.
using 'P0008-WAERS'
'INR'.
using 'Q0008-LGART(07)'
'1MDA'.
using 'Q0008-LGART(07)'
'1MDA'.
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
FILETYPE
TABLES
DATA_TAB
EXCEPTIONS
CONVERSION_ERROR
FILE_OPEN_ERROR
FILE_READ_ERROR
INVALID_TYPE
NO_BATCH
UNKNOWN_ERROR

= READFILE
= 'DAT'
= record
=
=
=
=
=
=

1
2
3
4
5
6

INVALID_TABLE_WIDTH
GUI_REFUSE_FILETRANSFER
CUSTOMER_ERROR
OTHERS
ENDFORM.

=
=
=
=

7
8
9
10.

" UPLOAD

*&---------------------------------------------------------------------*
*&
Form OPEN_GROUP
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM OPEN_GROUP .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT
=
GROUP
=
KEEP
=
USER
=
EXCEPTIONS
CLIENT_INVALID
=
DESTINATION_INVALID =
GROUP_INVALID
=
GROUP_IS_LOCKED
=
HOLDDATE_INVALID
=
INTERNAL_ERROR
=
QUEUE_ERROR
=
RUNNING
=
SYSTEM_LOCK_ERROR =
USER_INVALID
=
OTHERS
=
.

SY-MANDT
sy-uname "'HR_DELIMT'
'X'
SY-UNAME
1
2
3
4
5
6
7
8
9
10
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

You might also like