This program clones all the primary data (Pa *) of an employee to a new employee. The specific code is as follows:
*&---------------------------------------------------------------------*
* & Report zppa_clone_pernr
*&
*&---------------------------------------------------------------------*
* & Clone
*&*
*&---------------------------------------------------------------------*
Report zppa_clone_pernr line-size 255.
*
*----------------------------------------------------------------------*
* T a B L E S
*----------------------------------------------------------------------*
Tables: pasters.
*----------------------------------------------------------------------*
* C o n s t a N T S
*----------------------------------------------------------------------*
* Constants :.
**----------------------------------------------------------------------*
** D a T
**----------------------------------------------------------------------*
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 '2013' obligatory.
Parameters: p_per2 like prelp-pernr default '2013' 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'
'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 '123 '.
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 'vora'
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
**----------------------------------------------------------------------*
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/CompassButton/archive/2007/10/05/1812309.aspx