1.PNP:逻辑数据库PNP
结构(structure): pnnnn , psnnnn , qnnnn , pernr
pnnnn是每种信息类型的字段汇总,它包括PSnnnn(字段表)、Pskey(关键字表)、PSHD1(每种信息类型中公有部分) 。
qnnnn 是屏幕字段表 比如P0002-ANRED(地址表格关键字)只是一个CHAR(1)的关键字,要在屏幕上录入和显示就需要在Q0002中加上字段Q0002-ANREX(称谓文本) CHAR(5)。
pernr 为HR 主数据报告的标准选择 其中包括0000和0001两种信息类型的字段及一些其他字段。
结构QPPNP用于存放在SELECTION屏幕中所选的值.比如时间范围等.
为节省系统资源,pnnnn表中存储的大部分都是KEY字段,而在程序运行过程中去相应的CONTORL TABLE 中读取text和attribute信息. 例如P0001对应的其中一个CONTORL TABLE 是T513S(工作职别)
NODES: pernr.
INFOTYPES: 0002. "Personal Data
*-- Processing
GET pernr.
PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.
CHECK language.
WRITE: / ....
ENDPROVIDE.
其中PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.
CHECK language.
WRITE: / ....
ENDPROVIDE.
与LOOP AT P0002 WHERE ENDDA GE PN-BEGDA
AND BEGDA LE PN_ENDDA.
WRITE....
ENDLOOP.
等价.
其中pn-degda和pn-endda是屏幕选择中的时间范围.
2.
两种信息类型的关联处理.
1. JOIN:
REPORT zpsol020 LINE-SIZE 100.
*-- declaration
TABLES: pernr.
INFOTYPES: 0002, "Personal Data
0006. "Address
DATA: name LIKE p0001-ename.
*-- Processing
GET pernr.
PROVIDE * FROM p0002
* FROM p0006 BETWEEN pn-begda AND pn-endda
WHERE p0006-subty = '1'.
IF p0006_valid EQ 'X'.
*程序运行后每个被INCLUDE的信息类型都会产生pnnnn-valid变量,如果该行有值则这个变量的值为’X’. 例如: p0002中一行3.1-4.1而p0006中一行3.1-6.1。 屏幕选择日期为5.1-5.2。则只有p0006有值,而p0002中没有。
CONCATENATE p0002-nachn p0002-vorna INTO name
SEPARATED BY SPACE.
PERFORM print_data.
ENDIF.
ENDPROVIDE.
*-------------------------------------------------------------*
* FORM PRINT_DATA
*-------------------------------------------------------------*
FORM print_data.
WRITE: / p0002-pernr NO-ZERO,
sy-vline,
p0002-begda,
sy-vline,
p0002-endda,
sy-vline,
(30) name,
sy-vline,
(20) p0006-ort01.
ENDFORM.
2.PROJECTION
REPORT zpsol030 LINE-SIZE 100.
*-- Declaration
TABLES: pernr,
T513S. "Job Titles
INFOTYPES: 0001, "Organ. Assignment
0002. "Personal Data
*-- Processing
GET pernr.
PROVIDE stell ename FROM p0001
gbdat FROM p0002 BETWEEN pn-begda and pn-endda.
*感觉JOIN和PROJECTION没太大区别,只是一个用*,一个用具体字段而已。
IF p0001_valid EQ 'X'.
IF p0001-stell NE space.
PERFORM re513s.
WRITE: / pernr-pernr,
sy-vline,
(20) p0001-ename,
sy-vline,
p0002-gbdat,
sy-vline,
p0001-stell,
sy-vline,
(15) t513s-stltx,
sy-vline,
p0001-begda,
sy-vline,
p0001-endda.
ENDIF.
ENDIF.
ENDPROVIDE.
*-------------------------------------------------------------*
* FORM RE513S
*-------------------------------------------------------------*
* Read Job Title
*-------------------------------------------------------------*
FORM re513s.
CHECK sy-langu NE t513s-sprsl OR
p0001-stell NE t513s-stell OR
p0001-begda LT t513s-begda OR
p0001-begda GT t513s-endda.
SELECT * FROM t513s
WHERE sprsl EQ sy-langu
AND stell EQ p0001-stell
AND endda GE p0001-begda
AND begda LE p0001-begda.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR t513s.
WRITE: / pernr-pernr,
‘No entry in T513S for job key’ (001),
p0001-stell.
REJECT.
ENDIF.
ENDFORM.
3.
PNP中的宏和函数
表$rinfo$ 是LOG表?
1.宏
RP_PROVIDE_FROM_LAST:取符合条件的最后一条记录。
RP_PROVIDE_FROM_FIRST:取符合条件的第一条记录。(取出后放在PNNNN内表工作区中)
输入参数:1.pnnnn 2. pnnnn-subtype 3. pn-begda 4.pn-endda
返回参数: pnp-sw-found 为1时,有返回记录,0时,没有记录.
RP_SET_DATA_INTERVAL 用来设置时间间隔。将表$rinfo$中的时间间隔改写为选择屏幕中的时间。
以上宏在程序DBPNPMAC中,如果不引用LOGIC DATABASE的话,需要INCLUDE该程序才能使用这三个宏.
2.函数HR_READ_INFOTYPE:
该函数自动进行权限检查
返回值SUBRC: 0 - 返回所有结果
4 - 由于权限问题返回部分结果
8 - 没有找到数据
12 - 由于权限问题没有返回任何结果.
该函数只能在未引用逻辑数据库PNP的情况下使用,如果已经引用了PNP,则应该使用函数READ-INFOTYPE,参数与上函数类似.
(FORM read-infotype TABLES ri_inftab USING ri_pernr
ri_infty
ri_begda LIKE sy-datum
ri_endda LIKE sy-datum.)
3.函数 RP_GET_HIRE_DATE
取员工的入职时间
其中CHECK_INFOTYPE的可选值为: 0000,0001,0016,0041
4.函数 BAPI_EMPLOYEE_ENQUEUE 和 BAPI_EMPLOYEE_ENQUEUE 分别用来锁定和解锁员工号. 以保证对员工信息进行更新时的数据一致性.
5. 函数 HR_INFOTYPE_OPERATION 维护员工和申请人的主数据.
在屏幕中操作进行数据维护时系统所做的检查在直接调用该函数时也会进行(包括权限检查,输入有效性等). 并且与屏幕维护时的错误返回结果相同.
参数OPERATION:MOD (change), COPY (copy), DEL (delete), INS (insert), LIS9 (delimit).
参数DIALOG_MOD : 0 在后台执行,出现错误时将错误信息返回到结构体RETURN中
1 在后台执行,出现错误时返回屏幕对话模式
2. 屏幕对话模式.
4.报表程序中的权限检查包括 person authorization 和 data authorization两种.
其中person 的用来检查当前用户是否有对某中信息类型的权限. 而 data的用来限制最终显示数据.
如果不用PNP逻辑数据库,而用SQL语句来完成一些操作的话,需要用函数HR_CHECK_AUTHORITY_INFTY来检查权限.
HR: Master Data object is supplemented by the HR: Reporting authorization object。
例如,管理员要查询所有员工的电话号码,但如果只有HR:Master Data , 则需要每条员工记录都检查一遍是否有权限.
HR:Master Data 这个权限检查对象是由 HR:Reporting做补充的,如果HR:Reporting存在相应的权限设置,则可以让权限检查变的简单一些,从而忽略掉一部分权限检查.
HR:Master Data 和 HR:Reporting 都是Human Resouses Class中的Object. 不明白...这个CLASS名是啥.
5.
INFOTYPES: 2005 MODE N
加上MODE N 后, 在GET PERNR事件后,内表P2005并不与PNP关联而且不填充数据,而是等宏
RP_READ_ALL_TIME_ITY 执行后,才根据时间范围,进行数据填充..
?在GET事件后填充也是根据屏幕选择的时间范围进行数据填充, 用宏填充还是用屏幕选择的PN-BEGDA,PN-ENDDA做范围进行填充,有什么不同么?
在LOOP/ENDLOOP的控制块AT/ENDAT中使用SUM. 则将该组中的数值型字段合计到对应的字段中去.
*&---------------------------------------------------------------------*
*& Report ZTESTALV014
*&
*&---------------------------------------------------------------------*
*&
*&timedata process
*&---------------------------------------------------------------------*
REPORT ztestalv014.
TABLES: pernr.
INFOTYPES: 0001, "Organizational Assignment
2005 MODE n. "Overtime,MODE N 不在GET事件时进行内表填充
TYPES: BEGIN OF overtime,
bukrs LIKE p0001-bukrs,
werks LIKE p0001-werks,
btrtl LIKE p0001-btrtl,
stdaz LIKE p2005-stdaz,
count TYPE p,
END OF overtime.
DATA: ot_tab TYPE TABLE OF overtime WITH HEADER LINE.
DATA: average TYPE p DECIMALS 2,
filled_lines LIKE sy-index.
GET pernr.
rp_provide_from_last p0001 space pn-begda pn-endda.
rp_read_all_time_ity pn-begda pn-endda.
DESCRIBE TABLE p2005 LINES filled_lines.
IF filled_lines GT 0.
MOVE-CORRESPONDING: p0001 TO ot_tab.
ADD 1 TO ot_tab-count.
LOOP AT P2005.
IF p2005-stdaz GT 0.
MOVE-CORRESPONDING: p0001 TO ot_tab.
COLLECT ot_tab. "记数字段COUNT被COLLECT合计
CLEAR ot_tab-count.
ENDIF.
ENDLOOP.
ENDIF.
END-OF-SELECTION.
COLLECT ot_tab.
LOOP AT ot_tab.
AT END OF btrtl. "Personnel subarea
SUM.
PERFORM calculate_average
USING average ot_tab-stdaz ot_tab-count.
FORMAT COLOR COL_GROUP INTENSIFIED OFF.
PERFORM print.
ENDAT.
AT END OF werks. "Personnel area
SUM.
PERFORM calculate_average
USING average ot_tab-stdaz ot_tab-count.
FORMAT COLOR COL_GROUP INTENSIFIED ON.
PERFORM print.
ENDAT.
AT END OF bukrs. "Company code
SUM.
PERFORM calculate_average
USING average ot_tab-stdaz ot_tab-count.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
PERFORM print.
SKIP.
ENDAT.
AT LAST.
SUM.
PERFORM calculate_average
USING average ot_tab-stdaz ot_tab-count.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
PERFORM print.
SKIP.
ENDAT.
ENDLOOP.
*-------------------------------------------------------------*
* FORM PRINT
*-------------------------------------------------------------*
* Print cumulated overtime
*-------------------------------------------------------------*
FORM print.
WRITE: / ot_tab-bukrs,
ot_tab-werks,
ot_tab-btrtl,
ot_tab-count,
ot_tab-stdaz,
average.
ENDFORM.
*-------------------------------------------------------------*
* FORM CALCULATE_AVERAGE
*-------------------------------------------------------------*
FORM calculate_average USING c a b.
c = a / b.
ENDFORM.
*-------------------------------------------------------------*
* If the system language is German, print the data selection period on the page header. In this case, the field SY-LANGU has the value D. To do this, use the macro RP-STICHTAG for a key date or RP-ZEITRAUM for a period at the TOP-OF-PAGE event.
*-------------------------------------------------------------*
TOP-OF-PAGE.
IF SY-LANGU EQ 'D' .
IF pn-begda EQ pn-endda.
rp-stichtag.
ELSE.
rp-zeitraum.
ENDIF.
endif.
6.
1. 有些信息类型的屏幕输入内容在数据库中存成了重复组(repeat field group)的形式.
对于重复结构,用 VARY SPECIFICATION FROM P0041-DAR01 NEXT P0041-DAR02. 来处理.
DATA: BEGIN OF dtype, "Workarea for IT0041
dar LIKE p0041-dar01,
dat LIKE p0041-dat01,
END OF dtype.
DO 12 TIMES VARYING dtype FROM p0041-dar01
NEXT p0041-dar02.
* p0041中dar01和dat01为重复结构,共12个,dar02,dat02.......
IF dtype-dar IS INITIAL.
EXIT.
ELSE.
IF dtype-dar IN datetype.
rp_provide_from_last p0001 space pn-begda pn-endda
CLEAR data_tab_wa.
MOVE-CORRESPONDING p0001 TO data_tab_wa.
MOVE-CORRESPONDING dtype TO data_tab_wa.
PERFORM read_hiredate.
PERFORM re548t USING sy-langu dtype-dar.
MOVE t548t-dtext TO data_tab_wa-dtext.
APPEND data_tab_wa TO data_tab.
ENDIF.
ENDIF.
ENDDO.
类似的可以用 WHILE CONDITIONS VARYING dtype FROM p0041-dar01
NEXT p0041-dar02.
ENDWHILE.
把0041中的日期类型都拿出来循环一遍(每行12个),看有没有能跟屏幕中的匹配的,然后再把匹配的日期类型拿去跟表re548t查询..
7.
PCL1 Database for HR workarea
PCL2 Acounting result (Time,trip cost,payroll)
PCL3 Recruitment data
PCL4 Documents
PCL5 Personel Cost planning
Database table PCL1 contains the following data areas:
B1 Time events/PDC
G1 Group incentive wages
L1 Individual incentive wages
PC Personal calendar
TE Trip costs/accounting results
TC Trip costs/credit card data
TX Infotype texts
Z1 Interface PDC -> cost accounting/materials management
Database table PCL2 contains the following data areas:
B2 Time accounting results
CU Cluster directory
PS Generated schema
PT Texts for generated schemas
RX Payroll results/international
Xy Payroll results/country-specific, whereby xy represents the relation ID. This either
consists of Rn (n = HR country indicator), or of the ISO code from table T500L.
ZL Personal work schedule