Skip to Content
Author's profile photo Petra Hunger

How to code a condition call in TM

How to code a condition call  

This question is Not Answered.(Mark as assumed answered)

Petra Hunger   Steel

Currently Being Moderated 

Today, I would like to provide sample coding for a condition call.

In TM, most of the times, BRF+ conditions are used instead of custom tables known from ERP. The great thing about these conditions is that you can just provide the Fo number or FU number or OTR number to it and the code will read the related data and return a result. Where in SD, you had to read the table with the data, you can just input the FO and the method will revert back saying if this FO is relevant or not for this condition in lt_cond_result.

The following code can be used:

  REPORT zphu_cond_call.

DATA: ls_bo_inst_key     TYPE /bobf/s_frw_key,
       lt_bo_inst_key     TYPE /bobf/t_frw_key,
       ls_condition_id    TYPE /scmtms/s_condition_id,

       lt_condition_id    TYPE /scmtms/t_condition_id,
       co_message         TYPE REF TO /bobf/if_frw_message,
       lt_cond_result     TYPE /scmtms/t_boid_cond_result,
       lt_cond_result_all TYPE /scmtms/t_boid_cond_result.

CLEAR: ls_bo_inst_key, ls_bo_inst_key, ls_condition_id, lt_condition_id.


BREAK-POINT.


* specify the key of an example bo instance (here: a trq instance)


ls_bo_inst_keykey = ‘0050569F57AB1ED4A6989181F34473F6’.

APPEND ls_bo_inst_key TO lt_bo_inst_key.


*specify the condition to be executed
ls_condition_idcondition_id = ‘ZTEST_PHU’.
APPEND ls_condition_id TO lt_condition_id.


* call method that reads the condition


CALL METHOD /scmtms/cl_cond_ol=>proc_conditions
   EXPORTING
     it_boinst_key            = lt_bo_inst_key  “<- your TRQ number
     it_cond_id               = lt_condition_id   “<- your condition name
     iv_do_not_return_no_hits = abap_true
   IMPORTING
     et_bokey_cond_result     = lt_cond_result “<- whether or not the condition is ok for this instance
   CHANGING
     co_message               = co_message.

* collect all results from condition for later processing
INSERT LINES OF lt_cond_result INTO TABLE lt_cond_result_all.

BREAK-POINT.


You can find this and other useful hints about TM enhancements in the TM enhancement guide from Holger Polch.


http://scn.sap.com/blogs/SAP_TM_Enhancements

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.