Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Numbering Routine in SAP Audit Management

$
0
0

1. Introduction

 

In audit management module of SAP the naming of an audit object (audit plan, audit, question list, question) isgiven by the user.  This has its disadvantages such as

  1. No convention in the naming of the object.
  2. If a naming convention is followed by the organization, users who are not aware of the naming convention will give their own naming which may not follow the naming convention.

Hence we go for the numbering routine which generates the naming of the Audit objects automatically while creating them which follows the naming convention.

The BADI used for implementing the numbering routine is PLM_AUDIT_IDENTIFIER.

Method used for implementing numbering routine: GET_EXTERNAL_ID

2. Business description

 

Don’t have to do manual numbering, and therefore more effective – will also remove the risk of someone trying to introduce a system in the numbering, which then could raise demands on reporting etc.

 

3. Steps to create Audit

 

Go to transaction PLMD_AUDIT.

Select the audit object which needs to be createdfrom the options displayed after pressing the create icon.

The audit objects can be created by two ways.

  1. Directly by selecting the object in top three options
  2. By using a template which references(copies) the already created audit objects by selecting from below three options.

 

Provide the name of the object (before numbering routine is implemented).

 

 

Provide the necessary values for the audit and save.

 

4. Implementation of numbering routine

 

Go to the BADI: PLM_AUDIT_IDENTIFIER   and create an implementation (Ex: znumbering).

Go to the method GET_EXTERNAL_ID and implement the numbering routine.

There are different audit object for which the naming convention has to be unique.

The different audit objects and their object type are listed below.

Audit object

Object type

Audit plan

AUP

Audit

AUO

Question list

QUN

Audit question list

AQN

Part, Element, Question

QUE

Audit Part, Element, Question

AQN

Corrective and preventive action

COR

 

 

Parameters of the Method GET_EXTERNAL_ID

Import parameter:

IV_OBJECT_TYPE: will contain the object type of the audit object.

IV_EXTERNAL_ID: contains the name of the Audit object if the name was given.

IR_PARENT_OBJECT: Contains the parent object of the audit object

Export parameter:

EV_EXTERNAL_ID: will be used to set the numbering for the audit object.

 

4.1 Creation of number range object

 

In my scenario I have generated the numbering for each of the audit object using the number range objects.

The function module NUMBER_GET_NEXT will be used to retrieve the numbering from the number range object.

Creation of number range object:

Go to transaction SNRO.

Provide the name of the number range object and press create.

 

 

Provide the necessary details.

 

Create the intervals and save. In my case I have created four intervals each for the object type’s AUP, AUO, AQN, COR.

Here I have created interval AP for object type AUP, AU for object type AUO, CA for object type COR and QL for object type AQN.

 

4.2  Creating the numbering for the audit objects

 

Retrieve the numbering from the number range object by passing the interval in parameter NR_RANGE_NR and the number range object name in the parameter OBJECT. Retrieve the number from the parameter NUMBER.

Concatenate the interval name and the number into the export parameter W_EXTERNAL_ID of the method.

Instead of using number range object to generate the numbering we can also use our own logic to generate the internal numbering.

 

 

 

 

Sample code

The sample code given below is a simple one. Based on the requirement we receive we need to implement our logic to meet the requirement.

DATA: lv_nr_range_nr TYPE nrnr,
lv_numrange_object
TYPE nrobj,
lv_number
TYPE char20,
lv_quant
TYPE nrquan,
lv_code
TYPE nrreturn.
IF iv_object_type = 'AUP'
OR iv_object_type = 'AUO'
OR iv_object_type = 'COR'
OR iv_object_type = 'AQN'.
lv_numrange_object
= 'ZPLM_AUDIT'.
CASE iv_object_type.
WHEN 'AUP'.
lv_nr_range_nr
= 'AP'.
WHEN 'AUO'.
lv_nr_range_nr
= 'AU'.
WHEN 'COR'.
lv_nr_range_nr
= 'CA'.
WHEN 'QUN'.
lv_nr_range_nr
= 'QL'.
ENDCASE.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr     
= lv_nr_range_nr
object          
= lv_numrange_object
IMPORTING
number           = lv_number
ev_external_id+2
= lv_number.
ev_external_id
(2) = lv_nr_range_nr.
ENDIF.

Audit created after numbering routine is implemented.

 

5. Disable the input field

Once numbering is created we can disable the input for the naming field so that the user can’t able to overwrite the naming created.

We use the method IS_EXTERNAL_ID_CHANGEABLE of the BADI to disable the input of the naming field using the below logic.

To disable the the input field for input make the export parameter

rv_is_changeable = '0'.

 

6. Difficulties faced

 

  • ü When creating audit using template the BADI will be executed twice hence the numbering will be incremented by 2 from the previous number. Hence a check must be performed so that the Number range object was called only once.

 

  • ü When creating audit Question list using template the incoming object type will be AUO instead of AQN. This should be taken care by checking the parent object type with the import parameter object type. If object type is AUO and parent object type is AUP the object is Audit. If both the object type and parent object type are AUO then the object is Question list.

Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>