SAP Help BOBX create enhancement validation
create enhancement validation using BOBX
see @@create-enhancement-determination
Step 1 - first create a business object enhancement or use existing
find the business object you want to enhance
Create enhancement
enter name and business object and press ok to create
Step 2 - Find business object element Validations
first find the relevant business object enhancement created above
double click on business object z enhancement
Expand the Node Elements
select change mode
and find the node you want to create an enhancement validation for (i.e. ROOT). You can expand the validations
node to see all the existing validation(standard + other enhancements). Useful to see how these work and be able
to find code that you might want to use in your new validation.
Step 3 - Create Enhancement Validation
Right click on the Validations node and choose Create Validation->Action Validation
Enter name/details and Click Save
Double Click on the method name you have just entered, it will ask you if you want to create it. Press Yes and enter all the usual transport details
The New class interface will be created with the appropriate methods such as EXECUTE. This is where you enter you validation code.
Active it
Now press the Generate button
and you should get a message saying it generated ok
Step 4 - Example code to implement custom validations
METHOD /bobf/if_frw_validation~execute.
DATA: lt_root TYPE /scmtms/t_tor_root_k,
ls_root TYPE /scmtms/s_tor_root_k,
lt_party TYPE /scmtms/t_tor_party_k,
lt_item_tr TYPE /scmtms/t_tor_item_tr_k,
lt_stages TYPE /scmtms/t_pln_stage,
lt_stops TYPE /scmtms/t_tor_stop_k,
lt_exec TYPE /scmtms/t_tor_exec_k,
ls_exec TYPE /scmtms/s_tor_exec_k.
DATA: ld_error TYPE string.
DATA: ld_anyerror TYPE string.
DATA: lt_item TYPE /scmtms/t_tor_item_tr_k,
wa_item TYPE /scmtms/s_tor_item_tr_k.
CLEAR: ld_anyerror.
* Use the retrieve call to get the current node details (in this case its the root details)
* But note if you had implemented this at item level, this same call would retrieve the item details
io_read->retrieve(
EXPORTING iv_node = is_ctx-node_key
it_key = it_key
iv_fill_data = abap_true
IMPORTING
et_data = lt_root
).
* Once you have got the root details you can then retrieve other details
* CALL METHOD /scmtms/cl_print_helper=>get_tor_nodes
* EXPORTING
* it_key = it_key
* IMPORTING
* et_root = lt_root
* et_item_tr = lt_item_tr
* "ET_ITEM_TR_TRQ = lt_item_tr
* et_item_pos_details = lt_item_pos
* et_party = lt_party
* et_stages = lt_stages
* et_stop = lt_stops
* et_exec = lt_exec.
*Or perform some checks, just add a message without any checking
IF ls_root-TOR_ID GT 200.
ld_anyerror = 'X'.
ENDIF.
IF ld_anyerror IS INITIAL.
sy-msgty = 'S'.
sy-msgid = 'ZAA'.
CLEAR: sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4.
sy-msgv1 = 'Checks passed OK'.
sy-msgno = '000'.
ELSE.
sy-msgty = 'E'.
sy-msgid = 'ZAA'.
CLEAR: sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4.
sy-msgv1 = 'Checks failed because TOR_ID gt 200'.
sy-msgno = '000'.
ENDIF.
* Writes what is in current system message details to TMS front end guid
CALL METHOD /scmtms/cl_common_helper=>msg_helper_add_symsg
CHANGING
co_message = eo_message.
ENDMETHOD.
Step 5 - Set Validation Trigger Actions
If you return to the BOBX tcode for the enhancement validation you have just created (i.e. press BACK). you will also see
a Trigger Action tab which will allow you to select when you want this validation to trigger.
There are lots of options in some of these validation you just need to find the one you want or experiment until you do as
some are not always obvious when they will be triggered. I'll just set it to the check function i.e. when the user clicks
the check order button in TMS. ALso note when debuggin the NWBC to find where the actions do actually trigger hard codes break
pounts don't always seem to work so try add the external break points using the stop button within the code editor.