on 10-02-2015 9:23 PM
Hello Experts,
I'm implementing MDGC 7 in a demo system. I am using this guide: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60f0cc68-5884-2e10-b8a9-a71ba25ad...
but I would like to direct my workflow based on the account group specified in the CR (I'm using customer like UI). I've copied the sample badi implementation of BADI "USMD_SSW_RULE_CONTEXT_PREPARE" that was designed for MDG material, I changed the constants to fit to my requirements, but my badi is not working. I've checked the code and the method "READ_ACCOUNT_GROUP" that I have created by copying the code (and replacing the constants) of READ_MATERIAL standard method (this method was created to retrieve material number from the CR). The problem is that this method cannot retrieve the account group (field KTOKD) value from my CR. (I couldn't really find out what is the exact reason of the error in the code, the code is quite complex and I'm not really good in object oriented ABAP...)
So my question would be the following: is there any sample methods that I can use for MDGC to retrieve certain data from my CR (preferably account group value)? I have an idea how could I solve that by simply writing a few lines of codes that directly selects from my staging area table, but I would much better like to use some standard SAP code as a template (which I can also use during a client implementation or which could be compliant in case of system upgrades.)
Thank you in advance,
Tamas
Hi,
We did a similar implementation for MDG-F entity Cost centre.
Following is the logic.
1. Based on CR number , get the object list of that CR
ls_sel-sign = 'I'
ls_sel-option = 'EQ'
ls_sel-fieldname = usmd0_cs_fld-crequest.
ls_sel-low = iv_cr_number.
INSERT ls_sel INTO TABLE lt_sel.
CALL METHOD go_model_ext->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.
2. lt_objlist has list of entities and the key values.Use it to build lt_sel(selection table)
LOOP AT lt_objlist INTO ls_objlist .
CASE ls_objlist-usmd_entity.
WHEN if_usmdz_cons_entitytypes=>gc_entity_cctr.
lv_fieldname = if_usmdz_cons_entitytypes=>gc_entity_cctr.
ls_sel-fieldname = ls_objlist-usmd_entity_obj.
ls_sel-sign = y0mxr_if_ref_mdg_constants=>gc_sign_i.
ls_sel-option = y0mxr_if_ref_mdg_constants=>gc_option_eq.
ls_sel-low = ls_objlist-usmd_value.
INSERT ls_sel INTO TABLE lt_sel.
endloop.
3.Then create an instance of model data class
* Get read-only access to USMD model data
CALL METHOD cl_usmd_model_ext=>get_instance
EXPORTING
i_usmd_model = '0G'
IMPORTING
eo_instance = go_model_ext
* Prepare result table
CALL METHOD go_model_ext->create_data_reference
EXPORTING
i_fieldname = lv_fieldname
i_struct = go_model_ext->gc_struct_key_attr
if_table = abap_true
i_tabtype = go_model_ext->gc_tabtype_sorted
IMPORTING
er_data = lr_data.
ASSIGN lr_data->* TO <lt_data>.
CALL METHOD go_model_ext->read_char_value
EXPORTING
i_fieldname = lv_fieldname
it_sel = lt_sel
* i_readmode = if_usmd_model_ext=>gc_readmode_no_act
if_use_edtn_slice = abap_false
IMPORTING
et_data = <lt_data>.
<lt_data> contains the data and within that you could find specific attribute value
Regards,
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu,
thank you for your answer, this is almost the same as the one that I copied from the GET_MATERIAL method. So my problem is the same: what is the value that I'm supposed to use for lv_fieldname in your last method? You used a constant that contains the name of the cost center entity type (if_usmdz_cons_entitytypes=>gc_entity_cctr), but what should I use if I want to retrieve customer account group (e.g. ship-to, sold-to, etc.). I've used KTOKD, but it didn't work.
Since you used an entity type, and the sample GET_MATERIAL also retrieved an entity type (MATERIAL), maybe I will try to provide the entity type name that contains KTOKD as an attribute, and get the KTOKD value from that entity type. I will try...
Thanks,
Tamas
Hi Raghu,
afterall, I used the sample code delivered in the GET_MATERIAL method. It looks like the below. It's almost the same as the one you sent. The thing is that at the end " lt_data" contains all the data contained in the BP_CUSGEN entities of all the CRs, so then I had to restrict the hits. And also, at the beginning I used hardcoding instead of the loop solution.
method READ_ACCOUNT_GROUP.
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_ktokd TYPE ktokd.
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_account_group.
* Get read-only access to USMD model data
CALL METHOD cl_usmd_model_ext=>get_instance
EXPORTING
i_usmd_model = 'BP'
IMPORTING
eo_instance = lr_model.
* Read object list of CR and get the one and only account group:
* Get the key of the (type 1) entity ???CUSGEN/ACCOUNT_GROUP
* 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
WITH KEY USMD_ENTITY = 'BP_HEADER'.
ASSERT sy-subrc = 0. " CR not found or contains no account group
lv_ktokd = ls_objlist-usmd_value.
* Prepare result table for Customer account group read
CALL METHOD lr_model->create_data_reference
EXPORTING
* maybe the field name is different????
i_fieldname = 'BP_CUSGEN'
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 ACCOUNT GROUP via account group ID and Change Request ID
CLEAR lt_sel.
* maybe the field name is supposed to be something else here?
ls_sel-fieldname = 'BP_CUSGEN'.
ls_sel-sign = lc_incl.
ls_sel-option = lc_equal.
ls_sel-low = lv_ktokd.
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
*maybe the fieldname is different here?
i_fieldname = 'BP_CUSGEN'
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>
WITH KEY ('BP_HEADER') = lv_ktokd.
ASSERT sy-subrc = 0. " CR not found or contains no account group
MOVE-CORRESPONDING <ls_data> TO es_account_group.
endmethod.
When I was done with this particular method, the program goes back to the PREPARE_RULE_CONTEXT method. Here I also changed the standard code designed for MDGM, the get_element_id method required a correct export parameter. It must be the same object that you specified in IMG-->process modeling-->workflow-->rulebased WF-->configure rule-based WF-->BRF+Application-->CR-type related aplication-->Contained objects-->Type:Any (as it is written in the doc posted above by me):
get_element_id(
EXPORTING
* maybe the iv_name value is not correct here?
iv_cr_type = lv_crequest-usmd_creq_type
iv_name = 'ACCOUNT_GROUP'
IMPORTING
ev_brf_expr_id = lv_brf_expr_id ).
ls_context-id = lv_brf_expr_id.
CREATE DATA ls_context-value TYPE ktokd.
ASSIGN ls_context-value->* TO <value>.
<value> = ls_account_group-ktokd.
APPEND ls_context TO et_rule_context_value.
ENDMETHOD.
Thank you for your help,
Tamas
Hello Taasdfg
MDG-F and MDG-C data model are of different nature. MDG-F generates its own table in MDG itself where as in MDG-C the data is stored in staging.
The logic for retrieving the data for MDG-F and C is different.
You can use BRF based workflow instead of changing the code. Add account group column in BRF and then trigger the approval process.
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kiran,
I'm sorry, but your answer is not correct.
Both MDG-C and MDG-F use generated database table to store data that is currently processed in a CR. This is the so called staging area. The difference between MDG-C and MDG-F is the storage of the active data (meaning data that is currently not processed in a CR). MDG-C makes use of the SAP ERP tables (e.g. BUT000, KNA1, etc.) whereas MDG-F keeps the data in the generated tables with an additional active flag.
The way how you can access the data, is exactly the same.
Best regards
Michael
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.