You are on page 1of 24

report zhr_kar1_bdc_emp

no standard page heading line-size 255.


type-pools: truxs.
types:begin of zemp,
pernr type pspar-pernr,
begda type string, "p0002begda,
endda type string, "p0002endda,
massn type massn,
massg type massg,
werks type werks,
persg type persg,
persk type persk,
anrex type anrex,
nachn type nachn,
vorna type vorna,
gbpas type gbpas,
sprsl type sprsl,
natio type natio,
end of zemp.
data: it_tab type table of zemp,
wa type zemp,
field_name
like dynpread-fieldname,
it_tab1 type table of bdcdata,
wa1 type bdcdata,
it_bdcmsg type table of bdcmsgcoll,
w_struct type truxs_t_text_data.
parameters: z_excel(128) type c obligatory.
at selection-screen on value-request for z_excel.
call function 'F4_FILENAME'
exporting
program_name
= syst-cprog
dynpro_number
= syst-dynnr
field_name
= field_name
importing
file_name
= z_excel .

*
*

*
*

call function 'TEXT_CONVERT_XLS_TO_SAP'


exporting
I_FIELD_SEPERATOR
=
I_LINE_HEADER
=
i_tab_raw_data
= w_struct
i_filename
= z_excel
tables
i_tab_converted_data
= it_tab
EXCEPTIONS
CONVERSION_FAILED
= 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.
*include bdcrecx1.
start-of-selection.
loop at it_tab into wa.

perform bdc_dynpro
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_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

using 'SAPMP50A' '1000'.


using 'BDC_CURSOR'
'RP50G-PERNR'.
using 'BDC_OKCODE'
'/00'.
using 'RP50G-PERNR'
''.
using 'RP50G-TIMR6'
'X'.
using 'SAPMP50A' '1000'.
using 'BDC_OKCODE'
'=INS'.
using 'RP50G-PERNR'
''.
using 'BDC_CURSOR'
'T582S-ITEXT(01)'.
using 'RP50G-SELEC(01)'
'X'.
using 'RP50G-TIMR6'
'X'.
using 'MP000000' '2000'.
using 'BDC_CURSOR'
'P0000-MASSG'.
using 'BDC_OKCODE'
'=UPD'.
using 'PSPAR-PERNR'
wa-pernr.
using 'P0000-BEGDA'
wa-begda.
using 'P0000-ENDDA'
wa-endda.
using 'P0000-MASSN'
wa-massn.
using 'P0000-MASSG'
wa-massg.
using 'PSPAR-WERKS'
wa-werks.

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_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'PSPAR-PERSG'
wa-persg.
using 'PSPAR-PERSK'
wa-persk.
using 'MP000200' '2001'.
using 'BDC_CURSOR'
'Q0002-GBPAS'.
using 'BDC_OKCODE'
'=UPD'.
using 'P0002-BEGDA'
wa-begda.
using 'P0002-ENDDA'
wa-endda.
using 'Q0002-ANREX'
wa-anrex.
using 'P0002-NACHN'
wa-nachn.
using 'P0002-VORNA'
wa-vorna.
using 'Q0002-GBPAS'
wa-gbpas.
using 'P0002-SPRSL'
wa-sprsl.
using 'P0002-NATIO'
wa-natio.
using 'MP000100' '2000'.
using 'BDC_OKCODE'
'/EBCK'.
using 'BDC_CURSOR'
'P0001-BEGDA'.
using 'SAPLSPO1' '0200'.
using 'BDC_OKCODE'
'=YES'.

call transaction 'PA30' using it_tab1 mode 'A' update 'S'


messages into it_bdcmsg.
refresh it_tab1.
endloop.
*&---------------------------------------------------------------------*
*&
Form BDC_DYNPRO
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0165
text
*
-->P_0166
text
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear wa1.
wa1-program = program.
wa1-dynpro
= dynpro.

wa1-dynbegin = 'X'.
append wa1 to it_tab1.
endform.
" BDC_DYNPRO
*&---------------------------------------------------------------------*
*&
Form BDC_FIELD
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0290
text
*
-->P_WA_BEGDA text
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
clear wa1.
wa1-fnam = fnam.
wa1-fval = fval.
append wa1 to it_tab1.
endform.

" BDC_FIELD

*&---------------------------------------------------------------------*
*& Report ZHR_KAR2_BDC_EMP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zhr_kar2_bdc_emp.
type-pools: truxs.
types: begin of zstruct,
pernr type pspar-pernr,
begda type string, "p0002begda,
endda type string, "p0002endda,
massn type massn,
massg type massg,
werks type werks,
persg type persg,
persk type persk,
anrex type anrex,
nachn type nachn,
vorna type vorna,
gbpas type gbpas,
sprsl type sprsl,
natio type natio,
end of zstruct.

types:begin of st_valid,
pernr type rp50g-pernr,
end of st_valid.
data: it_file type table of zstruct,
wa_file type zstruct,
it_file1 type table of bdcdata,
wa_file1 type bdcdata,
field_name
like dynpread-fieldname,
w_struct type truxs_t_text_data,
it_bdcmsg type table of bdcmsgcoll,
it_valid type table of st_valid,
wa_valid type st_valid.
parameters: p_file(128) type c obligatory.
parameters : p_create radiobutton group rb1.
parameters : p_update radiobutton group rb1.
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name
= field_name
importing
file_name
= p_file.

*
*

*
*
*
*
*

call function 'TEXT_CONVERT_XLS_TO_SAP'


exporting
I_FIELD_SEPERATOR
=
I_LINE_HEADER
=
i_tab_raw_data
= w_struct
i_filename
= p_file
tables
i_tab_converted_data
= it_file
EXCEPTIONS
CONVERSION_FAILED
= 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.

* Creation
start-of-selection.

if p_create = 'X' .
loop at it_file into wa_file.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

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_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

USING 'SAPMP50A' '1000'.


USING 'BDC_OKCODE'
'=INS'.
USING 'RP50G-PERNR'
wa_file-pernr.
USING 'BDC_CURSOR'
'T582S-ITEXT(01)'.
USING 'RP50G-SELEC(01)'
'X'.
USING 'RP50G-TIMR6'
'X'.
USING 'MP000000' '2000'.
USING 'BDC_CURSOR'
'PSPAR-PERSK'.
USING 'BDC_OKCODE'
'=UPD'.
USING 'PSPAR-PERNR'
wa_file-pernr.
USING 'P0000-BEGDA'
wa_file-begda.
USING 'P0000-ENDDA'
wa_file-endda.
USING 'P0000-MASSN'
wa_file-massn.
USING 'P0000-MASSG'
wa_file-massg.
USING 'PSPAR-WERKS'
wa_file-werks.
USING 'PSPAR-PERSG'
wa_file-persg.
USING 'PSPAR-PERSK'
wa_file-persk.
USING 'MP000200' '2001'.
USING 'BDC_CURSOR'
'P0002-NATIO'.
USING 'BDC_OKCODE'
'=UPD'.
USING 'P0002-BEGDA'
wa_file-begda.
USING 'P0002-ENDDA'
wa_file-endda.
USING 'Q0002-ANREX'
wa_file-anrex.
USING 'P0002-NACHN'
wa_file-nachn.
USING 'P0002-VORNA'
wa_file-vorna.
USING 'Q0002-GBPAS'
wa_file-gbpas.

*
*
*
*
*
*
*
*
*
*
*
*

PERFORM bdc_field
PERFORM bdc_field
PERFORM bdc_dynpro
PERFORM bdc_field
PERFORM bdc_field
PERFORM bdc_dynpro
PERFORM bdc_field

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_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

USING 'P0002-SPRSL'
wa_file-sprsl.
USING 'P0002-NATIO'
wa_file-natio.
USING 'MP000100' '2000'.
USING 'BDC_OKCODE'
'/EBCK'.
USING 'BDC_CURSOR'
'P0001-BEGDA'.
USING 'SAPLSPO1' '0200'.
USING 'BDC_OKCODE'
'=YES'.
using 'SAPMP50A' '1000'.
using 'BDC_OKCODE'
'=INS'.
using 'RP50G-PERNR'
wa_file-pernr.
using 'BDC_CURSOR'
'T582S-ITEXT(01)'.
using 'RP50G-SELEC(01)'
'X'.
using 'RP50G-TIMR6'
'X'.
using 'MP000000' '2000'.
using 'BDC_CURSOR'
'PSPAR-PERSK'.
using 'BDC_OKCODE'
'=UPD'.
using 'P0000-BEGDA'
'16.03.2016'.
using 'P0000-MASSN'
'01'.
using 'PSPAR-WERKS'
'1000'.
using 'PSPAR-PERSG'
wa_file-persg.
using 'PSPAR-PERSK'
wa_file-persk.
using 'MP000200' '2001'.
using 'BDC_CURSOR'
'Q0002-GBPAS'.
using 'BDC_OKCODE'
'=UPD'.
using 'P0002-BEGDA'
'16.03.2016'.
using 'P0002-ENDDA'
'31.12.9999'.
using 'Q0002-ANREX'
'Mr.'.
using 'P0002-NACHN'
wa_file-nachn.
using 'P0002-VORNA'

wa_file-vorna.
using 'Q0002-GBPAS'
wa_file-gbpas.
perform bdc_field
using 'P0002-SPRSL'
'EN'.
perform bdc_dynpro
using 'MP000100' '2000'.
perform bdc_field
using 'BDC_OKCODE'
'/EEND'.
perform bdc_field
using 'BDC_CURSOR'
'P0001-BEGDA'.
perform bdc_dynpro
using 'SAPLSPO1' '0200'.
perform bdc_field
using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'PA30'.
perform bdc_field

call transaction 'PA30' using it_file1 mode 'A' update 'S'


messages into it_bdcmsg.
refresh it_file1.
endloop.
elseif p_update = 'x' .
select pernr from pa0002 into table it_valid for all entries in it_file
where pernr = it_file-pernr.
loop at it_file into wa_file.
read table it_valid into wa_valid with key pernr = wa_file-pernr.
perform bdc_dynpro
perform bdc_field

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=INS'.
perform bdc_field
using 'RP50G-PERNR'
wa_file-pernr.
perform bdc_field
using 'BDC_CURSOR'
'T582S-ITEXT(01)'.
perform bdc_field
using 'RP50G-SELEC(01)'
'X'.
perform bdc_field
using 'RP50G-TIMR6'
'X'.
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-BEGDA'
wa_file-begda.
perform bdc_field
using 'P0000-MASSN'
wa_file-massn.
perform bdc_field
using 'P0000-MASSG'
wa_file-massg.

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_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'PSPAR-WERKS'
wa_file-werks.
using 'PSPAR-PERSG'
wa_file-persg.
using 'PSPAR-PERSK'
wa_file-persk.
using 'MP000200' '2001'.
using 'BDC_CURSOR'
'P0002-NATIO'.
using 'BDC_OKCODE'
'=UPD'.
using 'P0002-BEGDA'
wa_file-begda.
using 'P0002-ENDDA'
wa_file-endda.
using 'Q0002-ANREX'
wa_file-anrex.
using 'P0002-NACHN'
wa_file-nachn.
using 'P0002-VORNA'
wa_file-vorna.
using 'Q0002-GBPAS'
wa_file-gbpas.
using 'P0002-SPRSL'
wa_file-sprsl.
using 'P0002-NATIO'
wa_file-natio.
using 'MP000100' '2000'.
using 'BDC_OKCODE'
'/EBCK'.
using 'BDC_CURSOR'
'P0001-BEGDA'.
using 'SAPLSPO1' '0200'.
using 'BDC_OKCODE'
'=YES'.

call transaction 'PA30' using it_file1 mode 'A' update 'S'


messages into it_bdcmsg.
refresh it_file1.
endloop.
endif.
*&---------------------------------------------------------------------*
*&
Form BDC_DYNPRO
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0137
text
*
-->P_0138
text
*----------------------------------------------------------------------*

form bdc_dynpro using program dynpro.


clear wa_file1.
wa_file1-program = program.
wa_file1-dynpro
= dynpro.
wa_file1-dynbegin = 'X'.
append wa_file1 to it_file1.
endform.
" BDC_DYNPRO
*&---------------------------------------------------------------------*
*&
Form BDC_FIELD
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0152
text
*
-->P_0153
text
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
clear wa_file1.
wa_file1-fnam = fnam.
wa_file1-fval = fval.
append wa_file1 to it_file1.
endform.

REPORT

" BDC_FIELD

ZHR_KAR_BDC3 no standard page heading line-size 255.

type-pools : truxs.
types: begin of zstruct_cre,
empno type pspar-pernr,
earea type pspar-werks,
egroup type pspar-persg,
esubgrp type pspar-persk,
title type p0002-titel,
lname type p0002-nachn,
fname type p0002-vorna,
bdate type q0002-gbpas,
langu type p0002-sprsl,
nation type p0002-natio,
end of zstruct_cre.
types: begin of zstruct_upd,
llname type p0002-nachn,
ffname type p0002-vorna,
end of zstruct_upd.

parameters : pa_file like rlgrap-filename.


parameters : p_create radiobutton group rb1.
parameters : p_update radiobutton group rb1.
data g_raw_data type truxs_t_text_data.
data itab_cre type table of zstruct_cre.
data wa_cre type zstruct_cre.
data itab_upd type table of zstruct_upd.
data wa_upd type zstruct_upd.
data it_bdcdata type table of bdcdata.
data wa_bdcdata type bdcdata.
data it_msglog type table of bdcmsgcoll.
data wa_msglog type bdcmsgcoll.
types: begin of zstruct_log,
msgid type bdcmsgcoll-msgid,
msgnr type bdcmsgcoll-msgnr,
msgv1 type bdcmsgcoll-msgv1,
end of zstruct_log.
data: it_msgalv type table of zstruct_log,
wa_msgalv type zstruct_log.
at selection-screen on value-request for pa_file.
in input parameter.
call function 'F4_FILENAME'
exporting
field_name = 'P_FILE'
importing
file_name = pa_file.
. " F4_FILENAME
start-of-selection.
if p_create = 'X'.

*
*

*
*
*

call function 'TEXT_CONVERT_XLS_TO_SAP'


exporting
I_FIELD_SEPERATOR
=
I_LINE_HEADER
=
i_tab_raw_data
= g_raw_data
i_filename
= pa_file
tables
i_tab_converted_data
= itab_cre.
EXCEPTIONS
CONVERSION_FAILED
= 1
OTHERS
= 2

" FM used to get F4 help

.
if sy-subrc = 0.
message 'EMPLOYEE RECORDS UPLOADED SUCCESSFULLY' type 'I'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*include bdcrecx1.
loop at itab_cre into wa_cre.
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_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=INS'.
using 'RP50G-PERNR'
''.
using 'BDC_CURSOR'
'T582S-ITEXT(01)'.
using 'RP50G-SELEC(01)'
'X'.
using 'RP50G-TIMR6'
'X'.
using 'MP000000' '2000'.
using 'BDC_CURSOR'
'PSPAR-PERSK'.
using 'BDC_OKCODE'
'=UPD'.
using 'PSPAR-PERNR'
wa_cre-empno.
using 'P0000-BEGDA'
'01.01.2016'.
using 'P0000-ENDDA'
'31.12.9999'.
using 'P0000-MASSN'
'01'.
using 'PSPAR-WERKS'
wa_cre-earea.
using 'PSPAR-PERSG'
wa_cre-egroup.
using 'PSPAR-PERSK'
wa_cre-esubgrp.
using 'MP000200' '2001'.
using 'BDC_CURSOR'
'Q0002-GBPAS'.
using 'BDC_OKCODE'
'=UPD'.
using 'P0002-BEGDA'
'01.01.2016'.
using 'P0002-ENDDA'
'31.12.9999'.
using 'Q0002-ANREX'

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_dynpro
perform bdc_field
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_dynpro
perform bdc_field
perform bdc_field
*perform bdc_transaction

wa_cre-title.
using 'P0002-NACHN'
wa_cre-lname.
using 'P0002-VORNA'
wa_cre-fname.
using 'Q0002-GBPAS'
wa_cre-bdate.
using 'P0002-SPRSL'
wa_cre-langu.
using 'P0002-NATIO'
wa_cre-nation.
using 'MP000100' '2000'.
using 'BDC_OKCODE'
'/EBCK'.
using 'BDC_CURSOR'
'P0001-BEGDA'.
using 'SAPLSPO1' '0200'.
using 'BDC_OKCODE'
'=NO'.
using 'MP000100' '2000'.
using 'BDC_CURSOR'
'P0001-BEGDA'.
using 'BDC_OKCODE'
'/00'.
using 'P0001-BEGDA'
'01.01.2016'.
using 'P0001-ENDDA'
'31.12.9999'.
using 'P0001-ABKRS'
'D2'.
using 'MP000100' '2000'.
using 'BDC_CURSOR'
'P0001-BEGDA'.
using 'BDC_OKCODE'
'=UPD'.
using 'P0001-BEGDA'
'01.01.2016'.
using 'P0001-ENDDA'
'31.12.9999'.
using 'P0001-ABKRS'
'D2'.
using 'P0001-VDSK1'
'1000'.
using 'MP000600' '2001'.
using 'BDC_OKCODE'
'/EBCK'.
using 'BDC_CURSOR'
'P0006-BEGDA'.
using 'PA30'.

*perform close_group.
call transaction 'PA30' using it_bdcdata mode 'N' update 'S' messages in

to it_msglog.
refresh it_bdcdata.
endloop.
loop at it_msglog into wa_msglog.
wa_msgalv-msgid
= wa_msglog-msgid.
wa_msgalv-msgnr
= wa_msglog-msgnr.
wa_msgalv-msgv1
= wa_msglog-msgv1.
append wa_msgalv to it_msgalv.
clear: wa_msgalv, wa_msglog.
endloop.

elseif p_update = 'X'.

*
*

*
*
*
*
*
*

call function 'TEXT_CONVERT_XLS_TO_SAP'


exporting
I_FIELD_SEPERATOR
=
I_LINE_HEADER
=
i_tab_raw_data
= g_raw_data
i_filename
= pa_file
tables
i_tab_converted_data
= itab_upd.
EXCEPTIONS
CONVERSION_FAILED
= 1
OTHERS
= 2
.
if sy-subrc = 0.
MESSAGE 'EMPLOYEE RECORDS UPLOADED SUCCESSFULLY' TYPE 'I'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

loop at itab_upd into wa_upd.


perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=INS'.
using 'RP50G-PERNR'
'616263'.
using 'BDC_CURSOR'
'T582S-ITEXT(03)'.
using 'RP50G-SELEC(03)'
'X'.
using 'RP50G-TIMR6'
'X'.
using 'MP000200' '2001'.
using 'BDC_CURSOR'
'P0002-VORNA'.

perform bdc_field

using 'BDC_OKCODE'
'UPD'.
perform bdc_field
using 'P0002-BEGDA'
'24.03.1992'.
perform bdc_field
using 'P0002-ENDDA'
'31.12.9999'.
perform bdc_field
using 'Q0002-ANREX'
'Mr.'.
perform bdc_field
using 'P0002-NACHN'
wa_upd-llname.
perform bdc_field
using 'P0002-VORNA'
wa_upd-ffname.
perform bdc_field
using 'Q0002-GBPAS'
'24.03.1992'.
perform bdc_field
using 'P0002-SPRSL'
'EN'.
perform bdc_field
using 'P0002-NATIO'
'IN'.
*perform bdc_transaction using 'PA30'.
*perform close_group.
call transaction 'PA30' using it_bdcdata mode 'N' update 'S' messages in
to it_msglog.
refresh it_bdcdata.
endloop.
endif.
type-pools: slis.
data: it_fieldcat type slis_t_fieldcat_alv, wa_fieldcat
slis_fieldcat_alv.
wa_fieldcat-fieldname = 'MSGID'.
wa_fieldcat-seltext_m = 'Msg Id'.
append wa_fieldcat to it_fieldcat.

type

" Fieldname in the data table


" Column description o/p

wa_fieldcat-fieldname = 'MSGNR'.
wa_fieldcat-seltext_m = 'Msg Number.'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MSGV1'.
wa_fieldcat-seltext_m = 'Env'.
append wa_fieldcat to it_fieldcat.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = it_fieldcat
tables
t_outtab
= it_msgalv.
* EXCEPTIONS

*
*

PROGRAM_ERROR
OTHERS

= 1
= 2

.
if sy-subrc <> 0.
write 'No msg'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*----------------------------------------------------------------------*
*
Start new screen
*
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro
= dynpro.
wa_bdcdata-dynbegin = 'X'.
append wa_bdcdata to it_bdcdata.
endform.
"bdc_dynpro
**---------------------------------------------------------------------*
**
Insert field
**---------------------------------------------------------------------form bdc_field using fnam fval.
clear wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
append wa_bdcdata to it_bdcdata.
endform.

report

"bdc_field

zhr_ns_bdc_det no standard page heading line-size 255.

type-pools: truxs.
types: begin of ty_emp,
pernr type rp50g-pernr,
begda type q0002-gbpas,
werks type pspar-werks,
persg type pspar-persg,
persk type pspar-persk,
nachn type p0002-nachn,
vorna type p0002-vorna,
gbpas type q0002-gbpas,
sprsl type p0002-sprsl,
natio type p0002-natio,
end of ty_emp.

"personnel no
"start date
"personnel area
"employee group
"employee subgroup
"Last name
"First name
"DOB
"Language
"Nation

types: begin of ty_valid,


pernr type rp50g-pernr,
end of ty_valid.
types: begin of ty_status,
msg1 type c,
end of ty_status.
types: begin of ty_emp1,
pernr type rp50g-pernr, "personnel no
*
fatxt TYPE q0002-fatxt,
anzkd type p0002-anzkd,
end of ty_emp1.

data: it_emp type table of ty_emp,


wa_emp type ty_emp.
data: x_stru type truxs_t_text_data.
*DATA: it_bdcdata TYPE TABLE OF bdcdata,
*
wa_bdcdata TYPE bdcdata.
data: it_valid type table of ty_valid,
wa_valid type ty_valid.
data: it_status type table of ty_status,
wa_status type ty_status.
clear it_emp.
refresh it_emp.
data: it_emp1 type table of ty_emp1,
wa_emp1 type ty_emp1,
it_bdcmsg1 type table of bdcmsgcoll.
data: x_stru1 type truxs_t_text_data.

clear it_emp1.
refresh it_emp1.
selection-screen begin of block blck with frame title text-011.
parameters: up_file type localfile obligatory.
parameters: up_file1 type localfile obligatory.
selection-screen end of block blck.

parameters : p_create radiobutton group rb1.


parameters : p_update radiobutton group rb1.
include bdcrecx1.
at selection-screen on value-request for up_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name
= 'Filename '
importing
file_name
= up_file.
start-of-selection.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
*
I_FIELD_SEPERATOR
=
*
I_LINE_HEADER
=
i_tab_raw_data
= x_stru
i_filename
= up_file
tables
i_tab_converted_data
= it_emp
exceptions
conversion_failed
= 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.
at selection-screen on value-request for up_file1.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name
= 'Filename '
importing
file_name
= up_file1.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
*
I_FIELD_SEPERATOR
=
*
I_LINE_HEADER
=
i_tab_raw_data
= x_stru1
i_filename
= up_file1

tables
i_tab_converted_data
= it_emp1
exceptions
conversion_failed
= 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.

if p_create = 'X' .
loop at it_emp into wa_emp.
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_dynpro
perform bdc_field
perform bdc_field

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=INS'.
using 'RP50G-PERNR'
wa_emp-pernr.
using 'BDC_CURSOR'
'T582S-ITEXT(01)'.
using 'RP50G-SELEC(01)'
'X'.
using 'RP50G-TIMR6'
'X'.
using 'MP000000' '2000'.
using 'BDC_CURSOR'
'P0000-BEGDA'.
using 'BDC_OKCODE'
'=UPD'.
using 'PSPAR-PERNR'
wa_emp-pernr.
using 'P0000-BEGDA'
wa_emp-begda.
using 'P0000-ENDDA'
'31.12.9999'.
using 'P0000-MASSN'
'01'.
using 'PSPAR-WERKS'
wa_emp-werks.
using 'PSPAR-PERSG'
wa_emp-persg.
using 'PSPAR-PERSK'
wa_emp-persk.
using 'MP000200' '2001'.
using 'BDC_CURSOR'
'Q0002-GBPAS'.
using 'BDC_OKCODE'
'=UPD'.

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_dynpro
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field

using 'P0002-BEGDA'
wa_emp-begda.
using 'P0002-ENDDA'
'31.12.9999'.
using 'Q0002-ANREX'
'Mr.'.
using 'P0002-NACHN'
wa_emp-nachn.
using 'P0002-VORNA'
wa_emp-vorna.
using 'Q0002-GBPAS'
wa_emp-gbpas.
using 'P0002-SPRSL'
wa_emp-sprsl.
using 'P0002-NATIO'
wa_emp-natio.
using 'MP000100' '2000'.
using 'BDC_OKCODE'
'/EEND'.
using 'BDC_CURSOR'
'P0001-BEGDA'.
using 'SAPLSPO1' '0200'.
using 'BDC_OKCODE'
'=YES'.

perform bdc_transaction using 'PA30'.

**********************
*
Call transaction 'PA30' using bdcdata mode 'N' update 'S' messages into
it_status.
*
*
REFRESH it_status.
endloop.
elseif p_update = 'X' .
loop at it_emp1 into wa_emp1.
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=INS'.
using 'RP50G-PERNR'
wa_emp1-pernr.
using 'BDC_CURSOR'
'T582S-ITEXT(03)'.
using 'RP50G-SELEC(03)'
'X'.

perform bdc_field

*
*
*
*

using 'RP50G-TIMR6'
'X'.
perform bdc_dynpro
using 'MP000200' '2000'.
perform bdc_field
using 'BDC_CURSOR'
'P0002-ANZKD'.
perform bdc_field
using 'BDC_OKCODE'
'UPD'.
perform bdc_field
using 'P0002-BEGDA'
'30.03.1992'.
perform bdc_field
using 'P0002-ENDDA'
'31.12.9999'.
perform bdc_field
using 'Q0002-ANREX'
'Mr.'.
perform bdc_field
using 'P0002-NACHN'
'Hooper'.
perform bdc_field
using 'P0002-VORNA'
'Kingsley'.
perform bdc_field
using 'P0002-GBDAT'
'30.03.1992'.
perform bdc_field
using 'P0002-SPRSL'
'EN'.
DATA: v_char TYPE BDCDATA-FVAL.
clear v_char.
v_char = wa_emp-anzkd.
CONDENSE v_char.
perform bdc_field1

using 'P0002-ANZKD'
wa_emp1-anzkd .
perform bdc_field
using 'P0002-NATIO'
'IN'.
PERFORM bdc_transaction USING 'PA30'.
call transaction 'PA30' using bdcdata mode 'N' update 'S'
messages into it_bdcmsg1.
refresh bdcdata.
endloop.
perform close_group.

endif.
form bdc_field1 using fnam fval.
if fval <> nodata.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
condense bdcdata-fval.
append bdcdata.
endif.
endform.

report zhr_kar_bdc_update
no standard page heading line-size 255.
type-pools: truxs.
types: begin of ty_emp1,
pernr type rp50g-pernr, "personnel no
*
fatxt TYPE q0002-fatxt,
anzkd type p0002-anzkd,
end of ty_emp1.
data: it_emp1 type table of ty_emp1,
wa_emp1 type ty_emp1,
it_bdcmsg1 type table of bdcmsgcoll.
data: x_stru1 type truxs_t_text_data.

clear it_emp1.
refresh it_emp1.
selection-screen begin of block blck with frame title text-011.
parameters: up_file1 type localfile obligatory.
selection-screen end of block blck.
at selection-screen on value-request for up_file1.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name
= 'Filename '
importing
file_name
= up_file1.
start-of-selection.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
*
I_FIELD_SEPERATOR
=
*
I_LINE_HEADER
=
i_tab_raw_data
= x_stru1
i_filename
= up_file1
tables
i_tab_converted_data
= it_emp1
exceptions
conversion_failed
= 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.
include bdcrecx1.
start-of-selection.
perform open_group.
loop at it_emp1 into wa_emp1.
perform bdc_dynpro
perform bdc_field

*
*
*
*

using 'SAPMP50A' '1000'.


using 'BDC_OKCODE'
'=INS'.
perform bdc_field
using 'RP50G-PERNR'
wa_emp1-pernr.
perform bdc_field
using 'BDC_CURSOR'
'T582S-ITEXT(03)'.
perform bdc_field
using 'RP50G-SELEC(03)'
'X'.
perform bdc_field
using 'RP50G-TIMR6'
'X'.
perform bdc_dynpro
using 'MP000200' '2000'.
perform bdc_field
using 'BDC_CURSOR'
'P0002-ANZKD'.
perform bdc_field
using 'BDC_OKCODE'
'UPD'.
perform bdc_field
using 'P0002-BEGDA'
'30.03.1992'.
perform bdc_field
using 'P0002-ENDDA'
'31.12.9999'.
perform bdc_field
using 'Q0002-ANREX'
'Mr.'.
perform bdc_field
using 'P0002-NACHN'
'Hooper'.
perform bdc_field
using 'P0002-VORNA'
'Kingsley'.
perform bdc_field
using 'P0002-GBDAT'
'30.03.1992'.
perform bdc_field
using 'P0002-SPRSL'
'EN'.
DATA: v_char TYPE BDCDATA-FVAL.
clear v_char.
v_char = wa_emp-anzkd.
CONDENSE v_char.
perform bdc_field1
perform bdc_field

using 'P0002-ANZKD'
wa_emp1-anzkd .
using 'P0002-NATIO'
'IN'.

PERFORM bdc_transaction USING 'PA30'.


call transaction 'PA30' using bdcdata mode 'N' update 'S'
messages into it_bdcmsg1.
refresh bdcdata.
endloop.
perform close_group.

form bdc_field1 using fnam fval.


if fval <> nodata.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
condense bdcdata-fval.
append bdcdata.
endif.
endform.

types: begin of ty_valid,


pernr type rp50g-pernr,
end of ty_valid.

You might also like