HR--一个员工的所有主数据(PA*)克隆到一个新员工的程序代码
这个程序将一个员工的所有主数据(PA*)克隆到一个新员工,具体代码
*&---------------------------------------------------------------------*
*& Report ZPPA_CLONE_PERNR
*&
*&---------------------------------------------------------------------*
*& CLONE
*& *
*&---------------------------------------------------------------------*
report zppa_clone_pernr line-size 255.
*
*----------------------------------------------------------------------*
* T A B L E S
*----------------------------------------------------------------------*
tables: pa0000.
*----------------------------------------------------------------------*
* C O N S T A N T S
*----------------------------------------------------------------------*
*constants: .
**----------------------------------------------------------------------*
** D A T A
**----------------------------------------------------------------------*
data: i_dd02l like dd02l occurs 0 with header line.
* Objects for variable structure assignment
data dref type ref to data.
field-symbols: <table> type any table,
<wa> type any,
<field> type any,
<field_nachn> type any,
<field_vorna> type any.
field-symbols <pnnnn> type c.
**----------------------------------------------------------------------*
** P A R A M E T E R S
**----------------------------------------------------------------------*
*### Input
selection-screen: begin of block frm1 with frame title text-010.
parameters: p_pernr like prelp-pernr default '30001' obligatory.
parameters: p_per2 like prelp-pernr default '30071' obligatory.
selection-screen: end of block frm1.
selection-screen: begin of block frm2 with frame title text-011.
select-options: pr_tnam for i_dd02l-tabname default 'PA0000' to
'PA9999' no-display.
selection-screen: end of block frm2.
selection-screen: begin of block frm3 with frame title text-012.
parameters: p_nachn like pa0002-nachn default 'Hubert'.
parameters: p_vorna like pa0002-vorna default 'Peter'.
selection-screen: end of block frm3.
parameters: p_pwd(3).
parameters: p_detail as checkbox.
parameters: p_test as checkbox default 'X'.
**----------------------------------------------------------------------*
** I N I T I A L I Z A T I O N
**----------------------------------------------------------------------*
*initialization.
*************************************************************************
** S T A R T O F P R O G R A M
*************************************************************************
**----------------------------------------------------------------------*
** S T A R T O F S E L E C T I O N
**----------------------------------------------------------------------*
start-of-selection.
if p_pwd ne '555'.
message s398(00) with 'Bitte Passwort eingeben'.
exit.
endif.
select single * from pa0000 where pernr = p_per2.
if sy-subrc = 0.
message s398(00) with 'PERNR Existiert schon,bitte zuerst vollst. löschen'.
exit.
endif.
select * from dd02l into table i_dd02l where tabname in pr_tnam.
loop at i_dd02l.
create data dref type standard table of (i_dd02l-tabname)
with non-unique default key.
assign dref->* to <table>.
select *
from (i_dd02l-tabname)
into table <table>
where pernr = p_pernr.
if sy-subrc = 0.
format color col_key intensified on.
write:/ i_dd02l.
endif.
loop at <table> assigning <wa>.
format color col_normal intensified off.
if p_detail = 'X'.
write:/3 space.
endif.
do 30 times.
assign component sy-index
of structure <wa> to <field>.
if sy-subrc = 0.
if p_detail = 'X'.
write: <field>.
endif.
endif.
enddo.
if i_dd02l-tabname = 'PA0001'.
assign component 'ENAME'
of structure <wa> to <field>.
if sy-subrc = 0.
concatenate p_vorna p_nachn into <field> separated by space.
endif.
endif.
if i_dd02l-tabname = 'PA0002'.
assign component 'NACHN'
of structure <wa> to <field>.
if sy-subrc = 0.
<field> = p_nachn.
endif.
assign component 'VORNA'
of structure <wa> to <field>.
if sy-subrc = 0.
<field> = p_vorna.
endif.
endif.
* Tab update
if p_test is initial.
assign component 'PERNR'
of structure <wa> to <field>.
<field> = p_per2.
check i_dd02l-tabname(2) = 'PA'.
modify (i_dd02l-tabname) from <wa>.
endif.
endloop.
endloop.
**----------------------------------------------------------------------*
** E N D O F S E L E C T I O N
**----------------------------------------------------------------------*
source url: https://www.sdn.sap.com/irj/sdn/wiki?path=/display/Snippets/HR+Clone+Pernr&