*&---------------------------------------------------------------------*
*& Include ZHR_ON_BORADING_PROCESS_TOP
*&---------------------------------------------------------------------*
TYPES: BEGIN OF gty_input,
****infotype 0000 & 0001
pernr type string,
begda TYPE string,
endda TYPE string,
* massn TYPE string,
massg TYPE string,
plans TYPE string,
org_unit type string,
org_level1 type string,
org_level2 type string,
org_level3 type string,
org_level4 type string,
werks TYPE string,
persg TYPE string,
persk TYPE string,
btrtl TYPE string,
abkrs TYPE string,
vdsk1 TYPE string,
zposfx type string,
rrf1 type string,
candid type string,
****infotype 0002
anrex TYPE string, " title
nachn TYPE string, "last name
vorna TYPE string,
gesch TYPE string, " Gender
gbdat TYPE string, " data brith
natio TYPE string,
****infotype 0007
schkz TYPE string,
zterf TYPE string,
****infotype 0008
trfgr TYPE string,
trfst TYPE string,
ansal TYPE string,
****infotype 0050
****infotype 0016
cttyp TYPE string,
prbzt TYPE string,
prbeh TYPE string,
kdgfr TYPE string,
kdgf2 TYPE string,
****infotype 0017
spebe TYPE string,
pkwrg TYPE string,
kzpmf TYPE string,
pkwkl TYPE string,
****infotype 0027 Subtype 01
bukrs TYPE string,
kostl TYPE string,
prozt TYPE string,
****infotype 0027 Subtype 02
bukrs1 TYPE string,
kostl1 TYPE string,
prozt1 TYPE string,
****infotype 0315
kostl2 TYPE string,
lstar TYPE string,
werks2 TYPE string,
accnt TYPE string,
****infotype 0587
tstid TYPE string,
penid TYPE string,
eepfm TYPE string,
eepnm TYPE string,
evpfa TYPE string,
pnflg TYPE string,
erpn1 TYPE string,
erpn2 TYPE string,
****infotype 0588
ticnm1 TYPE string,
esinm1 TYPE string,
esidp1 TYPE string,
lwfck TYPE string,
ptxel TYPE string,
****infotype 0591
nname TYPE string,
nmadd TYPE string,
reltn TYPE string,
datob TYPE string,
shprc TYPE string,
nname1 TYPE string,
nmadd1 TYPE string,
reltn1 TYPE string,
datob1 TYPE string,
shprc1 TYPE string,
nname2 TYPE string,
nmadd2 TYPE string,
reltn2 TYPE string,
datob2 TYPE string,
shprc2 TYPE string,
nname3 TYPE string,
nmadd3 TYPE string,
reltn3 TYPE string,
datob3 TYPE string,
shprc3 TYPE string,
****infotype 0804
heght TYPE string,
weght TYPE string,
bgrup TYPE string,
****infotype 9013
source TYPE string,
agrmnt TYPE string,
rrf TYPE string,
bl_typ TYPE string,
emp_roll TYPE string,
emp_con TYPE string,
emp_num TYPE string,
dep_ins TYPE string,
board_usr TYPE string,
****infotype 9015
language TYPE string,
zread TYPE string,
zwrite TYPE string,
zspeak TYPE string,
END OF gty_input.
DATA : gs_input TYPE gty_input.
DATA : gt_input TYPE STANDARD TABLE OF gty_input,
gt_raw TYPE truxs_t_text_data.
DATA : gv_pernr TYPE pernr_d,
gv_row TYPE i,
gv_row_str TYPE string.
*{ INSERT CHDK900354 1
DATA : gv_position TYPE HROBJID.
*} INSERT
"BDC
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: l_mstring(480).
*&---------------------------------------------------------------------*
*& Include ZHR_ON_BORADING_PROCESS_SEL
*&---------------------------------------------------------------------*
PARAMETERS : p_file TYPE rlgrap-filename.
PARAMETERS : R1 RADIOBUTTON GROUP G1,
R2 RADIOBUTTON GROUP G1.
*PARAMETERs : mode type ctuparams
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
PERFORM get_excel.
PERFORM bdc_creation.
FORM get_excel.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = gt_raw
i_filename = p_file
TABLES
i_tab_converted_data = gt_input
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
ENDFORM.
FORM bdc_creation.
IF gt_input IS NOT INITIAL.
LOOP AT gt_input INTO gs_input.
gv_row = gv_row + 1.
CLEAR gv_pernr.
SET PARAMETER ID 'PER' FIELD gv_pernr.
PERFORM bdc_dynpro USING 'SAPMP50A' '2200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
*perform bdc_field using 'BDC_CURSOR'
* 'RP50G-PERNR'.
PERFORM bdc_field USING 'RP50G-PERNR'
space.
PERFORM bdc_dynpro USING 'SAPMP50A' '2200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-EINDA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PICK'.
PERFORM bdc_field USING 'RP50G-EINDA'
gs_input-begda.
PERFORM bdc_field USING 'RP50G-SELEC(02)'
'X'."record-SELEC_11_003'.
****Infotype 0000
PERFORM bdc_dynpro USING 'MP000000' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'PSPAR-PERSK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
* PERFORM bdc_field USING 'P0000-PERNR'
* space.
PERFORM bdc_field USING 'P0000-BEGDA'
gs_input-begda.
PERFORM bdc_field USING 'P0000-ENDDA'
gs_input-endda.
PERFORM bdc_field USING 'P0000-MASSG'
gs_input-massg.
PERFORM bdc_field USING 'PSPAR-PLANS'
gs_input-plans.
PERFORM bdc_field USING 'PSPAR-WERKS'
gs_input-werks.
PERFORM bdc_field USING 'PSPAR-PERSG'
gs_input-persg.
PERFORM bdc_field USING 'PSPAR-PERSK'
gs_input-persk.
*{ INSERT CHDK900107 1
* PERFORM bdc_dynpro USING 'MP000000' '2000'.
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=UPD'.
*} INSERT
****Infotype 0001
PERFORM bdc_dynpro USING 'MP000100' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0001-BTRTL'
gs_input-btrtl.
PERFORM bdc_field USING 'P0001-ABKRS'
gs_input-abkrs.
PERFORM bdc_field USING 'P0001-PLANS'
gs_input-plans.
PERFORM bdc_field USING 'P0001-VDSK1'
gs_input-vdsk1.
****Infotype 0002
PERFORM bdc_dynpro USING 'MP000200' '2040'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'Q0002-ANREX'
gs_input-anrex.
PERFORM bdc_field USING 'P0002-NACHN'
gs_input-nachn.
PERFORM bdc_field USING 'P0002-VORNA'
gs_input-vorna.
PERFORM bdc_field USING 'P0002-GESCH'
gs_input-gesch.
*perform bdc_field using 'P0002-SPRSL'
* record-SPRSL_024.
PERFORM bdc_field USING 'P0002-GBDAT'
gs_input-gbdat.
PERFORM bdc_field USING 'P0002-NATIO'
gs_input-natio.
****Infotype 0007
PERFORM bdc_dynpro USING 'MP000700' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P0007-BEGDA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'UPD'.
IF gs_input-schkz IS NOT INITIAL.
PERFORM bdc_field USING 'P0007-SCHKZ'
gs_input-schkz.
ENDIF.
IF gs_input-zterf IS NOT INITIAL.
PERFORM bdc_field USING 'P0007-ZTERF'
gs_input-zterf.
ENDIF.
*perform bdc_field using 'P0007-EMPCT'
* gs_input-EMPCT.
****Infotype 0008
PERFORM bdc_dynpro USING 'MP000800' '2040'.
IF gs_input-trfgr IS NOT INITIAL OR gs_input-trfst IS NOT INITIAL
OR gs_input-ansal IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
*perform bdc_field using 'P0008-TRFAR'
* record-TRFAR_034.
*perform bdc_field using 'P0008-BSGRD'
* record-BSGRD_035.
*perform bdc_field using 'P0008-TRFGB'
* record-TRFGB_036.
*perform bdc_field using 'P0008-DIVGV'
* record-DIVGV_037.
PERFORM bdc_field USING 'P0008-TRFGR'
gs_input-trfgr.
PERFORM bdc_field USING 'P0008-TRFST'
gs_input-trfst.
PERFORM bdc_field USING 'P0008-ANSAL'
gs_input-ansal.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
*perform bdc_field using 'P0008-ANCUR'
* record-ANCUR_041.
*perform bdc_field using 'Q0008-IBBEG'
* record-IBBEG_042.
*perform bdc_field using 'P0008-WAERS'
* record-WAERS_043.
****Infotype 0016
PERFORM bdc_dynpro USING 'MP001600' '2040'.
IF gs_input-cttyp IS NOT INITIAL OR gs_input-prbzt IS NOT INITIAL
OR gs_input-prbeh IS NOT INITIAL OR gs_input-kdgfr IS NOT INITIAL
OR gs_input-kdgf2 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0016-CTTYP'
gs_input-cttyp.
PERFORM bdc_field USING 'P0016-PRBZT'
gs_input-prbzt.
PERFORM bdc_field USING 'Q0016-PRBEH'
gs_input-prbeh.
PERFORM bdc_field USING 'P0016-KDGFR'
gs_input-kdgfr.
PERFORM bdc_field USING 'P0016-KDGF2'
gs_input-kdgf2.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0017
PERFORM bdc_dynpro USING 'MP001700' '2000'.
IF gs_input-spebe IS NOT INITIAL OR gs_input-pkwrg IS NOT INITIAL
OR gs_input-kzpmf IS NOT INITIAL OR gs_input-pkwkl IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0017-SPEBE'
gs_input-spebe.
PERFORM bdc_field USING 'P0017-PKWRG'
gs_input-pkwrg.
PERFORM bdc_field USING 'P0017-KZPMF'
gs_input-kzpmf.
PERFORM bdc_field USING 'P0017-PKWKL'
gs_input-pkwkl.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0027 subtype 01
PERFORM bdc_dynpro USING 'MP002700' '2500'.
IF gs_input-bukrs IS NOT INITIAL OR gs_input-kostl IS NOT INITIAL
OR gs_input-prozt IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'UPD'.
PERFORM bdc_field USING 'P0027-KSTAR'
'01'.
* PERFORM bdc_field USING 'BDC_CURSOR'
* 'RHCD_TAB-PROZT(01)'.
PERFORM bdc_field USING 'RHCD_TAB-BUKRS(01)'
gs_input-bukrs.
PERFORM bdc_field USING 'RHCD_TAB-KOSTL(01)'
gs_input-kostl.
PERFORM bdc_field USING 'RHCD_TAB-PROZT(01)'
gs_input-prozt.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0027 subtype 02
PERFORM bdc_dynpro USING 'MP002700' '2500'.
IF gs_input-bukrs IS NOT INITIAL OR gs_input-kostl IS NOT INITIAL
OR gs_input-prozt IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0027-KSTAR'
'02'.
PERFORM bdc_field USING 'RHCD_TAB-BUKRS(01)'
gs_input-bukrs1.
PERFORM bdc_field USING 'RHCD_TAB-KOSTL(01)'
gs_input-kostl1.
PERFORM bdc_field USING 'RHCD_TAB-PROZT(01)'
gs_input-prozt1.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0315
PERFORM bdc_dynpro USING 'MP031500' '2000'.
IF gs_input-kostl2 IS NOT INITIAL OR gs_input-lstar IS NOT INITIAL
OR gs_input-werks2 IS NOT INITIAL OR gs_input-accnt IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0315-KOSTL'
gs_input-kostl2.
PERFORM bdc_field USING 'P0315-LSTAR'
gs_input-lstar.
PERFORM bdc_field USING 'P0315-WERKS'
gs_input-werks2.
PERFORM bdc_field USING 'P0315-ACCNT'
gs_input-accnt.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0587
PERFORM bdc_dynpro USING 'MP058700' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0587-TSTID'
gs_input-tstid.
PERFORM bdc_field USING 'P0587-PENID'
gs_input-penid.
PERFORM bdc_field USING 'P0587-EEPFM'
gs_input-eepfm.
PERFORM bdc_field USING 'P0587-EEPNM'
gs_input-eepnm.
*perform bdc_field using 'Q0587-EEPF2'
* record-EEPF2_081.
PERFORM bdc_field USING 'P0587-EVPFA'
gs_input-evpfa.
*perform bdc_field using 'Q0587-ERPF1'
* record-ERPF1_083.
*perform bdc_field using 'Q0587-ERPF2'
* record-ERPF2_084.
PERFORM bdc_field USING 'P0587-PNFLG'
gs_input-pnflg.
PERFORM bdc_field USING 'Q0587-ERPN1'
gs_input-erpn1.
PERFORM bdc_field USING 'Q0587-ERPN2'
gs_input-erpn2.
****Infotype 0588 subtype 0001
PERFORM bdc_dynpro USING 'MP058800' '2000'.
IF gs_input-ticnm1 IS NOT INITIAL OR gs_input-esinm1 IS NOT INITIAL
OR gs_input-esidp1 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0588-TICNM'
gs_input-ticnm1.
PERFORM bdc_field USING 'P0588-ESINM'
gs_input-esinm1.
PERFORM bdc_field USING 'P0588-ESIDP'
gs_input-esidp1.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0588 subtype 0002
PERFORM bdc_dynpro USING 'MP058800' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'Q0588-LWFCK'
gs_input-lwfck.
****Infotype 0588 subtype 0003
PERFORM bdc_dynpro USING 'MP058800' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'Q0588-PTXEL'
gs_input-ptxel.
****Infotype 0591 subtype BNES
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname IS NOT INITIAL OR gs_input-nmadd IS NOT INITIAL
OR gs_input-reltn IS NOT INITIAL OR gs_input-datob IS NOT INITIAL
OR gs_input-shprc IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0591 subtype BNGR
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname1 IS NOT INITIAL OR gs_input-nmadd1 IS NOT INITIAL
OR gs_input-reltn1 IS NOT INITIAL OR gs_input-datob1 IS NOT INITIAL
OR gs_input-shprc1 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname1.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd1.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn1.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob1.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc1.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0591 subtype BNPF
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname2 IS NOT INITIAL OR gs_input-nmadd2 IS NOT INITIAL
OR gs_input-reltn2 IS NOT INITIAL OR gs_input-datob2 IS NOT INITIAL
OR gs_input-shprc2 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname2.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd2.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn2.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob2.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc2.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0591 subtype BNPN
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname3 IS NOT INITIAL OR gs_input-nmadd3 IS NOT INITIAL
OR gs_input-reltn3 IS NOT INITIAL OR gs_input-datob3 IS NOT INITIAL
OR gs_input-shprc3 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname3.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd3.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn3.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob3.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc3.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0804
PERFORM bdc_dynpro USING 'MP080400' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0804-HEGHT'
gs_input-heght.
PERFORM bdc_field USING 'P0804-WEGHT'
gs_input-weght.
PERFORM bdc_field USING 'P0804-BGRUP'
gs_input-bgrup.
****Infotype 9013
PERFORM bdc_dynpro USING 'MP901300' '2000'.
IF gs_input-source IS NOT INITIAL OR gs_input-agrmnt IS NOT INITIAL
OR gs_input-rrf IS NOT INITIAL OR gs_input-bl_typ IS NOT INITIAL
OR gs_input-emp_roll IS NOT INITIAL OR gs_input-emp_con IS NOT INITIAL
OR gs_input-emp_num IS NOT INITIAL OR gs_input-dep_ins IS NOT INITIAL
OR gs_input-board_usr IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P9013-SOURCE'
gs_input-source.
PERFORM bdc_field USING 'P9013-AGRMNT'
gs_input-agrmnt.
PERFORM bdc_field USING 'P9013-RRF'
gs_input-rrf.
PERFORM bdc_field USING 'P9013-BL_TYP'
gs_input-bl_typ.
PERFORM bdc_field USING 'P9013-EMP_ROLL'
gs_input-emp_roll.
PERFORM bdc_field USING 'P9013-EMP_CON'
gs_input-emp_con.
PERFORM bdc_field USING 'P9013-EMP_NUM'
gs_input-emp_num.
PERFORM bdc_field USING 'P9013-DEP_INS'
gs_input-dep_ins.
PERFORM bdc_field USING 'P9013-BOARD_USR'
gs_input-board_usr.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 9015
PERFORM bdc_dynpro USING 'MP901500' '2000'.
IF gs_input-language IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P9015-LANGUAGE'
gs_input-language.
PERFORM bdc_field USING 'P9015-ZREAD'
gs_input-zread.
PERFORM bdc_field USING 'P9015-ZWRITE'
gs_input-zwrite.
PERFORM bdc_field USING 'P9015-ZSPEAK'
gs_input-zspeak.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
PERFORM bdc_dynpro USING 'SAPMP50A' '2200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/EBCK'.
PERFORM bdc_transaction USING 'PA40'.
CLEAR gs_input.
ENDLOOP.
ELSE.
MESSAGE 'No record in excel' TYPE 'I'.
ENDIF.
ENDFORM.
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM.
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.
FORM bdc_transaction USING tcode.
DATA : ls_ctu TYPE ctu_params.
*{ INSERT CHDK900245 4
DATA : lv_pernr TYPE persno,
lv_begda TYPE begda.
*} INSERT
ls_ctu-dismode = 'N'.
ls_ctu-updmode = 'S'.
ls_ctu-defsize = 'X'.
CLEAR : messtab[].
SET PARAMETER ID '/ISDFPS/UNIT_LENGTH' FIELD 'CM'.
SET PARAMETER ID '/ISDFPS/UNIT_MASS' FIELD 'KG'.
CALL TRANSACTION tcode USING bdcdata
OPTIONS FROM ls_ctu
MESSAGES INTO messtab.
COMMIT WORK.
*{ INSERT CHDK900101 2
GET PARAMETER ID 'PER' FIELD gv_pernr.
gv_row_str = gv_row.
IF gv_row = 1.
WRITE: / sy-vline,2 'Row ID', 10 sy-vline,12 'Error',19 sy-vline,21 'Employee Id' ,32 sy-vline,34 'Message'.
ULINE.
ENDIF.
*} INSERT
IF messtab[] IS NOT INITIAL.
*{ DELETE CHDK900101 1
*\ GET PARAMETER ID 'PER' FIELD gv_pernr.
*} DELETE
*{ DELETE CHDK900245 5
*\ IF gv_row = 1.
*\ WRITE: / sy-vline,2 'Row ID', 10 sy-vline,12 'Error',19 sy-vline,21 'Employee Id' ,32 sy-vline,34 'Message'.
*\ ULINE.
*\ ENDIF.
*} DELETE
*{ DELETE CHDK900245 6
*\ gv_row_str = gv_row.
*} DELETE
LOOP AT messtab.
MESSAGE ID messtab-msgid
TYPE messtab-msgtyp
NUMBER messtab-msgnr
INTO l_mstring
WITH messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 messtab-msgtyp,19 sy-vline,21 gv_pernr ,32 sy-vline,34 l_mstring.
ENDLOOP.
*{ REPLACE CHDK900245 3
*\ ELSE.
*\ WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 gv_pernr ,32 sy-vline,34 'Employee created Success'.
*\ ENDIF.
*\ IF messtab[] IS NOT INITIAL.
*\ READ TABLE messtab[] TRANSPORTING NO FIELDS WITH KEY msgtyp = 'E'.
*\ IF sy-subrc NE 0.
*\ WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 gv_pernr ,32 sy-vline,34 'Employee created Success'.
*\ ENDIF.
*\ ENDIF.
*\ CLEAR: bdcdata, bdcdata[].
ENDIF.
CLEAR lv_pernr.
SELECT SINGLE pernr begda INTO (lv_pernr,lv_begda) FROM pa0000 WHERE pernr = gv_pernr.
IF sy-subrc = 0.
CLEAR gv_position.
PERFORM create_0041 USING lv_pernr lv_begda.
gv_position = gs_input-plans.
IF lv_pernr IS NOT INITIAL AND gv_position IS NOT INITIAL AND gv_position NE '99999999'.
PERFORM create_1001 USING gv_position lv_pernr lv_begda.
ENDIF.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 gv_pernr ,32 sy-vline,34 'Employee created Success'.
ELSE.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'E',19 sy-vline,21 lv_pernr ,32 sy-vline,34 'Employee IS Not created'.
ENDIF.
CLEAR: bdcdata, bdcdata[].
*} REPLACE
ENDFORM.
*{ INSERT CHDK900245 1
FORM create_0041 USING lv_pernr TYPE persno
lv_begda TYPE begda.
DATA : lv_msg TYPE string,
ls_return TYPE bapireturn1,
ls_0041 TYPE p0041.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = lv_pernr
IMPORTING
return = ls_return.
IF ls_return-type NE 'E'.
CLEAR ls_return.
ls_0041-pernr = lv_pernr.
ls_0041-begda = lv_begda.
ls_0041-endda = '99991231'.
ls_0041-dar01 = 'Z1'.
ls_0041-dat01 = lv_begda.
ls_0041-dar02 = 'Z6'.
ls_0041-dat02 = lv_begda.
ls_0041-dar03 = 'Z9'.
ls_0041-dat03 = lv_begda.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0041'
number = lv_pernr
* subtype = subty
validityend = '99991231'
validitybegin = lv_begda
record = ls_0041
operation = 'INS'
IMPORTING
return = ls_return.
IF ls_return-type = 'E'.
CLEAR lv_msg.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = ls_return-id
lang = 'EN'
no = ls_return-number
v1 = ls_return-message_v1
v2 = ls_return-message_v2
v3 = ls_return-message_v3
v4 = ls_return-message_v4
IMPORTING
msg = lv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'W',19 sy-vline,21 gv_pernr ,32 sy-vline,
34 'Info 0041 is not created because', lv_msg.
ENDIF.
COMMIT WORK.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = lv_pernr
IMPORTING
return = ls_return.
ENDIF.
CLEAR: ls_return.
ENDFORM.
FORM create_1001 USING lv_position TYPE OBJEKTID
lv_pernr TYPE persno
lv_begda TYPE begda.
DATA : ls_1001 TYPE p1001.
CLEAR ls_1001.
ls_1001-OTYPE = 'S'.
ls_1001-OBJID = lv_position.
ls_1001-PLVAR = '01'.
ls_1001-RSIGN = 'A'.
ls_1001-RELAT = '008'.
ls_1001-ISTAT = '1'.
ls_1001-BEGDA = lv_begda.
ls_1001-ENDDA = '99993112'.
ls_1001-INFTY = '1001'.
ls_1001-SCLAS = 'P'.
ls_1001-SOBID = lv_pernr.
ls_1001-PROZT = 100.
CALL FUNCTION 'RH_PM_ENQUEUE'
EXPORTING
act_plvar = '01'
act_otype = 'S'
act_objid = lv_position
EXCEPTIONS
ERROR_IN_ENQUEUE = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'RH_PNNNN_MAINTAIN'
EXPORTING
act_fcode = 'INSE'
ACT_PLVAR = '01'
act_otype = 'S'
act_objid = lv_position
ACT_INFTY = '1001'
ACT_SUBTY = 'A008'
ACT_ISTAT = '1'
ACT_BEGDA = lv_begda
ACT_ENDDA = '99991231'
ACT_PNNNN = ls_1001
ACT_VTASK = 'S'
ACT_COMMIT_FLG = 'X'
SUPPRESS_DIALOG = 2
EXCEPTIONS
INFTY_NOT_VALID = 1
NO_PLVAR = 2
OBJECT_NOT_DEFINED = 3
OTYPE_NOT_VALID = 4
NO_AUTHORITY = 5
ACTION_REJECTED = 6
NO_GDATE = 7
FCODE_NOT_SUPPORTED = 8
OTHERS = 9.
IF sy-subrc NE 0.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'W',19 sy-vline,21 gv_pernr ,32 sy-vline,
34 'Info 1001 - Position to Employess relationship is not created'.
ENDIF.
CALL FUNCTION 'RH_PM_DEQUEUE'
EXPORTING
act_plvar = '01'
act_otype = 'S'
act_objid = lv_position.
ELSE.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'W',19 sy-vline,21 lv_position ,32 sy-vline,
34 'Position is locked, So 1001 - Position to Employess relationship is not created'.
ENDIF.
ENDFORM.
*} INSERT
*& Include ZHR_ON_BORADING_PROCESS_TOP
*&---------------------------------------------------------------------*
TYPES: BEGIN OF gty_input,
****infotype 0000 & 0001
pernr type string,
begda TYPE string,
endda TYPE string,
* massn TYPE string,
massg TYPE string,
plans TYPE string,
org_unit type string,
org_level1 type string,
org_level2 type string,
org_level3 type string,
org_level4 type string,
werks TYPE string,
persg TYPE string,
persk TYPE string,
btrtl TYPE string,
abkrs TYPE string,
vdsk1 TYPE string,
zposfx type string,
rrf1 type string,
candid type string,
****infotype 0002
anrex TYPE string, " title
nachn TYPE string, "last name
vorna TYPE string,
gesch TYPE string, " Gender
gbdat TYPE string, " data brith
natio TYPE string,
****infotype 0007
schkz TYPE string,
zterf TYPE string,
****infotype 0008
trfgr TYPE string,
trfst TYPE string,
ansal TYPE string,
****infotype 0050
****infotype 0016
cttyp TYPE string,
prbzt TYPE string,
prbeh TYPE string,
kdgfr TYPE string,
kdgf2 TYPE string,
****infotype 0017
spebe TYPE string,
pkwrg TYPE string,
kzpmf TYPE string,
pkwkl TYPE string,
****infotype 0027 Subtype 01
bukrs TYPE string,
kostl TYPE string,
prozt TYPE string,
****infotype 0027 Subtype 02
bukrs1 TYPE string,
kostl1 TYPE string,
prozt1 TYPE string,
****infotype 0315
kostl2 TYPE string,
lstar TYPE string,
werks2 TYPE string,
accnt TYPE string,
****infotype 0587
tstid TYPE string,
penid TYPE string,
eepfm TYPE string,
eepnm TYPE string,
evpfa TYPE string,
pnflg TYPE string,
erpn1 TYPE string,
erpn2 TYPE string,
****infotype 0588
ticnm1 TYPE string,
esinm1 TYPE string,
esidp1 TYPE string,
lwfck TYPE string,
ptxel TYPE string,
****infotype 0591
nname TYPE string,
nmadd TYPE string,
reltn TYPE string,
datob TYPE string,
shprc TYPE string,
nname1 TYPE string,
nmadd1 TYPE string,
reltn1 TYPE string,
datob1 TYPE string,
shprc1 TYPE string,
nname2 TYPE string,
nmadd2 TYPE string,
reltn2 TYPE string,
datob2 TYPE string,
shprc2 TYPE string,
nname3 TYPE string,
nmadd3 TYPE string,
reltn3 TYPE string,
datob3 TYPE string,
shprc3 TYPE string,
****infotype 0804
heght TYPE string,
weght TYPE string,
bgrup TYPE string,
****infotype 9013
source TYPE string,
agrmnt TYPE string,
rrf TYPE string,
bl_typ TYPE string,
emp_roll TYPE string,
emp_con TYPE string,
emp_num TYPE string,
dep_ins TYPE string,
board_usr TYPE string,
****infotype 9015
language TYPE string,
zread TYPE string,
zwrite TYPE string,
zspeak TYPE string,
END OF gty_input.
DATA : gs_input TYPE gty_input.
DATA : gt_input TYPE STANDARD TABLE OF gty_input,
gt_raw TYPE truxs_t_text_data.
DATA : gv_pernr TYPE pernr_d,
gv_row TYPE i,
gv_row_str TYPE string.
*{ INSERT CHDK900354 1
DATA : gv_position TYPE HROBJID.
*} INSERT
"BDC
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: l_mstring(480).
*&---------------------------------------------------------------------*
*& Include ZHR_ON_BORADING_PROCESS_SEL
*&---------------------------------------------------------------------*
PARAMETERS : p_file TYPE rlgrap-filename.
PARAMETERS : R1 RADIOBUTTON GROUP G1,
R2 RADIOBUTTON GROUP G1.
*PARAMETERs : mode type ctuparams
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
PERFORM get_excel.
PERFORM bdc_creation.
FORM get_excel.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = gt_raw
i_filename = p_file
TABLES
i_tab_converted_data = gt_input
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
ENDFORM.
FORM bdc_creation.
IF gt_input IS NOT INITIAL.
LOOP AT gt_input INTO gs_input.
gv_row = gv_row + 1.
CLEAR gv_pernr.
SET PARAMETER ID 'PER' FIELD gv_pernr.
PERFORM bdc_dynpro USING 'SAPMP50A' '2200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
*perform bdc_field using 'BDC_CURSOR'
* 'RP50G-PERNR'.
PERFORM bdc_field USING 'RP50G-PERNR'
space.
PERFORM bdc_dynpro USING 'SAPMP50A' '2200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-EINDA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PICK'.
PERFORM bdc_field USING 'RP50G-EINDA'
gs_input-begda.
PERFORM bdc_field USING 'RP50G-SELEC(02)'
'X'."record-SELEC_11_003'.
****Infotype 0000
PERFORM bdc_dynpro USING 'MP000000' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'PSPAR-PERSK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
* PERFORM bdc_field USING 'P0000-PERNR'
* space.
PERFORM bdc_field USING 'P0000-BEGDA'
gs_input-begda.
PERFORM bdc_field USING 'P0000-ENDDA'
gs_input-endda.
PERFORM bdc_field USING 'P0000-MASSG'
gs_input-massg.
PERFORM bdc_field USING 'PSPAR-PLANS'
gs_input-plans.
PERFORM bdc_field USING 'PSPAR-WERKS'
gs_input-werks.
PERFORM bdc_field USING 'PSPAR-PERSG'
gs_input-persg.
PERFORM bdc_field USING 'PSPAR-PERSK'
gs_input-persk.
*{ INSERT CHDK900107 1
* PERFORM bdc_dynpro USING 'MP000000' '2000'.
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=UPD'.
*} INSERT
****Infotype 0001
PERFORM bdc_dynpro USING 'MP000100' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0001-BTRTL'
gs_input-btrtl.
PERFORM bdc_field USING 'P0001-ABKRS'
gs_input-abkrs.
PERFORM bdc_field USING 'P0001-PLANS'
gs_input-plans.
PERFORM bdc_field USING 'P0001-VDSK1'
gs_input-vdsk1.
****Infotype 0002
PERFORM bdc_dynpro USING 'MP000200' '2040'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'Q0002-ANREX'
gs_input-anrex.
PERFORM bdc_field USING 'P0002-NACHN'
gs_input-nachn.
PERFORM bdc_field USING 'P0002-VORNA'
gs_input-vorna.
PERFORM bdc_field USING 'P0002-GESCH'
gs_input-gesch.
*perform bdc_field using 'P0002-SPRSL'
* record-SPRSL_024.
PERFORM bdc_field USING 'P0002-GBDAT'
gs_input-gbdat.
PERFORM bdc_field USING 'P0002-NATIO'
gs_input-natio.
****Infotype 0007
PERFORM bdc_dynpro USING 'MP000700' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P0007-BEGDA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'UPD'.
IF gs_input-schkz IS NOT INITIAL.
PERFORM bdc_field USING 'P0007-SCHKZ'
gs_input-schkz.
ENDIF.
IF gs_input-zterf IS NOT INITIAL.
PERFORM bdc_field USING 'P0007-ZTERF'
gs_input-zterf.
ENDIF.
*perform bdc_field using 'P0007-EMPCT'
* gs_input-EMPCT.
****Infotype 0008
PERFORM bdc_dynpro USING 'MP000800' '2040'.
IF gs_input-trfgr IS NOT INITIAL OR gs_input-trfst IS NOT INITIAL
OR gs_input-ansal IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
*perform bdc_field using 'P0008-TRFAR'
* record-TRFAR_034.
*perform bdc_field using 'P0008-BSGRD'
* record-BSGRD_035.
*perform bdc_field using 'P0008-TRFGB'
* record-TRFGB_036.
*perform bdc_field using 'P0008-DIVGV'
* record-DIVGV_037.
PERFORM bdc_field USING 'P0008-TRFGR'
gs_input-trfgr.
PERFORM bdc_field USING 'P0008-TRFST'
gs_input-trfst.
PERFORM bdc_field USING 'P0008-ANSAL'
gs_input-ansal.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
*perform bdc_field using 'P0008-ANCUR'
* record-ANCUR_041.
*perform bdc_field using 'Q0008-IBBEG'
* record-IBBEG_042.
*perform bdc_field using 'P0008-WAERS'
* record-WAERS_043.
****Infotype 0016
PERFORM bdc_dynpro USING 'MP001600' '2040'.
IF gs_input-cttyp IS NOT INITIAL OR gs_input-prbzt IS NOT INITIAL
OR gs_input-prbeh IS NOT INITIAL OR gs_input-kdgfr IS NOT INITIAL
OR gs_input-kdgf2 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0016-CTTYP'
gs_input-cttyp.
PERFORM bdc_field USING 'P0016-PRBZT'
gs_input-prbzt.
PERFORM bdc_field USING 'Q0016-PRBEH'
gs_input-prbeh.
PERFORM bdc_field USING 'P0016-KDGFR'
gs_input-kdgfr.
PERFORM bdc_field USING 'P0016-KDGF2'
gs_input-kdgf2.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0017
PERFORM bdc_dynpro USING 'MP001700' '2000'.
IF gs_input-spebe IS NOT INITIAL OR gs_input-pkwrg IS NOT INITIAL
OR gs_input-kzpmf IS NOT INITIAL OR gs_input-pkwkl IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0017-SPEBE'
gs_input-spebe.
PERFORM bdc_field USING 'P0017-PKWRG'
gs_input-pkwrg.
PERFORM bdc_field USING 'P0017-KZPMF'
gs_input-kzpmf.
PERFORM bdc_field USING 'P0017-PKWKL'
gs_input-pkwkl.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0027 subtype 01
PERFORM bdc_dynpro USING 'MP002700' '2500'.
IF gs_input-bukrs IS NOT INITIAL OR gs_input-kostl IS NOT INITIAL
OR gs_input-prozt IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'UPD'.
PERFORM bdc_field USING 'P0027-KSTAR'
'01'.
* PERFORM bdc_field USING 'BDC_CURSOR'
* 'RHCD_TAB-PROZT(01)'.
PERFORM bdc_field USING 'RHCD_TAB-BUKRS(01)'
gs_input-bukrs.
PERFORM bdc_field USING 'RHCD_TAB-KOSTL(01)'
gs_input-kostl.
PERFORM bdc_field USING 'RHCD_TAB-PROZT(01)'
gs_input-prozt.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0027 subtype 02
PERFORM bdc_dynpro USING 'MP002700' '2500'.
IF gs_input-bukrs IS NOT INITIAL OR gs_input-kostl IS NOT INITIAL
OR gs_input-prozt IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0027-KSTAR'
'02'.
PERFORM bdc_field USING 'RHCD_TAB-BUKRS(01)'
gs_input-bukrs1.
PERFORM bdc_field USING 'RHCD_TAB-KOSTL(01)'
gs_input-kostl1.
PERFORM bdc_field USING 'RHCD_TAB-PROZT(01)'
gs_input-prozt1.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0315
PERFORM bdc_dynpro USING 'MP031500' '2000'.
IF gs_input-kostl2 IS NOT INITIAL OR gs_input-lstar IS NOT INITIAL
OR gs_input-werks2 IS NOT INITIAL OR gs_input-accnt IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0315-KOSTL'
gs_input-kostl2.
PERFORM bdc_field USING 'P0315-LSTAR'
gs_input-lstar.
PERFORM bdc_field USING 'P0315-WERKS'
gs_input-werks2.
PERFORM bdc_field USING 'P0315-ACCNT'
gs_input-accnt.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0587
PERFORM bdc_dynpro USING 'MP058700' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0587-TSTID'
gs_input-tstid.
PERFORM bdc_field USING 'P0587-PENID'
gs_input-penid.
PERFORM bdc_field USING 'P0587-EEPFM'
gs_input-eepfm.
PERFORM bdc_field USING 'P0587-EEPNM'
gs_input-eepnm.
*perform bdc_field using 'Q0587-EEPF2'
* record-EEPF2_081.
PERFORM bdc_field USING 'P0587-EVPFA'
gs_input-evpfa.
*perform bdc_field using 'Q0587-ERPF1'
* record-ERPF1_083.
*perform bdc_field using 'Q0587-ERPF2'
* record-ERPF2_084.
PERFORM bdc_field USING 'P0587-PNFLG'
gs_input-pnflg.
PERFORM bdc_field USING 'Q0587-ERPN1'
gs_input-erpn1.
PERFORM bdc_field USING 'Q0587-ERPN2'
gs_input-erpn2.
****Infotype 0588 subtype 0001
PERFORM bdc_dynpro USING 'MP058800' '2000'.
IF gs_input-ticnm1 IS NOT INITIAL OR gs_input-esinm1 IS NOT INITIAL
OR gs_input-esidp1 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0588-TICNM'
gs_input-ticnm1.
PERFORM bdc_field USING 'P0588-ESINM'
gs_input-esinm1.
PERFORM bdc_field USING 'P0588-ESIDP'
gs_input-esidp1.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0588 subtype 0002
PERFORM bdc_dynpro USING 'MP058800' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'Q0588-LWFCK'
gs_input-lwfck.
****Infotype 0588 subtype 0003
PERFORM bdc_dynpro USING 'MP058800' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'Q0588-PTXEL'
gs_input-ptxel.
****Infotype 0591 subtype BNES
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname IS NOT INITIAL OR gs_input-nmadd IS NOT INITIAL
OR gs_input-reltn IS NOT INITIAL OR gs_input-datob IS NOT INITIAL
OR gs_input-shprc IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0591 subtype BNGR
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname1 IS NOT INITIAL OR gs_input-nmadd1 IS NOT INITIAL
OR gs_input-reltn1 IS NOT INITIAL OR gs_input-datob1 IS NOT INITIAL
OR gs_input-shprc1 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname1.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd1.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn1.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob1.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc1.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0591 subtype BNPF
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname2 IS NOT INITIAL OR gs_input-nmadd2 IS NOT INITIAL
OR gs_input-reltn2 IS NOT INITIAL OR gs_input-datob2 IS NOT INITIAL
OR gs_input-shprc2 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname2.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd2.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn2.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob2.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc2.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0591 subtype BNPN
PERFORM bdc_dynpro USING 'MP059100' '2000'.
IF gs_input-nname3 IS NOT INITIAL OR gs_input-nmadd3 IS NOT INITIAL
OR gs_input-reltn3 IS NOT INITIAL OR gs_input-datob3 IS NOT INITIAL
OR gs_input-shprc3 IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_CURSOR'
'ITAB_NOM-GRADD(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'ITAB_NOM-NNAME(01)'
gs_input-nname3.
PERFORM bdc_field USING 'ITAB_NOM-NMADD(01)'
gs_input-nmadd3.
PERFORM bdc_field USING 'ITAB_NOM-RELTN(01)'
gs_input-reltn3.
PERFORM bdc_field USING 'ITAB_NOM-DATOB(01)'
gs_input-datob3.
PERFORM bdc_field USING 'ITAB_NOM-SHPRC(01)'
gs_input-shprc3.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 0804
PERFORM bdc_dynpro USING 'MP080400' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0804-HEGHT'
gs_input-heght.
PERFORM bdc_field USING 'P0804-WEGHT'
gs_input-weght.
PERFORM bdc_field USING 'P0804-BGRUP'
gs_input-bgrup.
****Infotype 9013
PERFORM bdc_dynpro USING 'MP901300' '2000'.
IF gs_input-source IS NOT INITIAL OR gs_input-agrmnt IS NOT INITIAL
OR gs_input-rrf IS NOT INITIAL OR gs_input-bl_typ IS NOT INITIAL
OR gs_input-emp_roll IS NOT INITIAL OR gs_input-emp_con IS NOT INITIAL
OR gs_input-emp_num IS NOT INITIAL OR gs_input-dep_ins IS NOT INITIAL
OR gs_input-board_usr IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P9013-SOURCE'
gs_input-source.
PERFORM bdc_field USING 'P9013-AGRMNT'
gs_input-agrmnt.
PERFORM bdc_field USING 'P9013-RRF'
gs_input-rrf.
PERFORM bdc_field USING 'P9013-BL_TYP'
gs_input-bl_typ.
PERFORM bdc_field USING 'P9013-EMP_ROLL'
gs_input-emp_roll.
PERFORM bdc_field USING 'P9013-EMP_CON'
gs_input-emp_con.
PERFORM bdc_field USING 'P9013-EMP_NUM'
gs_input-emp_num.
PERFORM bdc_field USING 'P9013-DEP_INS'
gs_input-dep_ins.
PERFORM bdc_field USING 'P9013-BOARD_USR'
gs_input-board_usr.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
****Infotype 9015
PERFORM bdc_dynpro USING 'MP901500' '2000'.
IF gs_input-language IS NOT INITIAL.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P9015-LANGUAGE'
gs_input-language.
PERFORM bdc_field USING 'P9015-ZREAD'
gs_input-zread.
PERFORM bdc_field USING 'P9015-ZWRITE'
gs_input-zwrite.
PERFORM bdc_field USING 'P9015-ZSPEAK'
gs_input-zspeak.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE'
'/E'.
ENDIF.
PERFORM bdc_dynpro USING 'SAPMP50A' '2200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/EBCK'.
PERFORM bdc_transaction USING 'PA40'.
CLEAR gs_input.
ENDLOOP.
ELSE.
MESSAGE 'No record in excel' TYPE 'I'.
ENDIF.
ENDFORM.
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM.
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.
FORM bdc_transaction USING tcode.
DATA : ls_ctu TYPE ctu_params.
*{ INSERT CHDK900245 4
DATA : lv_pernr TYPE persno,
lv_begda TYPE begda.
*} INSERT
ls_ctu-dismode = 'N'.
ls_ctu-updmode = 'S'.
ls_ctu-defsize = 'X'.
CLEAR : messtab[].
SET PARAMETER ID '/ISDFPS/UNIT_LENGTH' FIELD 'CM'.
SET PARAMETER ID '/ISDFPS/UNIT_MASS' FIELD 'KG'.
CALL TRANSACTION tcode USING bdcdata
OPTIONS FROM ls_ctu
MESSAGES INTO messtab.
COMMIT WORK.
*{ INSERT CHDK900101 2
GET PARAMETER ID 'PER' FIELD gv_pernr.
gv_row_str = gv_row.
IF gv_row = 1.
WRITE: / sy-vline,2 'Row ID', 10 sy-vline,12 'Error',19 sy-vline,21 'Employee Id' ,32 sy-vline,34 'Message'.
ULINE.
ENDIF.
*} INSERT
IF messtab[] IS NOT INITIAL.
*{ DELETE CHDK900101 1
*\ GET PARAMETER ID 'PER' FIELD gv_pernr.
*} DELETE
*{ DELETE CHDK900245 5
*\ IF gv_row = 1.
*\ WRITE: / sy-vline,2 'Row ID', 10 sy-vline,12 'Error',19 sy-vline,21 'Employee Id' ,32 sy-vline,34 'Message'.
*\ ULINE.
*\ ENDIF.
*} DELETE
*{ DELETE CHDK900245 6
*\ gv_row_str = gv_row.
*} DELETE
LOOP AT messtab.
MESSAGE ID messtab-msgid
TYPE messtab-msgtyp
NUMBER messtab-msgnr
INTO l_mstring
WITH messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 messtab-msgtyp,19 sy-vline,21 gv_pernr ,32 sy-vline,34 l_mstring.
ENDLOOP.
*{ REPLACE CHDK900245 3
*\ ELSE.
*\ WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 gv_pernr ,32 sy-vline,34 'Employee created Success'.
*\ ENDIF.
*\ IF messtab[] IS NOT INITIAL.
*\ READ TABLE messtab[] TRANSPORTING NO FIELDS WITH KEY msgtyp = 'E'.
*\ IF sy-subrc NE 0.
*\ WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 gv_pernr ,32 sy-vline,34 'Employee created Success'.
*\ ENDIF.
*\ ENDIF.
*\ CLEAR: bdcdata, bdcdata[].
ENDIF.
CLEAR lv_pernr.
SELECT SINGLE pernr begda INTO (lv_pernr,lv_begda) FROM pa0000 WHERE pernr = gv_pernr.
IF sy-subrc = 0.
CLEAR gv_position.
PERFORM create_0041 USING lv_pernr lv_begda.
gv_position = gs_input-plans.
IF lv_pernr IS NOT INITIAL AND gv_position IS NOT INITIAL AND gv_position NE '99999999'.
PERFORM create_1001 USING gv_position lv_pernr lv_begda.
ENDIF.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'S',19 sy-vline,21 gv_pernr ,32 sy-vline,34 'Employee created Success'.
ELSE.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'E',19 sy-vline,21 lv_pernr ,32 sy-vline,34 'Employee IS Not created'.
ENDIF.
CLEAR: bdcdata, bdcdata[].
*} REPLACE
ENDFORM.
*{ INSERT CHDK900245 1
FORM create_0041 USING lv_pernr TYPE persno
lv_begda TYPE begda.
DATA : lv_msg TYPE string,
ls_return TYPE bapireturn1,
ls_0041 TYPE p0041.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = lv_pernr
IMPORTING
return = ls_return.
IF ls_return-type NE 'E'.
CLEAR ls_return.
ls_0041-pernr = lv_pernr.
ls_0041-begda = lv_begda.
ls_0041-endda = '99991231'.
ls_0041-dar01 = 'Z1'.
ls_0041-dat01 = lv_begda.
ls_0041-dar02 = 'Z6'.
ls_0041-dat02 = lv_begda.
ls_0041-dar03 = 'Z9'.
ls_0041-dat03 = lv_begda.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0041'
number = lv_pernr
* subtype = subty
validityend = '99991231'
validitybegin = lv_begda
record = ls_0041
operation = 'INS'
IMPORTING
return = ls_return.
IF ls_return-type = 'E'.
CLEAR lv_msg.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = ls_return-id
lang = 'EN'
no = ls_return-number
v1 = ls_return-message_v1
v2 = ls_return-message_v2
v3 = ls_return-message_v3
v4 = ls_return-message_v4
IMPORTING
msg = lv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'W',19 sy-vline,21 gv_pernr ,32 sy-vline,
34 'Info 0041 is not created because', lv_msg.
ENDIF.
COMMIT WORK.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = lv_pernr
IMPORTING
return = ls_return.
ENDIF.
CLEAR: ls_return.
ENDFORM.
FORM create_1001 USING lv_position TYPE OBJEKTID
lv_pernr TYPE persno
lv_begda TYPE begda.
DATA : ls_1001 TYPE p1001.
CLEAR ls_1001.
ls_1001-OTYPE = 'S'.
ls_1001-OBJID = lv_position.
ls_1001-PLVAR = '01'.
ls_1001-RSIGN = 'A'.
ls_1001-RELAT = '008'.
ls_1001-ISTAT = '1'.
ls_1001-BEGDA = lv_begda.
ls_1001-ENDDA = '99993112'.
ls_1001-INFTY = '1001'.
ls_1001-SCLAS = 'P'.
ls_1001-SOBID = lv_pernr.
ls_1001-PROZT = 100.
CALL FUNCTION 'RH_PM_ENQUEUE'
EXPORTING
act_plvar = '01'
act_otype = 'S'
act_objid = lv_position
EXCEPTIONS
ERROR_IN_ENQUEUE = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'RH_PNNNN_MAINTAIN'
EXPORTING
act_fcode = 'INSE'
ACT_PLVAR = '01'
act_otype = 'S'
act_objid = lv_position
ACT_INFTY = '1001'
ACT_SUBTY = 'A008'
ACT_ISTAT = '1'
ACT_BEGDA = lv_begda
ACT_ENDDA = '99991231'
ACT_PNNNN = ls_1001
ACT_VTASK = 'S'
ACT_COMMIT_FLG = 'X'
SUPPRESS_DIALOG = 2
EXCEPTIONS
INFTY_NOT_VALID = 1
NO_PLVAR = 2
OBJECT_NOT_DEFINED = 3
OTYPE_NOT_VALID = 4
NO_AUTHORITY = 5
ACTION_REJECTED = 6
NO_GDATE = 7
FCODE_NOT_SUPPORTED = 8
OTHERS = 9.
IF sy-subrc NE 0.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'W',19 sy-vline,21 gv_pernr ,32 sy-vline,
34 'Info 1001 - Position to Employess relationship is not created'.
ENDIF.
CALL FUNCTION 'RH_PM_DEQUEUE'
EXPORTING
act_plvar = '01'
act_otype = 'S'
act_objid = lv_position.
ELSE.
WRITE: / sy-vline,2 gv_row_str, 10 sy-vline,12 'W',19 sy-vline,21 lv_position ,32 sy-vline,
34 'Position is locked, So 1001 - Position to Employess relationship is not created'.
ENDIF.
ENDFORM.
*} INSERT
No comments:
Post a Comment