* This is to update the data to the cat2 transaction to update the
* absence and attendances data. Please use the date in upload as
* the start date of the month, as it is written for upload the whole
* data for the month.
*---------------------------------------------------------------*
report ZHR_CAT2_UPLOAD
no standard page heading line-size 255.
type-pools : TRUXS.
types: begin of ty_final,
profile type TCATST-VARIANT,
keydate type char10,
pernr type CATSFIELDS-PERNR,
SKOSTL TYPE CATSD-SKOSTL,
LSTAR TYPE CATSD-LSTAR,
RPROJ(24) TYPE c,
AWART TYPE CATSD-AWART,
LGART TYPE CATSD-LGART,
day1 TYPE CATSD-DAY1 ,
day2 TYPE CATSD-DAY2,
day3 TYPE CATSD-DAY3,
day4 TYPE CATSD-DAY4,
day5 TYPE CATSD-DAY5,
day6 TYPE CATSD-DAY6,
day7 TYPE CATSD-DAY7,
day8 TYPE CATSD-DAY8,
day9 TYPE CATSD-DAY9,
day10 TYPE CATSD-DAY10,
day11 TYPE CATSD-DAY11,
day12 TYPE CATSD-DAY12,
day13 TYPE CATSD-DAY13,
day14 TYPE CATSD-DAY14,
day15 TYPE CATSD-DAY15,
day16 TYPE CATSD-DAY16,
day17 TYPE CATSD-DAY17,
day18 TYPE CATSD-DAY18,
day19 TYPE CATSD-DAY19,
day20 TYPE CATSD-DAY20,
day21 TYPE CATSD-DAY21,
day22 TYPE CATSD-DAY22,
day23 TYPE CATSD-DAY23,
day24 TYPE CATSD-DAY24,
day25 TYPE CATSD-DAY25,
day26 TYPE CATSD-DAY26,
day27 TYPE CATSD-DAY27,
day28 TYPE CATSD-DAY28,
day29 TYPE CATSD-DAY29,
day30 TYPE CATSD-DAY30,
day31 TYPE CATSD-DAY31,
end of ty_final.
TYPES :
BEGIN OF TYPE_DATA,
EMPLOYEENUMBER TYPE BAPICATS1-EMPLOYEENUMBER , "EMPLOYEE NO.
WORKDATE TYPE BAPICATS1-WORKDATE, "DATE
SEND_CCTR TYPE BAPICATS1-SEND_CCTR, "SENDING COST CENTER
ACTTYPE TYPE BAPICATS1-ACTTYPE , "ACTIVITY TYPE
WBS_ELEMENT TYPE BAPICATS1-WBS_ELEMENT, "WBS ELEMENT
CO_AREA TYPE BAPICATS1-CO_AREA, "CONTROLLING AREA
ABS_ATT_TYPE TYPE BAPICATS1-ABS_ATT_TYPE, "ATTENDANCE OR ABSENCE TYPE
CATSHOURS TYPE BAPICATS1-CATSHOURS, "CATS HOURS
UNIT TYPE BAPICATS1-UNIT, "UNIT OF MEASURE
END OF TYPE_DATA.
types: begin of ty_message,
msg type char100,
end of ty_message.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA :
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL,
I_BAPI TYPE STANDARD TABLE OF BAPICATS1,"INTERNAL TABLE FOR TIMESHEET DATA.
I_RESULT TYPE STANDARD TABLE OF BAPICATS2,"INTERNAL TABLE FOR POSTED RECORDS
I_RET TYPE STANDARD TABLE OF BAPIRET2,
I_INPUT TYPE STANDARD TABLE OF BAPICATS1. "INTERNAL TABLE FOR RETURN MESSAGE.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA :
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA,
WA_BAPI LIKE LINE OF I_BAPI,
WA_RESULT LIKE LINE OF I_RESULT,
WA_RET LIKE LINE OF I_RET,
WA_INPUT LIKE LINE OF I_INPUT.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA: WF_MESSAGE(100),
PROFILE TYPE BAPICATS6-PROFILE,
COST_CENTER(10),
COUNTER TYPE I.
data: it_data type table of ALSMEX_TABLINE with header line,
wa_data1 like line of it_data,
IT_FINAL Type table of ty_final with header line.
*include bdcrecx1.
parameters:: p_file LIKE IBIPPARMS-PATH.
at selection-screen on value-request for p_file.
perform get_f4_for_file.
start-of-selection.
perform get_filedata.
perform get_excel_data. " get the excel data into internal table
perform post_cats_data. " post the cats data into CAT2 transaction
*&---------------------------------------------------------------------*
*& Form GET_EXCEL_DATA
*----------------------------------------------------------------------*
FORM GET_EXCEL_DATA .
sort it_data by row col.
loop at it_data.
case : it_data-col.
when '1'.
it_final-profile = it_data-value.
when '2'.
it_final-keydate = it_data-value.
when '3'.
it_final-pernr = it_data-value.
when '4'.
it_final-SKOSTL = it_data-value.
when '5'.
it_final-LSTAR = it_data-value.
when '6'.
it_final-RPROJ = it_data-value.
when '7'.
it_final-AWART = it_data-value.
when '8'.
it_final-LGART = it_data-value.
when '9'.
it_final-day1 = it_data-value.
when '10'.
it_final-day2 = it_data-value.
when '11'.
it_final-day3 = it_data-value.
when '12'.
it_final-day4 = it_data-value.
when '13'.
it_final-day5 = it_data-value.
when '14'.
it_final-day6 = it_data-value.
when '15'.
it_final-day7 = it_data-value.
when '16'.
it_final-day8 = it_data-value.
when '17'.
it_final-day9 = it_data-value.
when '18'.
it_final-day10 = it_data-value.
when '19'.
it_final-day11 = it_data-value.
when '20'.
it_final-day12 = it_data-value.
when '21'.
it_final-day13 = it_data-value.
when '22'.
it_final-day14 = it_data-value.
when '23'.
it_final-day15 = it_data-value.
when '24'.
it_final-day16 = it_data-value.
when '25'.
it_final-day17 = it_data-value.
when '26'.
it_final-day18 = it_data-value.
when '27'.
it_final-day19 = it_data-value.
when '28'.
it_final-day20 = it_data-value.
when '29'.
it_final-day21 = it_data-value.
when '30'.
it_final-day22 = it_data-value.
when '31'.
it_final-day23 = it_data-value.
when '32'.
it_final-day24 = it_data-value.
when '33'.
it_final-day25 = it_data-value.
when '34'.
it_final-day26 = it_data-value.
when '35'.
it_final-day27 = it_data-value.
when '36'.
it_final-day28 = it_data-value.
when '37'.
it_final-day29 = it_data-value.
when '38'.
it_final-day30 = it_data-value.
when '39'.
it_final-day31 = it_data-value.
endcase.
at end of row.
append it_final.
clear it_final.
endat.
endloop.
ENDFORM. " GET_EXCEL_DATA
*&---------------------------------------------------------------------*
*& Form POST_CATS_DATA
*----------------------------------------------------------------------*
FORM POST_CATS_DATA .
*" VALUE(PROFILE) LIKE BAPICATS6-PROFILE OPTIONAL
data: TESTRUN LIKE BAPICATS6-TESTRUN,
RELEASE_DATA LIKE BAPICATS6-RELEASE_DATA,
AGENT LIKE SWHACTOR,
TEXT_FORMAT_IMP LIKE BAPICATS6-TEXT_FORMAT_IMP ,
it_CATSRECORDS_IN type table of BAPICATS1,
it_CATSRECORDS_OUT type table of BAPICATS2,
wa_CATSRECORDS_IN like line of it_CATSRECORDS_IN,
wa_CATSRECORDS_OUT like line of it_CATSRECORDS_OUT,
RETURN type table of BAPIRET2.
field-symbols :
data: v_name type char30,
v_count type char2,
v_len type i.
loop at it_final.
do 31 times.
clear : v_count.
v_count = sy-index.
concatenate 'IT_FINAL-DAY' v_count into v_name.
condense v_name.
assign (v_name) to
if
* condense it_final-keydate.
v_len = strlen( it_final-keydate ) .
if v_len = '7'.
concatenate it_final-keydate '0' into it_final-keydate .
endif.
v_len = strlen( v_count ) .
if v_len = '1'.
it_final-keydate+7(1) = v_count.
else.
it_final-keydate+6(2) = v_count.
endif.
* it_final-keydate = it_final-keydate + v_count - 1 .
wa_catsrecords_in-workdate = it_final-keydate.
wa_catsrecords_in-SEND_CCTR = it_final-SKOSTL.
wa_catsrecords_in-ACTTYPE = it_final-LSTAR.
wa_catsrecords_in-WBS_ELEMENT = it_final-RPROJ.
wa_catsrecords_in-ABS_ATT_TYPE = it_final-AWART.
wa_catsrecords_in-WAGETYPE = it_final-lgart.
wa_catsrecords_in-UNIT = 'H'.
WA_BAPI-SPLIT = '0'.
wa_catsrecords_in-employeenumber = it_final-pernr.
wa_catsrecords_in-abs_att_type = it_final-awart.
wa_catsrecords_in-catshours =
if
wa_catsrecords_in-all_day_flag = 'X'.
endif.
APPEND wa_catsrecords_in to it_catsrecords_in.
CLEAR wa_catsrecords_in.
endif.
enddo.
**---> CATS: Insert Data Records
CALL FUNCTION 'BAPI_CATIMESHEETMGR_INSERT'
EXPORTING
profile = it_final-profile
text_format_imp = 'ITF'
TESTRUN = ''
RELEASE_DATA = 'X'
TABLES
catsrecords_in = it_catsrecords_in
catsrecords_out = it_catsrecords_out
return = return.
refresh :it_catsrecords_in.
read table return into wa_ret with key type = 'E'.
if sy-subrc = 0.
write:/ 'Error in uploading data for the pernr ' color 6, it_final-pernr color 6.
else.
write:/ 'Successfully uploaded data to the pernr ', it_final-pernr.
endif.
Endloop.
ENDFORM. " POST_CATS_DATA
*&---------------------------------------------------------------------*
*& Form GET_F4_FOR_FILE
*----------------------------------------------------------------------*
FORM GET_F4_FOR_FILE .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file.
ENDFORM. " GET_F4_FOR_FILE
*&---------------------------------------------------------------------*
*& Form GET_FILEDATA
*----------------------------------------------------------------------*
FORM GET_FILEDATA .
data : FILENAME LIKE RLGRAP-FILENAME .
FILENAME = p_file.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILENAME
I_BEGIN_COL = '1'
I_BEGIN_ROW = '1'
I_END_COL = '50'
I_END_ROW = '30000'
TABLES
INTERN = it_data
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
delete it_data where row = '001'.
ENDFORM. " GET_FILEDATA
ALSO READ:
- Upload Job & Position Relations Through PO03.
- BDC To Upload The OM Relations Through T-code PO13.
- Function Modules To Read Benefits Data In HR ABAP.
- Sample Code For Do Varying In HR ABAP.
- Get Family Data In HR ABAP.
.....Back To Index On HR ABAP.
.....Back To MAIN INDEX.
No comments:
Post a Comment