Вы находитесь на странице: 1из 3

11/8/2019 Upload infotype 2006 (Absence Quotas) - Code Gallery - SCN Wiki

Getting Started Store

Community WIKI SAP Community Welcome, Guest Login Register Search the Community

Code Gallery

Upload infotype 2006 (Absence Quotas)


Created by VIKAS RAO on Jun 13, 2014

Below code can be used to upload data of infotype 2006 (Absence Quotas)

REPORT ZHB2006.

DATA : p_infile LIKE rlgrap-filename VALUE 'C:\info2006.xls'.

DATA: L_P2006 TYPE P2006.


DATA: L_CAPFODEKEY TYPE BAPIPAKEY, Return type BAPIRETURN1.

PARAMETERS p_frmlin TYPE i DEFAULT 4. " From Line No


PARAMETERS p_toline TYPE i DEFAULT 65000. " To Line No
PARAMETERS p_frmcol TYPE i DEFAULT 1. " From col No
PARAMETERS p_tocol TYPE i DEFAULT 7. " To col No

START-OF-SELECTION.

PERFORM sub_xls_to_itab. " Get data from xls to internal table


*&---------------------------------------------------------------------*
*& Form SUB_XLS_TO_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM sub_xls_to_itab .
DATA: lwa_intern TYPE alsmex_tabline,
lit_intern TYPE STANDARD TABLE OF alsmex_tabline INITIAL SIZE 0.

DATA: l_row TYPE kcd_ex_row_n. " Row


" lv_zcomptcode TYPE zcomptcode.

REFRESH : lit_intern .
CLEAR : lwa_intern .

** IF p_cmstr = 'X'.
** SELECT MAX( zcomptcode ) FROM zvcompt INTO lv_zcomptcode .
** ENDIF.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'


EXPORTING
filename = p_infile
i_begin_col = p_frmcol
i_begin_row = p_frmlin
i_end_col = p_tocol
i_end_row = p_toline
TABLES
intern = lit_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole =2
OTHERS = 3.
IF sy-subrc <> 0 .
MESSAGE i899(mm) WITH text-003. " Error in uploading the file from presentation server
LEAVE LIST-PROCESSING.

ELSE.

l_row = 1.
LOOP AT lit_intern INTO lwa_intern.

IF l_row = lwa_intern-row.
IF lwa_intern-col = 1.
L_P2006-PERNR = lwa_intern-value.
L_P2006-INFTY = '2006'.
ELSEIF lwa_intern-col = 2.
L_P2006-SUBTY = lwa_intern-value.

ELSEIF lwa_intern-col = 3.
* PERFORM conv_date_yyyymmdd USING lwa_intern-value.
L_P2006-BEGDA = lwa_intern-value.

ELSEIF lwa_intern-col = 4.

https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=491918545 1/3
11/8/2019 Upload infotype 2006 (Absence Quotas) - Code Gallery - SCN Wiki
* PERFORM conv_date_yyyymmdd USING lwa_intern-value.
L_P2006-ENDDA = lwa_intern-value.

ELSEIF lwa_intern-col = 5.
* CONCATENATE lwa_intern-value
L_P2006-ANZHL = lwa_intern-value.
ELSEIF lwa_intern-col = 6.
* PERFORM conv_date_yyyymmdd USING lwa_intern-value.
L_P2006-DESTA = lwa_intern-value.
ELSEIF lwa_intern-col = 7.
* PERFORM conv_date_yyyymmdd USING lwa_intern-value.
L_P2006-DEEND = lwa_intern-value.
ENDIF.

AT END OF row.

call function 'BAPI_EMPLOYEE_ENQUEUE'


exporting
number = L_P2006-pernr
importing
return = return.

call function 'HR_INFOTYPE_OPERATION'


exporting
infty = '2006'
number = L_P2006-pernr
subtype = L_P2006-SUBTY
objectid =' '
lockindicator = ' '
* ANZHL = L_P2006-ANZHL
* DESTA = L_P2006-DESTA
* DEEND = L_P2006-DEEND
* validityend = L_P2006-ENDDA
* validitybegin = L_P2006-BEGDA
record = L_P2006
operation = 'INS'
nocommit =''
dialog_mode = '0'
importing
return = return
key = L_CAPFODEKEY.

call function 'BAPI_EMPLOYEE_DEQUEUE'


exporting
number = L_P2006-pernr
importing
return = return.

l_row = l_row + 1.
ENDAT.

ENDIF.

ENDLOOP.

ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CONV_DATE_YYYYMMDD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_ZPDDATE text
*----------------------------------------------------------------------*
FORM conv_date_yyyymmdd USING p_date.

DATA : dd(2) TYPE n,


mm(2) TYPE n,
yyyy(4) TYPE n,
dl TYPE i.

dd = p_date+0(2).
mm = p_date+3(2).
yyyy = p_date+5(4).

CLEAR : p_date.

CONCATENATE dd mm yyyy INTO p_date.

* ENDIF.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'


EXPORTING
date_external = p_date
* ACCEPT_INITIAL_DATE =

https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=491918545 2/3
11/8/2019 Upload infotype 2006 (Absence Quotas) - Code Gallery - SCN Wiki
IMPORTING
date_internal = p_date
EXCEPTIONS
date_external_is_invalid =1
OTHERS =2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDFORM. " CONV_DATE_YYYYMMDD


No labels

Contact Us SAP Help Portal


Privacy Terms of Use Legal Disclosure Copyright Cookie Preferences Follow SCN

https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=491918545 3/3

Вам также может понравиться