Thursday 10 December 2020

Determination In BOPF

Description: The Blog Post is about how to create determination and test it in BOPF framework.

Prerequisite: To know The Steps Of Creating BO Object in BOPF And Also To add Node And Necessary Structures Required For Creating BOBF Application.

Introduction: A determination is an entity of a business object node that is used to provide functions that are automatically executed as soon as a certain trigger condition is fulfilled. A determination is triggered internally on the basis of changes made to the node instance of a business object.

Examples For Determination: Generation Of ID Automatically Via SNRO.

Categories of Determination: In general, BOPF provides the following categories for Determination:

Transient Determination – Modifies only transient fields or nodes. For such determinations no locking is necessary.

Persistent Determination – Modifies transient and persistent fields or nodes. Here locking is necessary.

Let’s start creating with determination in BOBF tcode:

Here, i have previously created business object, and added Node Employee which holds the basic employee details, And also had generated the required combined structure and combined table type

For the employee detail, I want the id to be generated through Snro, So I will create a  Determination for this.

Follow The Steps As Shown,

Step1: Choose “Create Determination” in the context menu

of the node.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Once you had clicked on create determination it pop ups the below screen,

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step2: Maintain the basic properties of the new determination

Give the name of your choice to Determination and provide the description.

Give the Determination category

Give the Change Mode:

Persistent Determination => Exclusive Write

Transient Determination => Only Read Mode

Give Determination Class: Choose a class from the BOPF Library or create a new class by forward navigation to implement an individual determination

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step 3: Choose request nodes/ associations and trigger condition

◉ Request Nodes: Nodes, that trigger the determination whenever instances of this node fulfill the trigger condition (create, update, delete, load, determine)

◉ Read Nodes: Nodes that have to been all loaded into the buffer before the determination can start.

◉ Write Nodes: Nodes for which the framework has to ensure, that they are all write-locked before the determination is executed.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step4: Choose Determination Execution Times.

A determination execution time defines, at which time of the transactional cycle the

trigger condition of that determination should be evaluated.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step5: Choose Determination Dependencies

Determination dependencies restrict the order, in which the trigger conditions are evaluated. Dependency defines the execution order of determinations:

◉ Necessary Determinations: Determinations, which have to been executed before by the framework.

◉ Dependent Determinations: Determinations that are dependant on the other determination created.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Examples of valid execution orders are:

4, 1, 3, 2, 5 (for example, the determination DET 2 is always executed before the execution of DET 5)

1, 2, 5, 4, 3 (for example, DET 1 is always executed before the execution of DET 2).

Note: You can only choose Dependent Determination if you have created more than one determination.

once you have selected click Enter.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step6: Now we should write the logic in the Implementation Class that we created.

double click on the class and it will ask you to create object, Click on Yes.

Save it in the package and click Enter.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step7: You will be able to see the below screen, the First two methods are deprecated avoid using them and write your logic in the last method. i,e /BOBF/IF_FRW_DETERMINATION~EXECUTE :This Method Carries Out The Determination.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Source code

Step8: In the Method Execute, write the below code to generate snro.

DATA: lt type  Zan_c_tt, //combined Table type
ls type REF TO ZAN_C_S,//combined Structure
lv_id(3) type c.

io_read->RETRIEVE
exporting
IV_NODE                 =     is_ctx-node_key
IT_KEY                  =     it_key
*        IV_BEFORE_IMAGE         = ABAP_FAlSE    " Data Element for Domain BOOLE: TRUE (="X") and False (=" ")
*        IV_FILL_DATA            = ABAP_TRUE    " Data element for domain BOOLE: TRUE (='X') and False (=' ')
*        IT_REQUESTED_ATTRIBUTES =     " List of Names (e.g. Fieldnames)
importing
*        EO_MESSAGE              =     " Message Object
ET_DATA                 =     lt
*        ET_FAILED_KEY           =     " Key Table
*        ET_NODE_CAT             =     " Node Category Assignment
).

loop At lt REFERENCE INTO ls.

CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR                   = '01'
OBJECT                        = 'ZAN_ID'
*         QUANTITY                      = '1'
*         SUBOBJECT                     = ' '
*         TOYEAR                        = '0000'
*         IGNORE_BUFFER                 = ' '
IMPORTING
NUMBER                        =  lv_id
*         QUANTITY                      =
*         RETURNCODE                    =
*       EXCEPTIONS
*         INTERVAL_NOT_FOUND            = 1
*         NUMBER_RANGE_NOT_INTERN       = 2
*         OBJECT_NOT_FOUND              = 3
*         QUANTITY_IS_0                 = 4
*         QUANTITY_IS_NOT_1             = 5
*         INTERVAL_OVERFLOW             = 6
*         BUFFER_OVERFLOW               = 7
*         OTHERS                        = 8
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ls->Eid = lv_id.

io_modify->UPDATE(
exporting
IV_NODE           =     is_ctx-node_key
IV_KEY            =     ls->key
*          IV_ROOT_KEY       =     " NodeID
IS_DATA           =    ls
*          IT_CHANGED_FIELDS =     " List of Names (e.g. Fieldnames)
).

About Interface and the Parameters used in method

/BOBF/IF_FRW_DETERMINATION: This interface defines methods for determination execution in BOPF.

Parameter Description 
IS_CTX  Provides context information of the Determination

IT_KEY

Hold keys of the node instances 

IO_READ

Hold keys of the node instances 
IO_MODIFY  Provides write access to the business objects 
EO_MESSAGE  Holds Message container to return information 
ET_FAILED _KEY  Holds node instance keys, for which the Determination Criteria Didn’t Match 

Now the determination has been created and implemented.

Let’s Test Your Application In BOBT Tcode

Step1: Run Tcode BOBT and open your Business Object.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step2: Now Click on create node button as shown,

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

Step3: Once you click on the add node button You can see the Eid has been generated by snro, that was implemented in Determination Implementation Class.

SAP ABAP Tutorial and Material, SAP ABAP Certification, SAP ABAP Exam Prep, SAP ABAP Preparation

No comments:

Post a Comment