0% found this document useful (0 votes)
23 views

Get Manager Org

This document contains a summary of 3 sentences: The document summarizes code for extracting employee and organizational data from a database table into an interface table, including retrieving employee manager, substitute, and payroll substitution relationships from the database. The code opens a cursor on the database table, fetches records in packages into an interface table, and enhances the records with related employee attributes from additional queries. It then returns the interface table containing the extracted employee data with the associated relationship attributes.

Uploaded by

klasskovskaya.n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Get Manager Org

This document contains a summary of 3 sentences: The document summarizes code for extracting employee and organizational data from a database table into an interface table, including retrieving employee manager, substitute, and payroll substitution relationships from the database. The code opens a cursor on the database table, fetches records in packages into an interface table, and enhances the records with related employee attributes from additional queries. It then returns the interface table containing the extracted employee data with the associated relationship attributes.

Uploaded by

klasskovskaya.n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Example: DataSource for table ZMANAGER_ORG_ATTR

TABLES: HRP1001.

* Auxiliary Selection criteria structure


DATA: L_S_SELECT TYPE SRSC_S_SELECT.

* Maximum number of lines for DB table


STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,

* counter
S_COUNTER_DATAPAKID LIKE SY-TABIX,

* cursor
S_CURSOR TYPE CURSOR.
* Select ranges
RANGES: L_R_OBJID FOR HRP1001-OBJID.

* Initialization mode (first call by SAPI) or data transfer mode


* (following calls) ?
IF I_INITFLAG = SBIWA_C_FLAG_ON.

************************************************************************
* Initialization: check input parameters
* buffer input parameters
* prepare data selection
************************************************************************

* Check DataSource validity


CASE I_DSOURCE.
WHEN 'ZMANAGER_ORG_ATTR'.
WHEN OTHERS.
IF 1 = 2. MESSAGE E009(R3). ENDIF.
* this is a typical log call. Please write every error message like this
LOG_WRITE 'E' "message type
'R3' "message class
'009' "message number
I_DSOURCE "message variable 1
' '. "message variable 2
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.

APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.

* Fill parameter buffer for data extraction calls


S_S_IF-REQUNR = I_REQUNR.
S_S_IF-DSOURCE = I_DSOURCE.
S_S_IF-MAXSIZE = I_MAXSIZE.

* Fill field list table for an optimized select statement


* (in case that there is no 1:1 relation between InfoSource fields
* and database table fields this may be far from beeing trivial)
APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.

ELSE. "Initialization mode or data extraction ?

************************************************************************
* Data transfer: First Call OPEN CURSOR + FETCH
* Following Calls FETCH only
************************************************************************
* First data package -> OPEN CURSOR
IF S_COUNTER_DATAPAKID = 0.
*
* Fill range tables BW will only pass down simple selection criteria
* of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'OBJID'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_OBJID.
APPEND L_R_OBJID.
ENDLOOP.

* Determine number of database records to be read per FETCH statement


* from input parameter I_MAXSIZE. If there is a one to one relation
* between DataSource table lines and database entries, this is trivial.
* In other cases, it may be impossible and some estimated value has to
* be determined.
*
*
* Get all employees with manager relation.
*
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT (S_S_IF-T_FIELDS) FROM HRP1001
WHERE OBJID IN L_R_OBJID
AND RSIGN = 'A'
AND RELAT = '012' " Manager
AND PLVAR = '01'
AND endda >= sy-datum
AND begda <= sy-datum.

ENDIF. "First data package ?

* Fetch records into interface table.


* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS
OF TABLE e_t_data
PACKAGE SIZE S_S_IF-MAXSIZE.
*
* Add employee number on internal table.
*
loop at e_t_data.
select single objid begda endda
from hrp1001
into
(l_s_data-uname, l_s_data-begda, l_s_data-endda)
where
sobid = e_t_data-objid and
relat = '008' and
otype = 'P' and
endda >= sy-datum and
begda <= sy-datum.

if sy-subrc NE 0.
delete e_t_data.
else.
e_t_data-rsign = 'M'. " Manager
e_t_data-uname = l_s_data-uname.
* e_t_data-begda = l_s_data-begda.
* e_t_data-endda = l_s_data-endda.
modify e_t_data.
endif.

endloop.

*
l_t_data[] = e_t_data[].
*
*
* Get all employees with substitute relation
*
loop at l_t_data into l_s_data.
*
clear lt_sub_pos.
refresh lt_sub_pos.
*
select sobid begda endda
from hrp1001
appending table lt_sub_pos
where
rsign = 'B' and
relat = 'Z01' and " Substitut
objid = l_s_data-objid and
endda >= sy-datum and
begda <= sy-datum.
*
loop at lt_sub_pos into ls_sub_pos.
select single objid
* begda endda
from hrp1001
into
* (l_s_data-uname, l_s_data-begda, l_s_data-endda)
l_s_data-uname
where
sobid = ls_sub_pos-position and
relat = '008' and
otype = 'P' and
endda >= sy-datum and
begda <= sy-datum.
if sy-subrc = 0.

l_s_data-begda = ls_sub_pos-begda.
l_s_data-endda = ls_sub_pos-endda.
l_s_data-rsign = 'S'. " Substitute
append l_s_data to e_t_data.
endif.
endloop.
endloop.

* Get employees with payroll substitution relation Z03 - xcras 27102011


loop at l_t_data into l_s_data.
*
clear lt_sub_pos.
refresh lt_sub_pos.
*
select sobid begda endda
from hrp1001
appending table lt_sub_pos
where
rsign = 'B' and
relat = 'Z03' and " Payroll
Substitut
objid = l_s_data-objid and
endda >= sy-datum and
begda <= sy-datum.
*
loop at lt_sub_pos into ls_sub_pos.
select single objid
* begda endda
from hrp1001
into
* (l_s_data-uname, l_s_data-begda, l_s_data-endda)
l_s_data-uname
where
sobid = ls_sub_pos-position and
relat = '008' and
otype = 'P' and
endda >= sy-datum and
begda <= sy-datum.
if sy-subrc = 0.

*
l_s_data-begda = ls_sub_pos-begda.
l_s_data-endda = ls_sub_pos-endda.
l_s_data-rsign = 'P'. " Substitute
append l_s_data to e_t_data.
endif.
endloop.
endloop.

* Enhancement for payroll substitution - ends here

IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.

S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

ENDIF. "Initialization mode or data extraction ?

ENDFUNCTION.

You might also like