Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Identifying Superior Org Units In Adhoc Reporting
1. Identifying Superior Org Units in Adhoc reporting.
How do you report on a superior organisational unit against a position that represents a group
or division within your organisation?
The scenario.
O Company ABC Limited
O Division Corporate Services
O Group Sales and Marketing
O Department Sales
O Team Administration
S Position Administrator
P Person Fred Jones
In your Adhoc report you want to show Fred Jones works for the Sales and Marketing Group.
There are many methods how this can be achieved. Cost centre ranges for example can help
determine which group or division an employee works for or perhaps introducing the org unit
ID field with a unique naming convention.
Here is another solution you may want to consider together with your technical team.
First identify an org unit as a group within the organisation.
This can be achieved by creating a new subtype under infotype 1002 (Description) via Table
V_778U. In this example subtype 9991 was created with a subtype text of “Group”
Assign the new subtype against the org unit via transaction PO10.
Next create a customised field against the infoset you use for your Adhoc queries.
In transaction SQ02 select the infoset to be maintained.
Assuming your infoset is based on the logical database PNPCE, select the Organizational
Assignment P0001 folder then click the “extras” icon.
Create an additional field “Group” with the following characteristics:
Type C Lngth 025 OutputLength 025 Decimals
Copy and paste the following code to this additional field:
data: notfound(1), sobids like hrp1001-sobid, sobidm like
hrp1001-sobid, sobida like hrp1001-sobid, psobid like
hrp1001-sobid, stexta like hrp1000-stext.
clear: group, sobids, sobidm, sobida, psobid, stexta.
notfound = 'T'.
* get the organisation unit of the employee
select single sobid from hrp1001
into sobida
where otype = 'S'
and objid = p0001-plans
and plvar = '01'
and endda between sy-datum and '99991231'
and subty = 'A003'
and sclas = 'O'.
* check if this org unit has group marker
perform checkifgroup using sobida changing psobid.
* if it does, get the group name
if sy-subrc = 0 and psobid = '9991'.
perform getgroupname using sobida changing stexta.
group = stexta.
* otherwise keep sobida because sobids can change when going into the
* loop
else.
sobids = sobida.
2. * enter the loop to find the org units above the currently selected
* one going up the hierarchy until one is found with the group marker
* or terminate the loop if none is found
while notfound = 'T'.
clear: sobidm, psobid, stexta.
perform getsuperior using sobids changing sobidm.
* check if the new org unit in sobidm has a record in hrp1002
if sy-subrc = 0.
perform checkifgroup using sobidm changing psobid.
* if there is a record
if sy-subrc = 0.
* and it has a group marker
if psobid = '9991'.
* get the name of the group and stop looping
perform getgroupname using sobidm changing stexta.
group = stexta.
notfound = 'F'.
* if no group marker is found continue with the next loop
else.
sobids = sobidm.
continue.
endif.
* if no record found in hrp1002, go up to the next org unit in the
* hierarchy using the currently selected org unit as the input to
* the loop
else.
sobids = sobidm.
continue.
endif.
* if no higher org unit is found, assign 'No group marker found'
* and stop looping
else.
group = 'No group marker found'.
notfound = 'F'.
endif.
endwhile.
endif.
Copy and paste the following code to the free coding section:
form getsuperior using qobjid changing qsobid.
select single sobid from hrp1001
into qsobid
where otype = 'O'
and objid = qobjid
and plvar = '01'
and rsign = 'A'
and relat = '002'
and endda = '99991231'
and sclas = 'O'.
endform.
form checkifgroup using pobjid changing psobid.
select single SUBTY from HRP1002
into psobid
where plvar = '01'
and otype = 'O'
and objid = pobjid
and endda = '99991231'.
endform.
form getgroupname using sobida changing stexta.
select single stext from hrp1000
into stexta
where plvar = '01'
and otype = 'O'
and objid = sobida
and endda = '99991231'.
endform.
Next drag the new field found under “Additional fields” to the Field Group/data fields folder
and generate the infoset.
3. The above code will then populate the additional field with the name of the org unit identified
as a group in your query. If no org unit representing a group is found the field is populated
with the text 'No group marker found'.