cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering two workflows using a single CR

former_member200911
Participant
0 Kudos

Hi,

I have a requirement where i need to trigger two different workflow using a single CR, it is working for me as long as I use my inputs from MATERIAL entity

ref following link

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60f0cc68-5884-2e10-b8a9-a71ba25ad...

but when i give my input from other entity for eg MARCFRGTR it doesnt work, I have changed the structure also in the BADI which is given in the link above.

Can anyone help me on this

Thanks

Arihant

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Arihant,

I hope you have created a custom implementation for this BADI.

Please check below points:

  • In your BADI implementaiton, inside method PREPARE_RULE_CONTEXT you might be calling a method similar to READ_MATERIAL, may be READ_MARCFRGTR in this case for reading the MARC information. Please check whether correct structure is passed to it while creating the data reference. It should be if_mdg_bs_mat_gen_c=>gc_fieldname_marcfrgtr and not if_mdg_bs_mat_gen_c=>gc_fieldname_material

          CALL METHOD lr_model->create_data_reference            

               EXPORTING              

                    i_fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_marcfrgtr              

                    i_struct    = lr_model->gc_struct_key_attr              

                    if_table    = abap_true              

                    i_tabtype   = lr_model->gc_tabtype_sorted            

               IMPORTING              

                    er_data     = lr_data.

  • While filling out the return table inside method PREPARE_RULE_CONTEXT, for getting the element id make sure you are passing right value (same name as created data object in BRF+ with caps). For ex:

            get_element_id(            

               EXPORTING              

                    iv_cr_type = lv_crequest-usmd_creq_type               

                    iv_name    = 'CASMARCFT'             

               IMPORTING              

                    ev_brf_expr_id = lv_brf_expr_id ).

  • Check whether step 4.3.4 is done as mentioned in the link
former_member200911
Participant
0 Kudos

method READ_MARCFRGTR is not there in standard SAP system, and i wanted to do it without going for too much customization and morover the link which i shared shows to put fields in User agent decision table but my requirement is to trigger the workflow based on input in Single value decision table so i am not sure whether that BADI or Enhancement will come in to picture, the concern here i have now is BRF+ decision tables dont support cross entity rules so,

If it is reading material from entity MATERIAL than decision table wont read input from other entity like MARCFRGTR, but if we give our input from the same entity MATERIAL than it works

so is there any way that my decision table reads material from entity MARCFRGTR since we have material (MATNR) in this entity as well

Thanks

Arihant

Former Member
0 Kudos

Hi Arihant,

For example i told a method READ_MARCFRGTR. This is not existing in standard example implementation. You have to create this method and code it similar to READ_MATERIAL.

Please follow below steps in the BADI:

  • Create a custom implementation for this BADI.
  • Inside this custom implementation class, create a new static private method called READ_MARCFRGTR.
  • Create below parameters for this new method,
    • Exporting parameter ES_MARCFRGTR  TYPE /MDGMM/_S_MM_PP_MARCFRGTR
    • Importing paramter IV_CR_NUMBER TYPE USMD_CREQUEST
  • Put below code inside this new method.

METHOD read_marcfrgtr.
   DATA: lr_model    TYPE REF TO if_usmd_model_ext.
   DATA: lt_sel      TYPE usmd_ts_sel.
   DATA: ls_sel      TYPE usmd_s_sel.
   DATA: lt_objlist  TYPE usmd_t_crequest_entity.
   DATA: ls_objlist  TYPE usmd_s_crequest_entity.
   DATA: lv_matnr    TYPE matnr.
   DATA: lr_data     TYPE REF TO data.
   FIELD-SYMBOLS: <lt_data> TYPE SORTED TABLE.
   FIELD-SYMBOLS: <ls_data> TYPE any.
   CONSTANTS: lc_incl  TYPE ddsign   VALUE 'I'.
   CONSTANTS: lc_equal TYPE ddoption VALUE 'EQ'.

   CLEAR: es_marcfrgtr.
* Get read-only access to USMD model data
   CALL METHOD cl_usmd_model_ext=>get_instance
     EXPORTING
       i_usmd_model = if_mdg_bs_mat_gen_c=>gc_model_mm
     IMPORTING
       eo_instance  = lr_model.
* Read object list of CR and get the one and only material:
* Get the key of the (type 1) entity MATERIAL
* from the object list of this CR
   ls_sel-sign      = lc_incl.
   ls_sel-option    = lc_equal.
   ls_sel-fieldname = usmd0_cs_fld-crequest.
   ls_sel-low       = iv_cr_number.
   INSERT ls_sel INTO TABLE lt_sel.
   CALL METHOD lr_model->read_char_value
     EXPORTING
       i_fieldname       = usmd0_cs_fld-crequest
       it_sel            = lt_sel
       if_use_edtn_slice = abap_false
     IMPORTING
       et_data           = lt_objlist.
   READ TABLE lt_objlist INTO ls_objlist INDEX 1.
   ASSERT sy-subrc = 0. " CR not found or contains no material
   lv_matnr = ls_objlist-usmd_value.
* Prepare result table for MATERIAL read
   CALL METHOD lr_model->create_data_reference
     EXPORTING
       i_fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_marcfrgtr
       i_struct    = lr_model->gc_struct_key_attr
       if_table    = abap_true
       i_tabtype   = lr_model->gc_tabtype_sorted
     IMPORTING
       er_data     = lr_data.
   ASSIGN lr_data->* TO <lt_data>.
* Read MATERIAL via material number and Change Request ID
   CLEAR lt_sel.
   ls_sel-fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material.
   ls_sel-sign   = lc_incl.
   ls_sel-option = lc_equal.
   ls_sel-low    = lv_matnr.
   INSERT ls_sel INTO TABLE lt_sel.
   ls_sel-fieldname = usmd0_cs_fld-crequest.
   ls_sel-low       = iv_cr_number.
   INSERT ls_sel INTO TABLE lt_sel.
   CALL METHOD lr_model->read_char_value
     EXPORTING
       i_fieldname       = if_mdg_bs_mat_gen_c=>gc_fieldname_marcfrgtr 
       it_sel            = lt_sel
       i_readmode        = if_usmd_model_ext=>gc_readmode_default
       if_use_edtn_slice = abap_false
     IMPORTING
       et_data           = <lt_data>.
* Return the one and only result
   READ TABLE <lt_data> ASSIGNING <ls_data> INDEX 1.
   ASSERT sy-subrc = 0. " CR not found or contains no material
   MOVE-CORRESPONDING <ls_data> TO es_marcfrgtr.
ENDMETHOD.


  • Create also GET_ELEMENT_ID and READ_CREQUEST methods and copy same code from the example implementation class CL_MDG_BS_MAT_BRF_CONTEXT_LABO to your custom implementation class for this methods.
  • Now inside the method PREPARE_RULE_CONTEXT use below code

METHOD if_usmd_ssw_rule_cntx_prepare~prepare_rule_context.
* Add one decision table parameter "Labor" (MARC-CASMARCFT)
* to the user agent decision table
   DATA: lv_brf_expr_id TYPE if_fdt_types=>id.
   DATA: ls_context     TYPE usmd_s_fdt_context_value.
   DATA: lv_crequest    TYPE usmd_s_crequest.
   DATA: ls_marcfrgtr    TYPE /MDGMM/_S_MM_PP_MARCFRGTR.
   FIELD-SYMBOLS: <value> TYPE any.
* Prepare export parameters
   CLEAR et_message.
   CLEAR et_rule_context_value.
* Read the one and only material of the CR
   CALL METHOD read_marcfrgtr
     EXPORTING
       iv_cr_number = iv_cr_number
     IMPORTING
       es_material  = ls_marcfrgtr.
* Read the CR itself (to get the CR type
   CALL METHOD read_crequest
     EXPORTING
       iv_cr_number = iv_cr_number
     IMPORTING
       es_crequest  = lv_crequest.
* fill out the return table
   get_element_id(
     EXPORTING
       iv_cr_type = lv_crequest-usmd_creq_type
       iv_name    = 'CASMARCFT'
     IMPORTING
       ev_brf_expr_id = lv_brf_expr_id ).
   ls_context-id = lv_brf_expr_id.
   CREATE DATA ls_context-value TYPE labor.
   ASSIGN  ls_context-value->* TO <value>.
   <value> = ls_material-labor.
   APPEND ls_context TO et_rule_context_value.
ENDMETHOD.

former_member200911
Participant
0 Kudos

Ok I will try this but i have one more concern here, when we upload a material using File upload option through MDG, does in the back-end our system call structure MDGM_*_*_MATERIAL by default? to read the material (remember here i am not giving input to User agent decision table so there is no use of the BADI which is given in the link I guess) or if i modify my programme based on MARCFRGTR it may call it from MDGM_*_*_*_MARCFRGTR structure?

Thanks

Arihant

Former Member
0 Kudos

Hi Arihant,

I think you should be using a separate Change Request Type for File upload not the same CR Type of single object processing. So both CR types have its own decision tables and functioning. Please check

former_member200911
Participant
0 Kudos

Yes, I am using a separate CR only for both HERKL and CASMARCFT fields, these two fields i want to club in a single CR which is based on my file upload approach, there i want too check whether it checks for structure MDGMM_*_*_*_MATERIAL in the back end or not, because i think it is reading the material from this structure and since HERKL/CASMARCFT come in a different structure it is getting failed

Is that correct?

Former Member
0 Kudos

Hi Arihant,

Yes, Material value will be read from the structure MDGMM_*_*_*_MATERIAL structure only since MATERIAL is TYPE1 Entity and MARCFRGTR is TYPE 4 Entity.

Point here is, same MATERIAL value only will be present in both the structures

former_member200911
Participant
0 Kudos

Ok,Thanks!!!

former_member200911
Participant
0 Kudos

This link explains about triggering different user based on input we give

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60f0cc68-5884-2e10-b8a9-a71ba25ad...

but it is limited to entity MATERIAL i guess, since LABOR is coming under structure ?/MDGM_S_PP_MM_MATERIAL

but my requirement is to trigger different user based on field COO and CAS which are coming under entity MARCFRGTR and structure is /MDGM_S_PP_MM_MARCFRGTR which is not working for me

I checked with the developer and he says this BADI/Enhancement is reading material from structure /MDGM_S_PP_MM_MATERIAL thats why it is not triggering other structure

Is that understanding correct?