You are on page 1of 16

http://scn.sap.com/thread/802672 http://scn.sap.com/thread/544613 http://www.eappdev.

com/sap-hr-abap/organizational-management/function-modules-in-ommodule

Function Modules in OM Module

RH_GET_LEADING_POSITION To fetch the manager's position. Say, for Org unit 10010027, it has the three reporting(lower-B002) org units 10010028, 10010029 and 10010030. This FM fetches the manager of org unit 10010027 as the manager of the rest three as well. Though if I use the F/M 'HRCM_ORGUNIT_MANAGER_GET', the manager is fetched only for the top org unit 10010027 and no manager for the lower org units which don't have a leading position of their own. HRCM_ORGUNIT_MANAGER_GET To get manager for a given Org unit. RH_RELATION_MAINTAIN To maintain relationship in OM module e.g to asign the employee to a new position.

RH_GET_MANAGER_ASSIGNMENT gets list of org units managed by user. RH_GET_VACANCY Always use this F/M to determine whether a position is vacant. (Source of this info : F1 on T77S0 Switch PPVAC-PPVAC Switch for defining a vacancy) RH_INSERT_INFTY inserts multiple records for OM objects into PP databases.(FCODE, VTASK) RH_DELETE_INFTY inserts multiple records for OM objects from PP databases.(VTASK) (the individual parameter values VTASK update type have the following meanings :D Update in dialog; S Synchronous update via update task; V Asynchronous update via update task; B update internal in buffer

only and no DB update.)

In HR applications, the parameter is set to 'D' for update in dialog. However, if you want an internal buffer update first of multiple operations that are logically connected and should be written to the daabase together, you should set the parameter to 'B' for internal buffer update only. The database update is then carried out by calling FM 'RH_UPDATE_DATABASE'.

RH_UPDATE_DATABASE

updates the Personnel Planning databases with Insert, Change, and Delete operations for infotype records carried out internally in the buffer with the function modules 'RH_INSERT_INFTY', 'RH_UPDATE_INFTY' and 'RH_DELETE_INFTY' (that is, with VTASK = 'B').
RH_CUT_INFTY to delimit an OM infotype RH_STRUC_GET for a given object / Evn path, returns a table with OTYPE & OBJID.

RP_PNP_ORGSTRUCTURE displays a pop-up with Org Hierarchy to choose Org Units from in a ranges table. (AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_orgeh-low.)

RH_OBJID_REQUEST implements the standard value help for Personnel Planning objects.The module first attempts to display the value help type (search function, structure search, standard matchcode and unrelated objects) that was last selected for this object type. If nothing was selected, a dialog box is displayed in which you can select the type of value help you require. (AT SELECTION-SCREEN ON VALUEREQUEST FOR postn-low.) Structure DYNPREAD holds fields of the current screen with values (from PP01).

RH_READ_OBJECT returns the text and validity of an object. To read more than one object, we

recommend that you use RH_READ_OBJECT_SET, which allows mass access.

RH_OBJECT_CREATE creates an OM object. RH_READ_INFTY_NNNN Read Infotype > 1001 for Object Set. It returns the associated infotype records for a set quantity of OM objects to a predefined infotype. Infotypes '1000' and '1001' are not supported as they are single infotypes. RH_READ_INFTY_1001

to read relationships between objects from Relationship table HRP1001. RH_BASE_AUTHORITY_CHECK A not released function module from Function group RHAC, checks the basic authorizations in OM. RH_STRU_AUTHORITY_CHECK validates structural authorization from tables T77UA and T77PR. RH_STRUC_GET_MULTIPLE_ROOTS
from Function group RH_STRUCTURE_GET, for getting organization hierarchy. RH_OM_ATTRIBUTES_READ to read the attribute value of an OM Object, say Org unit (is it Sales Office?). Can check the use of this FM in standard report RHGENERATE_ATTRIB_INDEX or an example program. RH_GET_ACTIVE_WF_PLVAR to get the active Plan Version in OM. Check usage in standard report RHGENERATE_ATTRIB_INDEX.

Payroll results can be extracted using the following methods:

If there is a need to do processing at individual steps:

1) Read cluster directory using CU_READ_RGDIR 2) Read valid period from cluster directory using CU_READ_LAST 3) Read payroll results using PYXX_READ_PAYROLL_RESULTusing SEQNO returned by CU_READ_LAST. Otherwise: 1)Using function module PYXX_GET_EVALUATION_PERIODSor 2)Using function module HR_GET_PAYROLL_RESULTSto import current payroll results.

Lets discuss first solution for country PL (where I am from;) )

First you need to define country specific data object:

DATA:it_pay_result TYPE pay<b>pl</b>_result.

pay<b>pl</b>_result is the country specific payroll result type for Poland: For different country use its abbreveation i.e. for NL - paynl_result etc.

Then define such structure: DATA: BEGIN OF it_rgdir OCCURS 0. INCLUDE STRUCTURE pc261. DATA: END OF it_rgdir.

This one is to retrieve payroll clusters. Now let's read the cluster for an employee.

CALL FUNCTION 'CU_READ_RGDIR' EXPORTING persnr = here you put personnel number

IMPORTING molga TABLES in_rgdir = it_rgdir = molga

EXCEPTIONS no_record_found = 1 OTHERS = 2.

Now when we have <b>all</b>clusters taken for particular employee lets read all tables for one each payroll period. Note! For each payroll period i.e. 07.2007 we have lots of tables to process, they keep differnet data. In it_rgdir we have clusters for all payroll periods which were run for this employee. Lest iterate thru them (alternatively we could just use FM 'CU_READ_LAST' to read the latest payroll run)

LOOP AT it_rgdir WHERE paydt BETWEEN start_date AND end_date. CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT' EXPORTING clusterid employeenumber sequencenumber = 'PL' "here put either NL, BE - your country abrev.

= pernr = it_rgdir-seqnr

CHANGING payroll_result EXCEPTIONS illegal_isocode_or_clusterid = 1 error_generating_import import_mismatch_error subpool_dir_full no_read_authority no_record_found versions_do_not_match OTHERS endloop. = 8. =4 =5 =6 =7 =2 =3 = it_pay_result

Now you have deep structure which contains payroll result for polish employee for all payroll periods. Using 'CU_READ_LAST' you would have only last one.

If you have more doubts see this document:


-------------------------------------------------===============================================================

Macros:

Introduction

Programs that process the cluster data (for example, RX) do not access the cluster independently. The data is accessed using a defined interface created with macros.

Macro contains some part of source code which it will be useful for number of applications. Macro is module which is stored

Naming Conventions of Macro: RP-aaa-bb-cc

o o

aaa is the type of Macro. It takes two values IMP Import Macro EXP Export Macro

o o o o o o o

bb is the Database table where the data is saved: C1 Database object PCL1 C2 Database object PCL2 C3 Database object PCL3 C4 Database object PCL4 Cc is the cluster, it may take RX Cluster object RX RD Cluster object RD B2 Cluster object B2 and so on.

Defining and Calling the Macros

Defining:

There are two options for defining the Macros

Macros are defined using the ABAP Commands DEFINE.END-OF-DEFINITION. A macro can be used within a report or within include. If a macro is used in a report, and the macro is defined in include with the DEFINE command, include must be integrated.

Macros can also be defined as RMAC macros. The source code of these modules is stored in the function section of the control table TRMAC. The coding is grouped under a specific name in the table key. According to conventions, the first two letters of the name must stand for the application. The rest of the name is freely definable.

Difference between the two methods is:

If a macro is changed, each report using this macro is automatically regenerated when it is executed.

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.

Standard HR Macros

o The macro RP-PROVIDE-FROM-FRST retrieves the first(start) data record which is valid in the data selection period. o The macro RP-PROVIDE-FROM-LAST retrieves the last(latest) data record which is valid in the data selection period. o The macro RP-READ-INFOTYPE retrieves the data record(s) which is valid in the data selection period.

How to check whether the macro operation is successful or not

For every macro, whether the operation was successful or not will be checked with PNP-SW-FOUND.

If PNP-SW-FOUND = 1, then the operation is successful.

Where exactly the Macro code is stored

The program code pertaining to this macro is stored in the control table RMAC

Guidelines for how and when to use the Standard Macros o RP_PROVIDE_FROM_FRST

Use macro RP_PROVIDE_FROM_FRST in programs for the logical databases PNP and PAP where the first data record for a period (can be a subtype) is read from an infotype table. The infotype table has been filled earlier (for example, with GET PERNR or RP_READ_INFOTYPE). This macro is only helpful if the infotype has time constraint 1 or 2. Prerequisites

The validity begin date of the time period must be before or the same as the validity end date. Validity start and end dates are correct (preferably of the type DATE).

The infotype table is sorted in ascending order. Otherwise, you would receive the first fitting table entry that might not necessarily correspond to the first time entry. Features The first entry for a specified period is placed in the table header entry from an internal infotype table. Parameters RP_PROVIDE_FROM_FRST inftytab subty beg end IN : 2) 3) 4) 1) Name of the internal table

Subtype required or SPACE if no subtype is being specified Validity start date of the time interval Validity end date of the time interval

OUT: 1) PNP-SW-FOUND: has the value 0 if there is no matching entry in the infotype table in the given time period. Otherwise it has the value 1. 2) The matching table header entry if PNP-SW-FOUND = 1 or

the initial table header entry if PNP-SW-FOUND = 0 Example (RP_PROVIDE_FROM_FRST inftytab subty beg end) RP_PROVIDE_FROM_FIRST P0021 '1' PN-BEGDA PN-ENDDA. IF PNP-SW-FOUND EQ '1'. ... ENDIF. or

RP_PROVIDE_FROM_FRST P0001 SPACE PN-BEGDA PN-ENDDA. IF PNP-SW-FOUND EQ '0'. WRITE: / 'Error: Org. assignment is missing' REJECT. ENDIF.

RP_PROVIDE_FROM_LAST

You use macro RP_PROVIDE_FROM_LAST in programs for the logical databases PNP and PAP where the last data record for a period (can be a subtype) is read from an infotype table. The infotype table has been filled earlier (for example, with GET PERNR or RP_READ_INFOTYPE). This macro is only helpful if the infotype (or subtype) has time constraint 1 or 2. Prerequisites The validity begin date of the time period must be before or the same as the validity end date. Validity start and end dates are correct (preferably of the type DATE).

The infotype table is sorted in ascending order. Otherwise, you would receive the last fitting table entry that might not necessarily correspond to the last time entry. Features The macro RP_PROVIDE_FROM_LAST makes sure that the last entry for a specified period is placed in the table header entry of the report output list. Parameters RP_PROVIDE_FROM_LAST inftytab subty beg end IN : 1) Name of the internal table

2) Subtype required or SPACE if no subtype is being specified 3) Validity begin date of the time interval 4) Validity end date of the time interval

OUT: 1) PNP-SW-FOUND: has the value 0 if there is no matching entry in the infotype table in the given time period. Otherwise it has the value 1. 2) The matching table header entry if PNP-SW-FOUND = 1 or the cleared table header entry if PNP-SW-FOUND = 0 Example: RP_PROVIDE_FROM_LAST P0021 '1' PN-BEGDA PN-ENDDA. IF PNP-SW-FOUND EQ '1'. ... ENDIF. OR

RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. IF PNP-SW-FOUND EQ '0'. WRITE: / 'Error: Org. assignment is missing'. REJECT. ENDIF. RP_READ_INFOTYPE

You can use the macro in all programs at any point. You can also use it in function modules. In database PNP, an infotype is usually read with GET PERNR. Using macro RP_READ_INFOTYPE is an exception. You can also use the function module HR_READ_INFOTYPE. For information on how to use the function module, see the documentation on Function Modules. Prerequisites The validity begin date of the time period must be before or the same as the validity end date. Validity begin and end are correct date specifications (preferably of the type DATE). The infotype table must match the infotype number.

The program using the macro must contain the include DBPNPMAC.

Features The macro RP_READ_INFOTYPE makes sure that all data records for a person for the specified period are placed in an internal infotype table. Parameters RP_READ_INFOTYPE pernr infty inftytab beg end IN : 2) 3) 4) 5) OUT: 1) Personnel number of the person requested

Infotype number of the required infotype Name of the internal infotype table Validity start date of the time interval Validity end date of the time interval 1) PNP-SW-FOUND = 0, if there is no matching record in the dataset

PNP-SW-FOUND = 1, if there is no matching record in the dataset 2) PNP-SW-AUTH-SKIPPED-RECORD = 0, if the HR authorization check has not retained any records due to incorrect authorizations. PNP-SW-AUTH-SKIPPED-RECORD = 1 , if the HR authorization check has retained at least one record due to lack of authorization 3) Internal infotype table, containing all matching records for which the user is authorized (this table can also be empty). Example (RP_READ_INFOTYPE pernr infty inftytab beg end) INFOTYPES: 0001. RP-LOWDATE-HIGHDATE. DATA: PERNR LIKE P0001-PERNR. DATA: BEGDA LIKE P0001-BEGDA, ENDDA LIKE P0001-ENDDA.

PERNR = '12345678'. BEGDA = LOW-DATE + 15 ENDDA = HIGH-DATE - 5. RP-READ-INFOTYPE PERNR 0001 P0001 BEGDA ENDDA. IF PNP-SW-AUT-SKIPPED-RECORD EQ '1'. WRITE: / 'Insufficient authorization'. STOP. ENDIF. IF PNP-SW-FOUND EQ '0'. WRITE: / 'Infotype 0001 missing'. STOP. ENDIF. ===================================================================== ======

before you can use it ABAP macro requires you to define it in the program ( or one of its includes) or in table TRMAC. In the macro definition you can use tables, files etc. e. g. for macro AA-BB-DD-XX you should code in the program ( or one of its includes):

DEFINE AA-BB-DD-XX.

LOOP AT ITAB. .....................

MOVE-CORRESPONDING ITAB TO ITAB2. ITAB2-FIELD1 = 8. APPEND ITAB2. " or write or upload etc.

ENDLOOP. END-OF-DEFINITION.

Macro contains some part of source code which it will be useful for number of applications.( Like function modules ). It already holds the data.. you can not doo may modification to that.. by using the begin date and end date you can do filter the records..

Generally we use two macros in HR ABAP 1. RP-PROVIDE-FROM-LAST 2. RP-PROVIDE-FROM-FRST

The macro RP-PROVIDE-FROM-LAST retrieves the last(latest) data record which is valid in the data selection period. The macro RP-PROVIDE-FROM-FRST retrieves the first(start)data record which is valid in the data selection period.

Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs

Ex : Tables : PERNR. INFOTYPES : 0001,0002. Start-of-selection. Get PERNR. RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. Write : / P0001-PERNR.

You might also like