KEMBAR78
All The Coding MDG | PDF | Data Model | Databases
0% found this document useful (0 votes)
62 views67 pages

All The Coding MDG

The document provides a method for debugging rule-based workflows in Master Data Governance (MDG) using an endless loop controlled by a User Profile Parameter. It explains how to implement this debugging technique in non-development environments by leveraging SAP class CL_USMD_WF_SSW to monitor agent determination and system method calls. Additionally, it includes pseudo code and instructions for setting up the debugging process, while cautioning against using this method in production environments.

Uploaded by

Debabrata sahoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views67 pages

All The Coding MDG

The document provides a method for debugging rule-based workflows in Master Data Governance (MDG) using an endless loop controlled by a User Profile Parameter. It explains how to implement this debugging technique in non-development environments by leveraging SAP class CL_USMD_WF_SSW to monitor agent determination and system method calls. Additionally, it includes pseudo code and instructions for setting up the debugging process, while cautioning against using this method in production environments.

Uploaded by

Debabrata sahoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 67

1.how to debug ruled based workflow.

1.https://www.youtube.com/watch?v=8pTsfgY8Jtu

https://www.youtube.com/watch?v=jmnMGB0B_xI
Aasim Khan

Posted on August 13, 2020 4 minute read

Debug background steps using endless


loop with User Profile parameter in MDG.
FollowRSS feedLike
5 Likes 419 Views 0 Comments

Purpose:

Debug Rule based workflow in MDG for Agent Determination and System Method Caller in real time
using endless loop with the help of User Profile Parameter.

Introduction:

We all know that the most-often-used Agent Determination, System Method Caller and Material
Enrichment BAdIs in MDG are called in the background step asynchronously. If anyone wants to
debug them, it’s not possible in foreground. However, SAP has provided
class CL_USMD_WF_SSW which can be used for debugging
methods CALL_SYNCH_SYST_METHOD and FIND_PATH_PROCESSOR for system method
caller and agent determination respectively after the CR is submitted. The only way to debug them
during runtime is by adding an endless loop in the said BAdIs in the dev systems. But if we want to
debug in runtime in a non-development environment (read Quality and Preprod), then it becomes
kind of little difficult. So, here’s a way out to deal with this problem – add an endless loop that can be
controlled using a User Profile Parameter.

How it’s achieved:

Pseudo Code:

Create a user parameter in table TPARA. Let’s name it as ZBGRND_DEBUG.

 Check if the Change Request number exists in table USMD120C. The table will always have
CR number at the time of agent determination and/or CR submission.
 Get the user id of the person who created this CR and have ZBGRND_DEBUG set as X in
the user profile parameter.
 Run endless loop.
 If CR number not found in step 1, get the user id from Governance API and/or Convenience
API.
 Check if the instances of Governance and Convenience API exists.
 If an instance of Governance API exists and Convenience API not, then get the user id from
GOV API else from CONV API.
 Else, use SY-UNAME.
 Run endless loop.

Here’s the code:


Importing Parameter: IM_CR_NUMBER OPTIONAL

METHOD background_debug.

IF im_cr_number IS NOT INITIAL.


DATA(lv_cr_number) = im_cr_number.
ELSE.
* Get CR Number from App Context.
lv_cr_number = cl_usmd_app_context=>get_context( )->mv_crequest_id.
ENDIF.

SELECT SINGLE @abap_true


FROM usmd120c
WHERE usmd_crequest = @lv_cr_number
INTO @DATA(lv_cr_exists).
* If the CR is found, check user parameter of the id who created this CR.
IF sy-subrc = 0 AND lv_cr_exists = abap_true.
DO.
SELECT SINGLE
a~usmd_created_by,
b~bname,
b~parid,
b~parva
FROM usmd120c AS a
JOIN usr05 AS b
ON b~bname = a~usmd_created_by
WHERE a~usmd_crequest = @lv_cr_number
AND b~parid = 'ZBGRND_DEBUG'
INTO @DATA(lst_cr_usr_param).
IF lst_cr_usr_param-parva = space.
EXIT.
ENDIF.
ENDDO.

* If the CR is not yet submitted, then get CR details from CONV API.
* This case occurs when Rule Service BAdI is called from DIF
ELSE.

* Get Model from App Context.


DATA(lv_model) = cl_usmd_app_context=>get_context( )->mv_usmd_model.

* Check if instance of governance API exists.


DATA(lv_flg_gov_api) = cl_usmd_gov_api=>check_instance_exists(
iv_model_name = lv_model ).

* Check if instance of convenience API exists.


DATA(lv_flg_conv_api) =
cl_usmd_conv_som_gov_api=>check_instance_exists(
iv_model_name = lv_model ).

TRY.
* If governance API exists and convenience API does not, then use GOV
API.
IF lv_flg_gov_api = abap_true AND lv_flg_conv_api = abap_false.
DATA(lo_gov_api) = cl_usmd_gov_api=>get_instance(
iv_model_name = lv_model ).
IF lo_gov_api IS BOUND.
* Get the id who created Change Request.
DATA(lv_created_by) =
lo_gov_api->get_crequest_attributes(
iv_crequest_id = lv_cr_number )-usmd_created_by.
ENDIF.

* Else use convenience API


ELSE.

* Get the instance of Convenience API


DATA(lo_conv_api) = cl_usmd_conv_som_gov_api=>get_instance(
iv_model_name = lv_model ).

IF lo_conv_api IS BOUND.
* Set the change number in Convenience API
lo_conv_api->set_environment(
iv_crequest_id = lv_cr_number
).

* Get the id who created Change Request.


lv_created_by =
lo_conv_api->get_crequest_attributes( )-usmd_created_by.
ENDIF.
ENDIF.

CATCH cx_usmd_conv_som_gov_api .
CATCH cx_usmd_app_context_cons_error .
CATCH cx_usmd_conv_som_gov_api_env.
CATCH cx_usmd_gov_api .

* If any error, then use SY-UNAME for endless loop.


lv_created_by = sy-uname.
ENDTRY.

* Run endless loop.


DO.
SELECT SINGLE
bname,
parid,
parva
FROM usr05
WHERE bname = @lv_created_by
AND parid = 'ZBGRND_DEBUG'
INTO @DATA(lst_usr_param).
IF lst_usr_param-parva = space.
EXIT.
ENDIF.
ENDDO.
ENDIF.

ENDMETHOD.
Call this method in the implementation of BAdIs USMD_SSW_SYSTEM_METHOD_CALLER,
USMD_SSW_DYNAMIC_AGENT_SELECT, USMD_SSW_RULE_CONTEXT_PREPARE, etc. as

zcl_mdg_utilities=>background_debug( lv_cr_id ).

Now set parameter ZBGRND_DEBUG = X in the user profile to enable background debugging.

Run NWBC and create a Change Request for Material/Customer/Vendor. You’ll see the CR is
created but the workflow is still not completed. Execute transaction SM50 where you’ll see this class
is waiting for your attention. Select the workprocess and start debugging.

Note: Don’t forget to switch it off when not required!

Caution: PLEASE DON’T SET THIS PARAMETER IN PRODUCTIVE ENVIRONMENT.

Conclusion:

As mentioned earlier, debugging the said asynchronous methods in MDG can be achieved using the
standard SAP class CL_USMD_WF_SSW after the CR is submitted but a layer of flexibility can be
added by using controlled endless loop which enables us to debug at runtime.
People might raise concerns about the usage of endless loop in productive environment, but don’t
the Security folks there turn debugging off and add an array of authorization checks already? All in
all, I’d say please use it judiciously.

Some places where this solution could be used:

 BAdIs in Enhancement Spot USMD_SSW_SERVICE_PROCESSOR.


 BAdIs in Enhancement Spot USMD_RULE_SERVICE when called from DIF.
 BAdI MDG_BS_MAT_API_ENRICH_BADI, etc.

NM: Another great blog post by Jerry Wang is worth spending time on!



 Alert Moderator

Dynamic agent badi. From udemy .


When I summit there is no processor because code is stoped.
Then go to sm51
Its stop here because flag value set = x.its stop here.

Then reset it blank from x the flag vale .then debug will go to ur code.

F6 it came out the loop.


Here one example of brf .

1.here if aap3 rejetc it will go to req .then if req resummit it will go to aap3 not app1 and ap2.

Here we create a ztable contain cr numer ,the person who rejected and what step rejected.
Video 17 kartic

Here if I summit if some error how can I swich off errors.

In staed of standard change it to warning.


We can make mandatory field in get data method feeder.or make it in ecc lable in spro.

2.mdg 17k in below if I takeing 6th record I want 2nd step is final.skip all step.here when requester
summit take the header sales user name from this place final step directly.how I jump by
implementing.badi on dynamic agent.

We will get cr no inside it .at moment requester summited before its trigeer step 2 it will trigger badi.

Here we can say new step is not 2.new step is 6.here what ever user of head of sales. same we
manipulet in final step.here I have I template so based on scenario I change the template.

3.sysyem call method .


In above we pass the cr no it will give cr instances.

In below we read cr data.


Get the data model from cr type

Then set a body of emil]


4.MERGE BADI

HERE ABDI IS TRGERER IF 21 AND 30 BOTH APPROVED PARRAL MERGE BADI.IN BADI WE TELL NEW
STEPIS ONE MORE DUMMY STEP 01.
Link.

https://answers.sap.com/tags/67837800100800004488?sort=votes

18 video.

If data come to mdg . if governace required then go for file upload or dif.otherwise go for
.this technique.

2.some has to do very the delta record.if record missing some checks or field value. this is right time to
tell it is possible by mdg.intial load one cr generedted.

3.in which case for value mapping or key mapping.

If u give service name it will call respective badi.if u give mergrpara it will call handing parallal merge
badi.if give dyn agent service name it will trigger dynamic selection badi.

If02 prosee partern use we have to service name.

Context based badi triger if serivce name mantained in brf application.


There is a business parter central data and business partener com data.business parter pur data.if

Pur data payment term is changed it trigger to pur team.if com code data reconselation data change it
trigger to company code people.if central data name or email phone no website is changed.then
required approval for two different approval.

Once both complete 22 and 30 .paralla merge badi trigger.badi have logic start new step call 01.
First system call badi trigger then paralla mergrbadi trigger .no logic required for system call badi.

Her we tell new step is 01.


But system call badi no logic required.but here logic is for send a mail.

In above pass the cr no.it will give instance of cr.(lo_cre_).then go read change request
It will give cr complte details.simlar structure of usmd120c.

Then just prepair body and emil recipient and subject.


When I do scenario I suumit it will two workitem.

Here it split.

Wf log.

Back ground step.


Some thing truble shot . I dint get my email.if the logic there.
Then goto swia tcode.

I got a task.
Then go pftc.

Then go to class method.


Then excute

Then give workitem no.click on instance.


Then excutecall sycrnus method.
Give cr noand service name.then click on debugging.
After that 3 approval .its showing activation failed.

Why failed.
Slg1.

Jurdation code not define.

So based on that go to ecc or report functional consultant.

Below screen we select as our .

Subject.
Same error I got in validation log.

5.in which scenario we add extra field in brf.

If the vender is created us approval process and in uk process different.


In single value dession table we add one more coloum say country.if summsion is happing on country
usa next step is different.

Add field in single value disseion table.here we build two workflow template.

For that we need to do .

Here u add new context.


Then give serive name here.

In read material it logic.


They create an instace of mm dada model.once got instance they pass the cr number to stcture.

Below hight ligh is abctracxt layer.


Then we r getting the dadat in to releavant sture.
In above ir_data model refer to abstat layer usmd_model_ext.
This is the only way to acess the dadabase.so usung the layer we raedthe value.

Once we got material data.this is get elment id.

In below labor is the name of coloum of dession table


For everycloum thre is a id .

This is the id we trying to get in programe .we pass labor and cr type .atumotically it will get brf plus aid.
Once we pass value we pass labor value.

This way pass value to programe to brf plus.here based on country we split workflow process so
enhance single table. .but in sap given example they are not spillint the process just they are split the
users not the approval process thts why they enhance user agent dessinon table.
From karthik 18.2

1.how to create cr programtecally.

1.st is we juct create a cr .we pass cr type and cr descrtipiton.then it will return cr no.before that for
which object we create cr .for that go_gov_api =cl_usmd….then if u want attached call add _attched
method.this is opctional.

2.then enque cr no.then enque the type 1 entity.


Till here cr created and type 1 data written to cr.after that I can add all the type 4 entity.

c.read change request attributr.


Then if u want any notes.
If want same like summit then use start workflow.but if u want save data on draft then use save
method.

In above use suppose data come in idoc .or they place data in file .path .so we can write abap programe
so peograme read the data and create cr.so in standard dif also same code present

B.How to read the data from entity.

When you pass entity name it will return the stcture.this is entity structure.in above data give the key
stcture.may contain materil no or vender no.
So read_char_value use .all the data in my staging table.so we not use select stamen on staging table.

c.Reading change document.

In normal abap go to cdheader table cdpos table.


In below get all the cr no spific to bp.

Then read cdheader data.and below for cdpos data.

Below contained old value and new value.


From zenser vide10

If u see the product no edit option is here. because I set the status no permitted processing.

In realtime if u want the debug .the process happen in back ground.even if u put break point on aces
class the break point not trigger.beacuse activation process in back ground.then how to debug
Take the cr no.or if we want approve or reject from backend.
If u want to debug the acesse class put the beake point in save method click on only watch symbol.

If u want entire process debug .click on debugging.even if u want debug replication process from here
we can debug.

Video 11.

Se24

For check.

CL_MDG_BS_MAT_BRF_CONTEXT_LABO
Here we can read material method to see how we read the value based on cr .
Imp point.

Extending the Data Model for Master Data


Governance for Material
You can extend the data model (MM) for Master Data Governance for Material (MDGM) with new entity types and attributes. You
must extend the ERP material master data model before you extend the MM data model. This document contains information
specific to enhancing the data model for MDGM; for more detailed information on the process, see the overall document on
extending Master Data Governance content.

Note
There is no need to create a customer access class for the data model MM. The MDGM data model, MM, is preconfigured with one
reuse area: MATERIAL. This reuse area points to the access class CL_MDG_BS_MAT_ACCESS, which can handle most fields of
the pre-delivered SAP ERP Material Master.

The following scenarios for enhancing the MDGM data model are possible:
 Extend the MDGM data model by adding attributes that already exist as database fields in the pre-delivered SAP ERP material
master.
 Extend the MDGM data model by adding a reuse entity type that already exists as a database table in the pre-delivered SAP
ERP material master.
 Extend the MDGM data model by adding a reuse entity type that exists as a database table that has been added to the pre-
delivered SAP ERP material master.
 Extend the MDGM data model by adding a flexible entity type that only exists in the database tables in MDG.

Scenarios
Scenario: Adding an Attribute to the MDGM Data Model
You can extend the MDGM data model by adding a pre-delivered SAP ERP material master database field to an MDGM entity as an
attribute. You can only add database fields that are part of the SAP ERP database tables (including customer-created fields); you
cannot add customer-created tables that you added to the SAP ERP database. Use the following process to add an attribute to the
MDGM data model:
1. Enhance the MDGM data model with additional attributes. The MDGM data model is called MM.
2. Generate the model-specific structures.
3. Maintain the mapping in the Service Mapping Tool (SMT).
4. Specify field properties.
5. Configure the UI. The MDGM application configuration is called BS_MAT_OVP. It is located in the development package
MDG_BS_MAT_UI.
6. Optional step: Create a new print form. You can use the existing print form (MDG_BS_MAT_PDF) as a template.
7. Optional step: Enhance the search. Generate the business template MDG_MATERIAL again.

Note
This scenario covers the pre-delivered fields belonging to the SAP Material Master database tables and also any customer-defined
fields you have added to those tables.

Scenario: Adding a Reuse Entity Type to the MDGM Data Model


You can extend the MDGM data model by adding a pre-delivered SAP ERP material master database table to the MDGM data
model as an entity type. Use the following process to add a reuse entity type to the MDGM data model:
1. Enhance the MDGM data model with additional entity types. You can choose the attributes belonging to this entity type that you
wish to add to the MDGM data model. The MDGM data model is called MM.
2. Generate the model-specific structures.
3. Create the mapping in the SMT and assign it to the model specific structures.
4. Specify the field properties.
5. You can extend the existing MDGM application configuration (BS_MAT_OVP). It is located in the development package
MDG_BS_MAT_UI. If necessary you can also create a new application configuration. You can use the existing MDGM
application configuration (BS_MAT_OVP) as a template.

Note
You cannot add fields from a new entity type to an existing UIBB. The new fields must be added to a new UIBB. Multiple UIBBs
can be added to a single assignment block.
6. Optional step: Create a new print form. You can use the existing print form (MDG_BS_MAT_PDF) as a template.
7. Optional step: Enhance the search. Generate the business template MDG_MATERIAL again.

Note
If you have extended the material master tables with customer-defined fields (using the procedure outlined in SAP Note 44410),
which you want to include into the MDGM Data Model, you need to enhance the following data structures (corresponding to the
extended material master table) manually:
 The structures of the tables in MDG_BS_MAT_S_MAT_DATA having the suffix _X_TAB
 The structures in MDG_BS_MAT_S_MATERIAL_UI_PROP

Scenario: Adding a Customer Owned Reuse Entity Type to the MDGM Data Model
You can extend the MDGM data model by adding a customer-owned material master database table (Z table) to the MDGM data
model as an entity type. Use the following process to add a reuse entity type to the MDGM data model:
1. Enhance the following data structures (corresponding to the new, customer-owned material master table) manually:
o Add table types for the data and _X structure to MDG_BS_MAT_S_MAT_DATA. Use the same design pattern as used in
existing table types.
o Add a table type to the structure MDG_BS_MAT_S_MATERIAL_UI_PROP. Use the same design pattern as used in existing
table types.
2. Implement the BAdI MDG_BS_MAT_API_SEGMENTS_EXT
3. Enhance the MDGM data model with additional entity types. You can choose the attributes belonging to this entity type that you
wish to add to the MDGM data model. The MDGM data model is called MM.
4. Generate the model-specific structures.
5. Create the mapping in the SMT and assign it to the model specific structures.
6. Specify the field properties.
7. You can extend the existing MDGM application configuration (BS_MAT_OVP). It is located in the development
package MDG_BS_MAT_UI. If necessary you can also create a new application configuration. You can use the existing MDGM
application configuration (BS_MAT_OVP) as a template.

Note
You cannot add fields from a new entity type to an existing UIBB. The new fields must be added to a new UIBB. Multiple UIBBs
can be added to a single assignment block.
8. Optional step: Create a new print form. You can use the existing print form (MDG_BS_MAT_PDF) as a template.
9. Optional step: Enhance the search. Enhance the ERP material master search template in SAP_APPL. Generate the business
template MDG_MATERIAL again and if required, implement the BAdI BADI_SDQ_PP_SEARCH.

Scenario: Adding a Flexible Entity Type to the MDGM Data Model


You can extend the MDGM data model by adding a flexible entity type to the MDGM data model. Note that flexible entity types are
not supported in Enterprise Search and so attributes from these entities cannot be used as search criteria. Use the following
process to add a flexible entity type to the MDGM data model:
1. Enhance the MDGM data model with additional entity types using the Edit Data Model configuration activity. Choose the
attributes that you wish to add to the MDGM data model. The MDGM data model is called MM. Assign the reuse area MDG to
your entity types to declare them as flexible entity types.
2. Optional step: Generate the model-specific structures.
3. Specify the field properties. You can do this in the Define Field Properties for UI configuration activity.
4. In order to see the new fields on the UI you should extend the existing MDGM application configuration (BS_MAT_OVP). It is
located in the package MDG_BS_MAT_UI. If necessary you can also create a new application configuration. You can use the
existing print form (MDG_BS_MAT_PDF) as a template.

Note
You cannot add fields from a new entity type to an existing UIBB. The new fields must be added to a new UIBB. Multiple UIBBs
can be added to a single assignment block.
5. Optional step: Create a new print form. You can use the existing print form (MDG_MM_MATERIAL_PDF) as a template.

Note
You cannot import flexible entities using IDocs or the file upload framework.
Coding.
Check entity
Check entity.
Check entity.

Derive entity.
e.q- how to add field in uibb only but not in data model.

Ans-by feeder class .

Feeder class link

https://blogs.sap.com/2016/05/25/feeder-class-parameter-use-to-build-generic-feeder-class-in-fpm/

https://blogs.sap.com/2016/08/18/one-click-actions-in-list-uibb/

Kartik vide 10
Nothing is in left side .
Then I add some code .

Now all the attribute of feeder class came to kna1 table .


Now I want populated the data
Now data came.

Karthik video 12.

Dump solve

Here feeder class assiment missing for this uibb.


Karthik video 13-

Then I crete a mapiing.

You might also like