Macros in ABAP-HR Programming – I

5
1097

The macros will be used to get the data from the various clusters based on the cluster ID.For Buffering purpose we use macros.

macros

For example, when we want to read the data from the cluster RU, we have to pass the cluster ID “RU” and Rx-KEY to the particular macro. By using the Rx-key the macro will fetch the data from the cluster RU.

Basically we use the macros to IMPORT/EXPORT the data to or from the clusters.

Here is the general naming convension for the IMPORT and EXPORT macros.

For Import:

RP-IMP-Cn-xx

where,

n ——–> No. of PCL file.(ex:1,2,3,4 0r 5)

xx——–> cluster ID

IMP——> Import

For Export:

RP-EXP-Cn-xx

where,

n ——–> No. of PCL file.(ex:1,2,3,4 0r 5)

xx——–> cluster ID

EXP——> Export

Macro contains some part of source code which it will be useful for number of applications, just like function modules.

Generally we use two macros in HR ABAP

  • RP-PROVIDE-FROM-LAST
  • 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.

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. ( same as sy-subrc but the value is in reverse case)

The macro RP-READ-INFOTYPE retrieves all the data record(s) which is valid in the data selection period. If SY-SUBRC = 0 or initial, then the process is successful.

All the Macros are stored in table TRMAC.

Whenever you are using the macros like RP-PROVIDE-FROM-LAST or RP-PROVIDE-FROM-FRST, check whether you have included logical database PNP in program attributes.

It is not necessary to include logical database PNP/PNPCE in your program when you are using the macro like RP-READ-INFOTYPE A B C D E , where A corresponds to PERNR which describes for which personnel number you require records. B corresponds to INFOTYPE which describes from which infotype you require records. C corresponds to data structure of the declared infotype (internal table like P0000 for infotype 0000) where all the records of the particular personnel number will be stored. D corresponds to Start date. E corresponds to End date.

Sample Code :

Tables : PERNR.

INFOTYPES : 0001,0002.

 Start-of-selection.

Get PERNR.

RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.

 Write : / P0001-PERNR.

Note:

1. NULL is a macro which contains the value 0 (on most implementations). this is the one used to initialize a pointer to NULL

2. Debugging a MACRO is not really possible, prevent the use of them.

5 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here