sitemap
ABAP HR
Concepts of Macros (Import/Export etc.)

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

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

  • bb is the Database table where the data is saved:
    o  C1 Database object PCL1
       o  C2 Database object PCL2
o  C3 Database object PCL3
o  C4 Database object PCL4
  • Cc is the cluster, it may take
    o  RX Cluster object RX
    o  RD Cluster object RD
    o  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 Macrocode 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:     1)        Name of the internal table
 2)        Subtype required or SPACE if no subtype is being specified
 3)        Validity start 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 orthe 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.

o        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:     1)        Personnel number of the person requested
 2)        Infotype number of the required infotype
 3)        Name of the internal infotype table
 4)        Validity start date of the time interval
 5)        Validity end date of the time interval

OUT:  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.
Back to ABAP HR Page
All of the  product names here are trademarks of their respective companies.  The site
www.allsaplinks.com no way affiliated with SAP AG. We have made every effort for the content
integrity.  Information used on this site is at your own risk.
SapMaterial.com   
ABAP TECHNICAL

SAP Introduction

sap abap faq

sap Tables

SAP Transaction codes

Internal tables

data dictionary

performance tuning

transports & Requests

Sap scripts

Smartforms

lsmw

reports

sap Workflow

module pool/ dialog
programming

table control

user exits

sap memory

abap memory

alv reports

ABAP ADVANCED

IDOC

ALE

BAPI

BADI

RFC


FUNCTIONAL SIDE

Materials Management

FICO

Human Resources

BIW / BW / SEM


Free Documentation
Abap Material

Ale Material

BAPI Material

BC Material

IDOC Material

R/3 Database Management

SAP material

RFC

Transport

Sales & Distribution Material

Basic Data and Function
Material

Basis (BC) Material

Billing Material

CA Material

CATT : Computer Aided Test
Tool

Capacity Evaluation and
leveling Material

Capacity Planning Material

Cross Application Material

Countries

Customer Service Material

Enterpise  Material

Financial / Controlling (FICO)

Internet Time Sheet

Inspection Material

HR Material

Material Management
Material

Payments Material

Payroll Material

Pension Fund

Production Planning and
Control

Plant Maintenance

Quality Management Material

Real Estate Material

SAP material

Wage Types