Skip to Content

Infotype P0007 does not exist in period from 14.03.2018 to 14.03.2018

In order to upload time events through z program have written the following code

REPORT ZHRTIME4.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
INFOTYPES: 2011,0050.

*INTERNAL TABLE TO UPLOAD DATA INTO
DATA: BEGIN OF IT_DATATAB OCCURS 0,
ROW(500) TYPE C,
END OF IT_DATATAB.

DATA: GD_FILE TYPE STRING.

*TEXT VERSION OF DATA TABLE
TYPES: BEGIN OF T_UPLOADTXT,
PERNR TYPE P0000-PERNR,
DATE TYPE BEGDA,
TIME TYPE TIMS,
END OF T_UPLOADTXT.

TYPES: BEGIN OF T_UPLOADTXT1,
PERNR TYPE P0032-PNALT,
DATE TYPE BEGDA,
TIME TYPE TIMS,
TIM_TYPE TYPE TEVEN-SATZA,
END OF T_UPLOADTXT1.

TYPES: BEGIN OF T_UPLOADTXT2,
PERNR TYPE P0000-PERNR,
DATE TYPE BEGDA,
END OF T_UPLOADTXT2.

DATA: WA_STRING(255) TYPE C,
WA_UPLOADTXT TYPE T_UPLOADTXT,
IT_UPLOAD TYPE TABLE OF T_UPLOADTXT,
WA_T247 TYPE T247,
IT_T247 TYPE TABLE OF T247,
IT_UPLOAD1 TYPE TABLE OF T_UPLOADTXT1,
IT_UPLOAD3 TYPE TABLE OF T_UPLOADTXT2,
IT_UPLOAD4 TYPE TABLE OF T_UPLOADTXT,
WA_UPLOAD TYPE T_UPLOADTXT,
WA_UPLOAD2 TYPE T_UPLOADTXT,
WA_UPLOAD3 TYPE T_UPLOADTXT2,
WA_UPLOAD1 TYPE T_UPLOADTXT1,
IT_P032 TYPE TABLE OF PA0032,
WA_P032 TYPE PA0032.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = P_FILE
MASK = ',*.TXT.'
MODE = 'O'
TITLE = 'UPLOAD FILE'(078)
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.

START-OF-SELECTION.

GD_FILE = P_FILE.

SELECT * FROM T247 INTO TABLE IT_T247 WHERE SPRAS = 'EN'.

DATA : W_DATE TYPE CHAR15,
W_DAY TYPE CHAR2,
W_MON TYPE CHAR3,
W_YEAR TYPE CHAR4,
W_TIME TYPE CHAR8.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = GD_FILE
FILETYPE = 'ASC'
TABLES
DATA_TAB = IT_DATATAB "ITBL_IN_RECORD[]
EXCEPTIONS
FILE_OPEN_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
ELSE.
LOOP AT IT_DATATAB.
CLEAR: WA_STRING, WA_UPLOADTXT.
WA_STRING = IT_DATATAB.
WA_UPLOADTXT-PERNR = WA_STRING+0(10).
W_DATE = WA_STRING+10(11).
SPLIT W_DATE AT '-' INTO W_DAY W_MON W_YEAR.
READ TABLE IT_T247 INTO WA_T247 WITH KEY KTX = W_MON.
IF SY-SUBRC EQ 0.
IF WA_T247-MNR LT 10.
* CONCATENATE '0' WA_T247-MNR INTO WA_T247-MNR.
ENDIF.
ENDIF.
CONCATENATE W_YEAR WA_T247-MNR W_DATE INTO WA_UPLOADTXT-DATE.
CLEAR : WA_T247,W_DAY,W_YEAR,W_DATE.
W_TIME = WA_STRING+22(8).
REPLACE ALL OCCURRENCES OF ':' IN W_TIME WITH SPACE.
WA_UPLOADTXT-TIME = W_TIME.
APPEND WA_UPLOADTXT TO IT_UPLOAD.
CLEAR : WA_UPLOADTXT.
ENDLOOP.
ENDIF.

SORT IT_UPLOAD BY PERNR DATE TIME.

DATA : TABIX TYPE SY-TABIX,
LINES TYPE I.

DESCRIBE TABLE IT_UPLOAD LINES LINES.

LOOP AT IT_UPLOAD INTO WA_UPLOAD.
MOVE-CORRESPONDING WA_UPLOAD TO WA_UPLOAD3.
APPEND WA_UPLOAD3 TO IT_UPLOAD3.
CLEAR : WA_UPLOAD3,WA_UPLOAD.
ENDLOOP.

DELETE ADJACENT DUPLICATES FROM IT_UPLOAD3.

LOOP AT IT_UPLOAD3 INTO WA_UPLOAD3.
LOOP AT IT_UPLOAD INTO WA_UPLOAD WHERE PERNR = WA_UPLOAD3-PERNR AND DATE = WA_UPLOAD3-DATE.
APPEND WA_UPLOAD TO IT_UPLOAD4.
CLEAR : WA_UPLOAD.
ENDLOOP.

SORT IT_UPLOAD4 BY PERNR DATE TIME.
DESCRIBE TABLE IT_UPLOAD4 LINES LINES.
READ TABLE IT_UPLOAD4 INTO WA_UPLOAD INDEX 1.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING WA_UPLOAD TO WA_UPLOAD1.
WA_UPLOAD1-TIM_TYPE = 'P10'.
APPEND WA_UPLOAD1 TO IT_UPLOAD1.
CLEAR : WA_UPLOAD1.
ENDIF.

CLEAR : WA_UPLOAD.
READ TABLE IT_UPLOAD4 INTO WA_UPLOAD INDEX LINES.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING WA_UPLOAD TO WA_UPLOAD1.
WA_UPLOAD1-TIM_TYPE = 'P20'.
APPEND WA_UPLOAD1 TO IT_UPLOAD1.
CLEAR : WA_UPLOAD1.
ENDIF.
CLEAR : WA_UPLOAD.
REFRESH : IT_UPLOAD4.
ENDLOOP.

DATA: LS_P2011 TYPE P2011,
IT_RETURN TYPE BAPIRETURN1,
BAPIPAKEY TYPE BAPIPAKEY.

IF IT_UPLOAD1[] IS NOT INITIAL.

SELECT * FROM PA0032
INTO TABLE IT_P032
FOR ALL ENTRIES IN IT_UPLOAD1
WHERE PNALT EQ IT_UPLOAD1-PERNR.

ENDIF.


LOOP AT IT_UPLOAD1 INTO WA_UPLOAD1.

READ TABLE IT_P032 INTO WA_P032 WITH KEY PNALT = WA_UPLOAD1-PERNR.
IF SY-SUBRC EQ 0.
WA_UPLOAD1-PERNR = WA_P032-PNALT.
ENDIF.

CLEAR : WA_P032.

LS_P2011-PERNR = WA_P032-PERNR.
LS_P2011-LDATE = WA_UPLOAD1-DATE.
LS_P2011-LTIME = WA_UPLOAD1-TIME.
LS_P2011-SATZA = WA_UPLOAD1-TIM_TYPE.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = WA_P032-PERNR
.


CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '2011'
NUMBER = WA_P032-PERNR
RECORD = LS_P2011
OPERATION = 'INS'
IMPORTING
RETURN = IT_RETURN

.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = WA_P032-PERNR
.

CLEAR : WA_UPLOAD1.

ENDLOOP.

Though syntactically it is correct the system is throwing an error that P0007 is not existing in the period.

Have checked P0007 infotype and it is maintained.

Please help

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 14 at 09:20 AM

    Why didn't you use BAPI_CC1_UPLOAD_TIMEEVENT and BAPI_TRANSACTION_COMMIT (then possibly followed by HR_CC1_TIMEEVENT_POST)

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 14 at 09:21 AM

    hi,

    Would be suspicious HR_INFOTYPE_OPERATION cannot be used to load time events.

    These are not actually stores on PA2011 but rather table TEVEN.

    You can use an LSMW (Business Object BUS7014) to load them

    or in an ABAP using

    BAPI BAPI_CC1_UPLOAD_TIMEEVENT

    HR_CC1_TIMEVENT_POST

    Both of which I have done in the past

    bg

    Add comment
    10|10000 characters needed characters exceeded