Академический Документы
Профессиональный Документы
Культура Документы
Added by Venkat Appikonda, last edited by Manish Kumar on Jan 06, 2014 (view
change)
Go to start of metadata
Using macros in HRABAP
Macro means presenting programs in modular form.
Customer-specific RMAC modules should begin with a special character.
The macros defined in table TRMAC can be used by all reports.
When you change a RMAC macro in the table TRMAC, the reports that use this macro are not
regenerated automatically. You must regenerate them manually.
Macros in personnel administration
RP_PROVIDE_FROM_LAST Pnnnn SPACE PN-BEGDA PN-ENDDA.
or
RP_PROVIDE_FROM_FIRST Pnnnn SPACE PN-BEGDA PN-ENDDA.
These statements make the most recent or earliest record in the PN/BEGDA to PN/ENDDA data
selection period available in the structure Pnnnn for info type nnnn.
If the infotype has subtypes, replace the SPACE parameter by the appropriate subtype number.
When a record has been successfully read, the return code PNP-SW-FOUND = 1 is returned.
Use PNP logical database in the attributes of the program
1 REPORT zmacro01 .
2 TABLES: pernr.
INFOTYPES: 0008.
3
4 GET pernr.
5 *---get the first record for
rp_provide_from_frst p0008
6
IF pnp-sw-found EQ 1.
7
WRITE: / pernr-pernr,
8
pn-begda,
9
pn-endda,
10
p0008-ansal,
p0008-lga01,
11
p0008-bet01.
12
ENDIF.
13*---get the last record for
14 rp_provide_from_last p0008
15 IF pnp-sw-found EQ 1.
WRITE: / pernr-pernr,
16
pn-begda,
17
pn-endda,
18
p0008-ansal,
19
p0008-lga01,
p0008-bet01.
20
21 ENDIF.
22
23
24
25
Macros in applicant data.
Use PAP logical database in the attributes of the program
PAP_PROVIDE_FROM_LAST Pnnnn SPACE PA$BEGDA PA$ENDDA.
or
PAP_PROVIDE_FROM_FIRST Pnnnn SPACE PA$BEGDA PA$ENDDA.
If the infotype has subtypes, replace the SPACE parameter by the appropriate subtype number.
When a record has been successfully read, the return code PNP-SW-FOUND = 1 is returned.
1
2
REPORT zmacro02.
3
TABLES: applicant.
4
INFOTYPES: 0001.
5
6 GET applicant.
7
pap_provide_from_first p0001 space pa$begda pa$endda.
IF pap_sw_found EQ 1.
8
WRITE: / applicant-aplno,
9
p0001-bukrs,
10
p0001-werks,
11
p0001-persg,
pa$begda,
12
pa$endda.
13
ENDIF.
14
pap_provide_from_last p0001 space pa$begda pa$endda.
15 IF pap_sw_found EQ 1.
16
WRITE: / applicant-aplno,
p0001-bukrs,
17
p0001-werks,
18
p0001-persg,
19
pa$begda,
20
pa$endda.
21 ENDIF.
22
23
Macros in time management
You should not load all time infotype records from the earliest to most recent system dates into
the main memory. This would quickly lead to a memory overload, especially if a front-end time
recording system is connected to your HR system.
Use the infotype declaration supplement MODE N to define that the internal time infotype
tables
In Payroll these macros are used to import and export the data from/to the cluster tables
RP-aaa-Cn-xy
where aaa = IMP / EXP,
n=1 for PCL1, 2 for PCL2, 3 for PCL3, 4 or PCL4
and xy = cluster name.
Export Using the Data Buffer
When macros are used for exporting, records are written to a main memory buffer and not
directly to the database. When the program run has been completed, the records in the buffer are
stored in the appropriate PCLn database.
Import Using the Data Buffer
When the macros are used to import data, the data records are not read directly from file PCLn.
Instead, the system checks the buffer directory to see whether the main memory already
contains a record with the same key. If this is not the case, the record is read from PCLn to the
buffer and then retrieved from the buffer for the report.
If the import is successful, the return code RP-IMP-xy-SUBRC = 0 is set. When data is read
from the buffer, the system carries out a check for cluster authorization. Standard import
programs follow the naming convention RPCLSTxy (xy = cluster name).
here is the program how to use the macros RP-aaa-Cn-xy in the payroll
Use PNP logical database in the attributes of the program
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
REPORT zhrpayroll
NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65
MESSAGE-ID zz.
************************************************************************
*
T A B L E S D E C L A R A T I O N
*
************************************************************************
TABLES: pernr,
" STUCTURE PERNR DECLARATION
pcl1,
" CLUSTER DECLARATION
pcl2.
" CLUSTER DECLARATION
************************************************************************
*
I N F O T Y P E S
D E C L A R A T I O N
*
************************************************************************
INFOTYPES: 0001,
"INFOTYPE 0001 DECLARATION
0002.
"INFOTYPE 0002 DECLARATION
***********************************************************************
*
I N C L U D E
S T R U C T U R E S
*
***********************************************************************
INCLUDE rpc2cd09.
"Cluster CD Data-Definition
INCLUDE rpc2ca00.
"Cluster CA Data-Definition "XUJP30K079863
INCLUDE rpc2ruu0.
"Cluster RU Data-Definition
INCLUDE rpc2rx09.
"Cluster RU Data-Definition internat. part
INCLUDE rpppxd00.
"Data Definition buffer PCL1/PCL2
INCLUDE rpppxd10.
"Common part buffer PCL1/PCL2
INCLUDE rpppxm00.
"Buffer handling routine
************************************************************************
*
I N T E R N A L T A B L E S D E C L A R A T I O N
*
************************************************************************
*....internal table to store final data
DATA: BEGIN OF it_final OCCURS 0,
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 FORM getpermo.
72 *.....get Period parameter into v_permo from table t549a
SELECT SINGLE permo
73
FROM t549a
74
INTO v_permo
WHERE abkrs = v_abkrs.
75
ENDFORM.
" GETPERMO
76
************************************************************************
77 *
Form GETDATES
*
78 ************************************************************************
79 FORM getdates.
80 *.....Time period indicator: Current period is initial
IF pnptimr9 = 'X'.
81
PERFORM getdates1.
82 *.....Time period indicator: Other period is initial
83
ELSEIF pnptimra = 'X'.
PERFORM getdates2.
84
ENDIF.
85
" GETDATES
86 ENDFORM.
************************************************************************
87 *
Form GETDATES1
*
88 ************************************************************************
89 FORM getdates1.
90 *.....get Payroll year and period from table t569v
SELECT SINGLE pabrj
91
pabrp
92
FROM t569v
93
INTO (v_pabrj , v_pabrp)
WHERE abkrs = v_abkrs.
94
*.....get
Start Date and End Date from table t549q
95
SELECT SINGLE endda
96
begda
97
FROM t549q
INTO (v_endda , v_begda)
98
WHERE pabrj = v_pabrj
99
pabrp = v_pabrp
100 AND
AND permo = v_permo.
101ENDFORM.
" GETDATES1
102************************************************************************
Form GETDATES2
*
103*
************************************************************************
104
FORM getdates2.
105*.....get Start Date and End Date from table t549q
106 SELECT SINGLE endda
107 begda
108 FROM t549q
109 INTO (v_endda , v_begda)
WHERE pabrj = pnppabrj
110 AND pabrp = pnppabrp
111 AND permo = v_permo.
" GETDATES2
112 ENDFORM.
************************************************************************
113
Form GET-DATA
*
114 *************************************************************************
115 FORM get-data.
116 *.....HR macro to get Latest Personnel Org. Info by Start and End dates
rp-provide-from-frst p0001 space v_begda
117 v_endda.
118 *.....if infotype p0001 succussfully read
IF pnp-sw-found = '1'.
119
it_final-pernr = p0001-pernr.
120*.....HR macro to get Latest personal Info by Start and End dates
rp-provide-from-last p0002 space v_begda
121
v_endda.
122
*.....if infotype p0002 succussfully read
123
IF pnp-sw-found = '1'.
124
it_final-vorna = p0002-vorna.
125
it_final-nachn = p0002-nachn.
it_final-gbdat = p0002-gbdat.
126
*.....get
data into Resultant table using function module CU_READ_RGDIR
127
PERFORM read-rgdir.
128
ENDIF.
129 ENDIF.
" GET-DATA
130ENDFORM.
************************************************************************
131
Form READ-RGDIR
*
132*************************************************************************
133FORM read-rgdir.
134*.....fill it_rgdir Personnel Number
135 CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
136
persnr
= p0001-pernr
137
TABLES
138
in_rgdir
= it_rgdir
139
EXCEPTIONS
no_record_found = 1
140
OTHERS
= 2.
141
IF sy-subrc <> 0.
142
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
143
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
144 ENDIF.
145*.....check whether "Pay date for payroll result" with in Start Date and
End date, and "Reason for Off-Cycle Payroll" is initial
146* LOOP AT it_rgdir
WHERE paydt >= v_begda
147 AND paydt <= v_endda AND
148 void IS INITIAL
149 AND ocrsn IS INITIAL
150 AND srtza = 'A'.
v_seqnr = it_rgdir-seqnr.
151*.....Move pernr and seqnr to cluster RX
152
UNPACK p0001-pernr TO rx-key-pernr.
UNPACK v_seqnr TO rx-key-seqno.
153
*.....Macro
for getting US pernrs Info. in cluster PCL2
154
rp-imp-c2-ru.
155
*.....populate internal table RT where Wage Type is '1000'
156
LOOP AT rt WHERE lgart = '1000'.
157
it_final-betrg = rt-betrg.
158*.......populate internal table TCRT where Wage Type is '/100'
LOOP AT tcrt WHERE lgart = '/101' AND ctype = 'Y'.
159
it_final-betrg1 = tcrt-betrg.
160
APPEND it_final.
161
ENDLOOP.
162
ENDLOOP.
CLEAR it_final.
163 ENDLOOP.
164 REFRESH it_rgdir.
ENDFORM.
" READ-RGDIR
165************************************************************************
166*
Form DISPLAY-PARA
*
167************************************************************************
168FORM display-para.
IF it_final[] IS INITIAL.
169
MESSAGE i013 WITH 'No data matched selection criteria'.
170 ELSE.
171
WRITE:/ sy-uline(125).
WRITE:/5 'PAYROLL AREA ' ,
172
30 'PAYROLL TEXT'.
173
WRITE:/ sy-uline(125).
174
WRITE:/10 v_abkrs,
175
35 v_atext.
WRITE:/ sy-uline(125).
176
WRITE:/2 'EMP ID',
177
10 'FULL NAME',
178
46 'DATE OF BIRTH',
179
70 'BASIC PAY',
180
90'TOTAL GROSS CUMULATED TAX AMOUNT'.
WRITE:/ sy-uline(125).
181
LOOP AT it_final.
182
CONCATENATE it_final-vorna it_final-nachn INTO v_name
183
SEPARATED BY ' '.
184
WRITE: / it_final-pernr,
185
v_name,
it_final-gbdat,
186
it_final-betrg,
187
it_final-betrg1.
188
CLEAR v_name.
189
CLEAR it_final.
ENDLOOP.
190
WRITE:/ sy-uline(125).
191
ENDIF.
192ENDFORM.
" DISPLAY-PARA
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238