`
touchinsert
  • 浏览: 1329692 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

HR--Copy of fetching HR data in different ways

 
阅读更多

There are 3 methods in fetching the data from HR database tables .

1.using select statements .

This is the simple method for the selection of data from the hr tables(pannnn). in the HR data time is the major component , in the where condition we should include the date parameters for fetching the data .see this simple example to understand REPORT ZHRTESTS.
tables:pa0002 .
data:begin of itab occurs 0,
pernr like pa0002-pernr,
begda like pa0002-begda,
endda like pa0002-endda,
vorna like pa0002-vorna,
nachn like pa0002-nachn,
end of itab .
select-options:s_pernr for pa0002-pernr ,
s_date for sy-datum.
start-of-selection .
select pernr
begda
endda
vorna
nachn
from pa0002
into table itab
where pernr in s_pernr
and begda le s_date-high
and endda ge s_date-low.
if not itab[] is initial.
loop at itab .
write:/ itab-pernr,
itab-begda,
itab-endda,
itab-vorna,
itab-nachn .
endloop.
endif.
2.using Different function modules..
1. using function module hr_read_infotype

This function module is used for fetching the data from Personnel Administration and Time management info types . This is used to get a single PERNR from the Info type .see the below example....

REPORT ZHRTESTS.
tables:pa0002 .
data: itab type p0002 occurs 0 with header line .
select-options:s_pernr for pa0002-pernr no intervals no-extension,
s_date for sy-datum.

start-of-selection .

CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
TCLAS = 'A'
pernr = s_pernr-low
infty = '0002'
BEGDA = s_date-low
ENDDA = s_date-high
TABLES
infty_tab = itab.
if not itab[] is initial.
loop at itab .
write:/ itab-pernr,
itab-begda,
itab-endda,
itab-vorna,
itab-nachn .
endloop.
endif.
2. Using function module rh_read_infty

This is used for the organization management info types. With this function module we can get the relations for the given object ( means we can get position for a pernr , organization for a position , organization for an organization....)report ygetsupervisor.
*&---------------------------------------------------------------------*
* database tables used
*&---------------------------------------------------------------------*
tables:pa0001,
hrp1001,
pa0002.
*&---------------------------------------------------------------------*
* internal tables declaration
*&---------------------------------------------------------------------*
data: t1001 like p1001 occurs 0 with header line,
t1002 like p1001 occurs 0 with header line,
t1003 like p1001 occurs 0 with header line,
t1004 like p1001 occurs 0 with header line,
t0001 like p0001 occurs 0 with header line,
it_pa0002 type pa0002 occurs 0 with header line.
*&---------------------------------------------------------------------*
* variable declaration
*&---------------------------------------------------------------------*
data: v_sobid1 like p1001-objid,
v_sobid2 like p1001-objid,
v_sobid3 like p1001-objid,
v_pernr like pa0002-pernr.
*&---------------------------------------------------------------------*
* selection screen paramters
*&---------------------------------------------------------------------*
parameters :pernr like pa0001-pernr.
*&---------------------------------------------------------------------*
* start of selection
*&---------------------------------------------------------------------*
start-of-selection.
call function 'RH_READ_INFTY'
exporting
plvar = '01'
otype = 'P'
objid = pernr
infty = '1001'
subty = 'B008'
begda = sy-datum
endda = sy-datum
tables
innnn = t1001 .
sort t1001 by begda descending .
read table t1001 with key objid = pernr
otype = 'P'
rsign = 'B'
relat = '008'
sclas = 'S'.
if sy-subrc = 0.
v_sobid1 = t1001-sobid.
call function 'RH_READ_INFTY'
exporting
plvar = '01'
otype = 'S'
objid = v_sobid1
infty = '1001'
subty = 'A003'
begda = sy-datum
endda = sy-datum
tables
innnn = t1002 .
endif.
sort t1002 by begda descending .
read table t1002 with key objid = v_sobid1
otype = 'S'
rsign = 'A'
relat = '003'
sclas = 'O'.
if sy-subrc = 0.
v_sobid2 = t1002-sobid.
call function 'RH_READ_INFTY'
exporting
plvar = '01'
otype = 'O'
objid = v_sobid2
infty = '1001'
subty = 'B012'
begda = sy-datum
endda = sy-datum
tables
innnn = t1003 .
endif.
sort t1003 by objid.
read table t1003 with key objid = v_sobid2
otype = 'O'
rsign = 'B'
relat = '012'
sclas = 'S'.
if sy-subrc = 0.
v_sobid3 = t1003-sobid.
call function 'RH_READ_INFTY'
exporting
plvar = '01'
otype = 'S'
objid = v_sobid3
infty = '1001'
subty = 'A008'
begda = sy-datum
endda = sy-datum
tables
innnn = t1004 .
endif.
read table t1004 with key objid = v_sobid3
otype = 'S'
rsign = 'A'
relat = '008'
sclas = 'P'.
if sy-subrc = 0.
v_pernr = t1004-sobid+0(8).
select pernr
vorna
nachn
cname
from pa0002
into corresponding fields of table it_pa0002
where pernr = v_pernr.
sort it_pa0002 by pernr begda.
read table it_pa0002 index 1.
if sy-subrc eq 0.
write:/ it_pa0002-pernr,it_pa0002-vorna,it_pa0002-nachn,it_pa0002-cname.
endif.
endif.
3. Using function module rh_struc_get
This is used to get the higher organization unit for the given personnel no. this is easier way for getting the highest org unit for a given pesonnel no or for a given org.unit ..REPORT ZHRTESTS.
PARAMETERS: OBJID TYPE OBJID.
DATA:RESULT_OBJEC TYPE OBJEC OCCURS 0 WITH HEADER LINE ,
RESULT_OBJEC1 TYPE OBJEC OCCURS 0 WITH HEADER LINE ,
V_OBJID1 TYPE OBJID .
*---here we will get the organization unit for the given pesonnel number.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'P'
act_objid = objid
act_wegid = 'P-S-O' " person-position-orgunit
TABLES
RESULT_OBJEC = RESULT_OBJEC.
LOOP AT RESULT_OBJEC WHERE OTYPE = 'O'.

*--- loop the orgunits only to get the higher orgunits
V_OBJID1 = RESULT_OBJEC-OBJID.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'O'
act_objid = V_OBJID1
act_wegid = 'O-O'
TABLES
RESULT_OBJEC = RESULT_OBJEC1 .
LOOP AT RESULT_OBJEC1.
ENDLOOP.
*----this is the highest orgunit for the Personnel number
WRITE:/ RESULT_OBJEC1-OBJID.
ENDLOOP.
3. using logical databases(macros)

Here i am using the PNP logical database for this example . And I am using the macros for getting the data from the databases .

REPORT ZHRTESTS.
TABLES: PERNR.
INFOTYPES: 0002.
GET PERNR.
*---get the first record for the pernr from the infotype
RP_PROVIDE_FROM_FRST P0002 SPACE PN-BEGDA PN-ENDDA .
IF PNP-SW-FOUND eq 1.
WRITE: / PERNR-PERNR,
PN-BEGDA,
PN-ENDDA,
P0002-VORNA,
P0002-NACHN,
P0002-GBDAT.
ENDIF.
*---get the last record for the pernr from the infotype
RP_PROVIDE_FROM_LAST P0002 SPACE PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND eq 1.
WRITE: / PERNR-PERNR,
PN-BEGDA,
PN-ENDDA,
P0002-VORNA,
P0002-NACHN,
P0002-GBDAT.
ENDIF.

Source link:http://wiki.sdn.sap.com/wiki/display/Snippets/Copy+of+fetching+hr+data+in+different+ways

分享到:
评论

相关推荐

    Learning GraphQL: Declarative Data Fetching for Modern Web Apps

    Why is GraphQL the most innovative technology for fetching data since Ajax? By providing a query language for your APIs and a runtime for fulfilling queries with your data, GraphQL presents a clear ...

    react-data-fetching:React用于React的声明式数据获取

    react-data-fetching通过单个React组件提供了一种非常直观的方式来轻松执行任何REST API调用。 它还可以帮助您解决超时,加载状态,错误处理,数据保存,上载/下载进度等问题。在让用户知道发生了什么的同时获取...

    Fetching-Data-Group-Project

    "Fetching-Data-Group-Project" 这个项目的核心是关于数据获取,它可能是团队协作完成的一个实战项目,旨在提升参与者的数据抓取、处理和分析能力。在这个项目中,我们可能会涉及以下几个重要的IT知识点: 1. **...

    pkg-cache(v2.6).zip

    node10-win-x64> Fetching base Node.js binaries to PKG_CACHE_PATH fetched-v10.17.0-win-x64 [ ] 0%> Error! getaddrinfo ENOENT github-production-release-asset-2e65be.s3.amazonaws....

    Unidac v6.1.6 pro for Delphi 7, XE5-XE8

    - 'Catastrophic failure' on data fetching is fixed PostgreSQL data provider - Bug with storing BYTEA fields when UnpreparedExecute=True is fixed - Bug in TUniLoader.LoadFromDataSet is fixed SQLite...

    Python Web Scraping Second Edition - Fetching Data From The Web

    ### Python Web Scraping 第二版 —— 从网络获取数据 #### 书籍概述与目标读者 《Python Web Scraping 第二版》是一本专为熟悉Python编程语言的程序员、安全专家以及网站管理员编写的实用指南。...

    nextjs-data-fetching:nextjs数据获取

    这是一个用引导的项目。入门首先,运行开发服务器: npm run dev# oryarn dev 用浏览器打开以查看结果。 您可以通过修改pages/index.js来开始编辑页面。 页面在您编辑文件时自动更新。 可以在上访问。...

    Beginning GraphQL - Fetch data faster and more ...

    Over-fetching and under-fetching data can negatively impact the performance of your web application. Future-proof your API structure and handle key development requirements by correctly defining types...

    04-data-fetching

    "04-data-fetching"这一主题主要聚焦于JavaScript中的数据获取技术,特别是在现代Web开发中的应用。JavaScript是一种广泛使用的客户端脚本语言,用于实现与用户的交互以及动态更新网页内容。在本主题中,我们将深入...

    xenbackup:通过标签将 xenserver vm 通过 XAPI 备份到备份 SR

    Fetching VM and SR data from pool. -------------------------------------------------------------------------------- Snapshotting all VM's with tag: 'testing_backups' --------------

    node-v14.20.0-win-x64.7z

    Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行时

    Beginning PHP 5.3

    - **String Literals:** Explanation of different ways to define strings in PHP, including single quotes, double quotes, and heredoc syntax. - **String Functions:** Overview of common string functions, ...

    C Programming

    - **Types of Data in Expressions**: Explanation of the rules for combining different data types in expressions. - **Getting Values into the Program**: Discussion on how to read values from external ...

    dkftpbench-0.45.tar.gz

    -t15 length of run (in seconds) -b3600 desired bandwidth (in bytes per second) -uanonymous user name -probouser@ user password -fusenet/rec.juggling/juggling.FAQ.Z file to fetch -m1500 bytes per...

    Mastering Data Analysis with R(PACKT,2015)

    Beginning with taking you through essential data mining and management tasks such as munging, fetching, cleaning, and restructuring, the book then explores different model designs and the core ...

    nextjs-prerender-datafetching

    这是一个用引导的项目。 入门 首先,运行开发服务器: npm run dev # or yarn dev 用浏览器打开以查看结果。 您可以通过修改pages/index.js来开始编辑页面。 页面在您编辑文件时自动更新。... 可以在pages/api/hello...

    filecoin-proof-parameters1.tar.gz

    filecoin-proof-parameters ,不包含复制证明参数数据,lotus daemon , 运行需要的依赖数据,拷贝到/var/tmp/filecoin-proof-parameters目录下解压

    Mastering.Core.Data.With.Swift.2017

    By the end of this book, you will have a solid grasp of Core Data's capabilities and be able to implement it effectively in your iOS applications. Whether you're a beginner looking to dive into Core ...

    Random-unsplash-photo-fetching

    图片2 该项目是使用版本11.1.0生成的。开发服务器为开发服务器运行ng serve 。... 如果您更改任何源文件,该应用程序将自动重新加载。代码脚手架运行ng generate component component-name生成一个新的组件。...

Global site tag (gtag.js) - Google Analytics