Exit modules in DMEE
Hello SAPers!
As promised earlier in some of my posts, here is an article on usage of exit modules in DME engine. I hope this post would be of interest for you and will give some new insights on this functionality. This post contains a lot of technical details, if you have any questions or need some clarification, feel free to post them as comments.
1.1 Templates for exit modules
Exit module is one of mapping options that can be used in DMEE. The purpose behind its usage is quite simple: whenever other mapping options are not sufficient (i.e. do not contain necessary values and / or it is not possible to get this value via combination of these options), you can leverage the power of ABAP to retrieve any value, including values from custom tables.
Before deep dive into usage of exit modules in DMEE, it is worth to consider some technical aspects. From ABAP point of view, exit module is a function module (FM) that has a predefined interface (i.e. combination of input / output parameters of certain types) and is called during execution of standard program to enhance its logic. The notion of FM with predefined interface is of paramount importance meaning that you cannot simply ask a programmer to write FM that will execute some logic. You should know at least what is the interface that is supported by DMEE. Thus, the best way to create new exit module is to find a standard template and copy it to Z* copy (in transaction SE37).
SAP provided a couple of standard templates, which can be logically divided into two groups:
- FM templates with basic interface (DMEE_EXIT_TEMPLATE and DMEE_EXIT_TEMPLATE_ABA);
- FM templates with extended interface (DMEE_EXIT_TEMPLATE_EXTENDED and DMEE_EXIT_TEMPLATE_EXTEND_ABA).
The main difference between these two interfaces is that extended interface allows you to check not only the value of DMEE tree node that is currently being processed but also the values in other nodes, which were generated previously. Besides, extended interface is a bit more flexible when it comes to coding. These details will be explored later based on some examples. You can also check OSS note OSS note 373145 (DMEE: enhanced interface for exit module), that delivered extended interface for additional technical details.
1.2 Overview of interface parameters
Below you can see screenshot of typical extended interface.
This interface has the following importing parameters:
- I_TREE_TYPE – type of DMEE tree (e.g. PAYM for payment related trees, UMS1 / UMS2 / UMS3 for advance return for tax on sales / purchases etc.);
- I_TREE_ID – ID of DMEE tree.
Combination of these two parameters uniquely identify DMEE tree and are used to access its settings in t-code DMEE. On technical level, basic templates DMEE_EXIT_TEMPLATE and DMEE_EXIT_TEMPLATE_ABA have slight differences in ABAP types of these two interfaces (check in SE37), otherwise they are the same.
- I_ITEM – importing parameter that contains the values of source fields for a specific application (e.g. for tree type PAYM, this parameter will contain the values of all fields from structures FPAYH, FPAYHX, FPAYP);
- I_PARAM – SAP recommends not to use this parameter;
- I_UPARAM – is a parameter storing values of format-specific structure;
- I_TAB – table that stores texts which comprise information relevant for note-to-payee.
- I_EXTENSION – information about values in other nodes. This parameter is available in extended interfaces only. It consists of several sub-components, which will be covered a bit later.
The interface has a couple of exporting parameters, which differ only in type:
- O_VALUE – output value in a generic type;
- C_VALUE – character value;
- N_VALUE – numeric value;
- P_VALUE – currency value.
Essentially, FM should return value using type that corresponds to the type of tree node indicated in DMEE tree. For instance, you will have empty field, if FM returns C_VALUE for a node that has type N.
1.3 Overview of extended parameters
As was already mentioned above importing parameter I_EXTENSION is available for FM with extended interface only. Overview of parameter’s components and their types is summarized in table below. You can check each type in transaction SE11 for more details.
As you can see, the only difference between templates with extended interfaces is in component types, whereas their internal structures are the same. From history point of view, template DMEE_EXIT_TEMPLATE_EXTENDED was introduced earlier. Starting from release 500 of SAP_APPL component template DMEE_EXIT_TEMPLATE_EXTEND_ABA was added.
Parameter I_EXTENSION-NODE contains a lot of technical details related to the current node that is being processed. Commonly useful would be the field NODE_ID, which corresponds to Node ID as configured in DMEE:
Parameter I_EXTENSION-NODE_VALUES contains technical parameters and output values of current node, whereas parameter I_EXTENSION-REF_TABLE contains a table with values of other nodes.
Please note the following restriction! In extended interface, you can check the values of other nodes, only if these nodes have reference ID.
1.4 Usage of exit module
There are lots of possible scenarios, where user exits might be used. Quite common requirement is to retrieve some requisite of company code e.g. from table T001Z that stores company code additional data (t-code OBY6). Simple example of exit module for this purpose can be found below. This exit module is checking the values of source structures for payment program, does selection of necessary requisite into local variable and returns it to DMEE tree. This approach is universal i.e. logic of the exit module doesn’t depend on the settings of particular DMEE tree. That’s why one FM can be reused across different DMEE trees.
FUNCTION Z_DMEE_COMPANY_TAX_NUMBER.
*"--------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_TREE_TYPE) TYPE DMEE_TREETYPE_ABA
*" VALUE(I_TREE_ID) TYPE DMEE_TREEID_ABA
*" VALUE(I_ITEM)
*" VALUE(I_PARAM)
*" VALUE(I_UPARAM)
*" REFERENCE(I_EXTENSION) TYPE DMEE_EXIT_INTERFACE_ABA
*" EXPORTING
*" REFERENCE(O_VALUE)
*" REFERENCE(C_VALUE)
*" REFERENCE(N_VALUE)
*" REFERENCE(P_VALUE)
*" TABLES
*" I_TAB
*"--------------------------------------------------------------------
data:
ls_item type dmee_paym_if_type,
lv_stcd1 type stcd1.
ls_item = i_item.
select single paval
from t001z into lv_stcd1
where bukrs = ls_item-fpayh-zbukr
and party = 'SAPU01'. "individual tax number of company code in Ukraine
if sy-subrc is initial.
c_value = lv_stcd1.
endif.
ENDFUNCTION.
To use exit module, choose the respective option on Mapping procedure tab and indicate its name on the source tab.
Overview of assignment on the source tab can be found below:
As was mentioned previously, extended interface offers some additional flexibility. Let’s consider a case, when you have two nodes in tree that should contain company code names – one in English, another in local language (e.g. Ukrainian). Besides, let’s assume that the format implies that the value of this node should be empty if country of payee is Russia. How can this requirement be met?
You can solve it by creating two nodes referencing the same exit module besides one technical node with reference ID “VEND_COUNTRY” that will store the reference to country of vendor. Source code might look as follows:
FUNCTION Z_DMEE_COMPANY_NAME.
*"--------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_TREE_TYPE) TYPE DMEE_TREETYPE_ABA
*" VALUE(I_TREE_ID) TYPE DMEE_TREEID_ABA
*" VALUE(I_ITEM)
*" VALUE(I_PARAM)
*" VALUE(I_UPARAM)
*" REFERENCE(I_EXTENSION) TYPE DMEE_EXIT_INTERFACE_ABA
*" EXPORTING
*" REFERENCE(O_VALUE)
*" REFERENCE(C_VALUE)
*" REFERENCE(N_VALUE)
*" REFERENCE(P_VALUE)
*" TABLES
*" I_TAB
*"--------------------------------------------------------------------
data:
ls_item type dmee_paym_if_type,
ls_ref_node type dmee_node_if_aba,
lv_name1 type text40.
ls_item = i_item.
" Dynamic selection of different values for different node IDs
case i_extension-node-node_id.
when 'N_5409292620'.
select single name1 title
from adrc into lv_name1
where addrnumber = ls_item-fpayhx-adrnr
and nation = space. " Standard version
c_value = lv_name1.
when 'N_5409292630'.
select single name1 title
from adrc into lv_name1
where addrnumber = ls_item-fpayhx-adrnr
and nation = 8. " Ukrainian version
c_value = lv_name1.
endcase.
" Checking value of another node
read table i_extension-ref_table
with key ref_name = 'VEND_COUNTRY'
into ls_ref_node.
if sy-subrc is initial and ls_ref_node-c_value = 'RU'.
clear: c_value.
endif.
ENDFUNCTION.
As you can see, usage of exit modules with extended interface allows you to populate DMEE nodes dynamically (based on their ID) and also allows you to read the values of other nodes (i.e. node with reference ID “VEND_COUNTRY”) and link some logic to these values. This approach might be useful when you have several nodes with similar purpose – then you can create one FM that centralizes their logic. However, major drawback of this approach is that by linking values to node IDs, you loose the advantage of flexibility i.e. your exit module becomes dependent on one DMEE tree and cannot be re-used without modifications in another DMEE for similar purpose.
I hope this post was useful! Your suggestions and comments are welcome!
Regards,
Bohdan Petrushchak
P.S. Examples in this post might seem quite trivial, but they are provided for demonstration purposes only and are intended to deliver the basic idea behind this functionality.
Very useful blog. Thanks for sharing this with the community.
Thanks,
Hakim
Hi Abdul,
Thanks for your feedback!
Regards,
Bohdan
Outstanding.
Leo
Hi Len,
Thanks for appreciation:)
Regards,
Bohdan
Hi Bohdan.
Recently I’ve found out that DMEE exits now have different interface for the incoming files.
*” IMPORTING
*” REFERENCE(I_INTERFACE) TYPE DMEE_EXIT_INTERFACE_INCOM_ABA
*” EXPORTING
*” REFERENCE(E_VALUE)
Any hint how to use it?
Hello Sergey,
Thanks for pointing this out. I probably have to add small clarification to this post - it dealt primarily with DMEE-engine issues related to generation of outgoing file. I do not have any experience dealing with user exits with template DMEE_EXIT_INTERFACE_INCOM_ABA, but upon quick check it seems that this particular interface is used for handling of incoming files. Thus it is most probably used in DMEE-trees with type MCSH "Conversion of Incoming File to MultiCashMCSH Conversion of Incoming File to MultiCash", which can be used to convert non-standard text-based bank statement to Multicash format, whereas I've been discussing tree type PAYM.
From usage point of view, there shouldn't be any difference, you should stick to general rules for usage of exits and take into account fields available for processing (via definition of type DMEE_EXIT_INTERFACE_INCOM_ABA in SE11).
Regards,
Bohdan
Excellent article Bohdan! This was very enlightening, thank you for sharing!
Hi Bohdan!
Thanks for this great article!
I have an issue trying to build a tree in DMEE.
Some fields that I have in my tree has zeros (0) and others have white spaces, and I need to erase these white spaces and zeros.
Example: 0000000045 --> I need: 45 and similar with white spaces.
What do you think is the best approach to implement this scenario?
I'm trying to implement the FM DMEE_EXIT_TEMPLATE_ABA in every field that I need to change in this way but I'm having some troubles:
I think that I have to build a non-generic FM like this, maybe a FM for a numerics fields using N_VALUE instead i_item field and for the chars fields use C_VALUE
If you had similar scenario or something like this problem, I would be very appreciated to hear what is the best approach
Thanks in advance.
Hi Pablo,
You do not have to implement any user exits to do that. You can just play with conversion functions in each node of DMEE-tree. It's a customizing and you do not need any ABAP-efforts to do that.
Regards,
Bohdan
Thanks Bohdan for your reply, I told the same thing to the functional team, but they insist that they don't have a C.V that meet their requirements. They define a node with a 18 digit numeric field and if they receive a 3 digit, they don't wat to build the tree with for example:
123 ;
they want this:
123;
I will take your advise and try to find playing with de conversion function to solve this problem.
Thanks again for your response.
Regards,
Hi Pablo,
Sorry for delay:) Could not get my hands earlier. If I understand everything correctly, there should not be any problem. You can use any C.V. that is supposed to display amount values with "Left-Justified" alignment e.g. AL.2. Besides, make sure the the node has field type "P - Currency". See an example below.
Regards,
Bohdan
Hi Bohdan,
Need a help.
I am trying to implement EXIT FM to display XBLNR values for mentioned Run ID and Date and concatenating each XBLNR values in a string variable and adding '#' after each 35 char. If the total string length is more than 140 chars then i am able to see 3 # in my DMEE but if the length than 105 then i am seeing only 2 # in DMEE file. Can you help me with this.
Also i wish to know how can i debug DMEE tree.
Regards
Ajay
Hi Ajay,
It seems that you're trying to generate a note to payee that contains a list of vendor invoice numbers. Could you please provide the source of your FM? Basically you can specifically check the length of the string in your FM and if it is less than 105 characters, add # explicitly.
Please refer to this blog post for details on debugging: https://9m2tpt.blogspot.com/2016/01/debugging-dmee.html.
Regards,
Bohdan
Thanks for sharing such important information. I come across a similar situation where 2 parallel track using the same DMEE tree. One is from F110 and F111.
Hi Sandip,
Thanks for feedback! The track in this case is the same - call it FI, RTR, AP etc. - it doesn't really matter. F110 and F111 are just two different transactions fot the same purposes - to post payments / generate payment orders. The only difference is that the first one works primarily for regular open items (vendor invoices, down-payment requests, partial payment requests), whereas the second one works primarily with payment requests i.e. also called payment form payments. I actually plan an exsensive blog post on this topic in near future:)
The fact that both F110 / F111 use the same tree - it's actually good approach - why create separate trees if you can re-use existing one?
Regards,
Bohdan
Hi Bodhan,
Yes both F110 / F111 are using the same tree. I am working on one requirement, where the user uses FIBLFFP (F111) wants to see Payment Ref (KIDNO) in XML.
DMEE tree has reference filed but it's used only for F110.
I will copy the existing one and create the new one, then with help of function exit if payment from F110 than use node 1, and when payment from F111 use node 2.
Big thank you for your blog which helps me to think out of the box.
Do you know any filed which indicate if it is an F110 or F111 payment?
Regards,
Sandip
Hi Sandip,
I would suggest you to check the values in fields FPAYP-ORIGIN or FPAYH-DORIGIN. The following would be the values that would help you to identify the origin of the operations:
You can also check another post, where I described these fields.
Regards,
Bohdan
Hi @Bohdan Petrushchak
This document is extremely helpful for me to solve one urgent issue with some modification. Thanks a ton for sharing wonderful document.
Just want to add here that if any one want to change any of FPAYH, FPAYHX and FPAYP . Find node of field and DO NOT MODIFY or PASS directly this value instead of that pass value in C_VALUE that will update your field.
Hi Bodhan
Ive been reading your blogs and I found this one DMEE related.
I have an issue with my DMEE, I have created a counter in each line (named 3)
My concern arise because I dont now why my counter is getting reset when it reach number 10.
any thoughts?
thanks
Hi Bohdan Petrushchak
I have a requirement to customize the reference field under USTRD node. I have written the code in the user exit to update the C_VALUE. But in the XML file the USTRD node itself is not available. We tried removing the conditions maintained for USTRD node but still it is not visible in the XML file.
Could you please help me on this?
Hi Deepthi Panicker ,
I'm not sure I would be of any help here. Too many variables and no system access. But just in case, check - maybe you have XSLT-transformation assigned to DMEE-tree, which is clearing the values. Check our this post on transformations.
Besides, also put a break-point into source code and check if exit is called at all. If it is called and it is passing the value back to calling problem, than xslt-transformations should be definitely checked. If exit is not even triggered - then check conditions. Remember, you might conditions on different tag levels in XML - if there is condition on any other parent condition above USTRD, then it won't be filled.
Regards,
Bohdan
Hi Bohdan,
Bank has provided us the ADAPTER and Predefined DMEE (which has FM for the Nodes) but when I copy the FM (provided by bank) to new FM and update the node with the newly copied FM, this NEW FM is not been trig-erred (in Debug) however if I revert back DMEE with the FM (Provided by the bank) Code will be trig-erred (in Debug). Am i missing anything here?
Need your suggestions..
Hi Bohdan,
Your documentation is more helpful to us. Thanks for your support and keep growing.
Hello Bogdan,
regarding tree format and payment through F110 I have a question: I have 2 different formats (CGI_XML_CT and CH_XML_CT) which are assigned to different payment methods (E for CH_XML_CT and U for CGI_XML_CT) and there is only one company code. In OBPM4 to this company code, to the same bank account are assigned both of these XML formats, but of course with different variants for each of them.
My question is what will happen in F110 for Payment Files when both payment methods are selected? Will be two XML Files generated or only one? I practically selected both E and U, same company code and and that bank account has a different variant in SAPFPAYM for XML formats.
Is it ok for doing this or at least possible?
Thank you and kind regards,
Ana Maria
Hi Ana-Maria,
Well... that's a good question. Honestly never tried anything like that and cannot answer your query. Theoretically yes, you're supposed to receive two separate XML-files. FDTA as it seems doesn't restrict you to the number of files.
Question is different: why should you indicate two different methods under one run? What are gaining by it? Why not create two separate proposals?
Regards,
Bohdan
Hi Bohdan,
I have a user demand which I do not find how to make it. they want one file in FDTA (with the same DME) for each vendor they put in their F110. Means 2 vendors 2 files, 3 vendors 3 file etc...
do you know how i could do this customizing,
thank you very much,
Jerome
hi Bohdan,
could you have any suggestion to help me please?
Thank you,
Hello Bohdan,
This blog post and the others you posted on DMEE subject are very useful. Following this one I've successfully implemented an exit without problems.
But now I have a requirement to include withholding data (WITH_ITEM records) as a whole new segment (N iterations), in a PAYM tree (to be used integrated in F110). As withholding data is not included in available structures (FPAYH / FPAYHX / FPAYP), it seems to me an exit like the ones in this post is not enough, as I would need one for each node / field (reading the same record several times). I would need instead some sort of exit to populate an additional table once and then loop it to generate the segments...
Which options do I have for that? Maybe copying and modifying the event modules linked in customizing (e.g. FI_PAYMEDIUM_DMEE_00)?
Thank you!
Hi Alejandro,
From what I can see the structure FPAYH contains some data on withholding tax e.g. fields WQSTE/WABZG. Is this information not enough? Otherwise, I do not see a problem with usage of standard user exits for DMEE for retrieval of withholding tax information.
Regards,
Bohdan
Yes, I noticed those fields in FPAYH but they are not enough, what we need is to generate a whole new segment level, with as many lines as WITH_ITEM records exist for the current header.
To give you an idea, something similar to WTRE tree types (program RFIDYYWT), but included in a PAYM tree type.
Is that possible with exits?
EDIT: Solved using BAdI: DMEE_BADI_01 (method MODIFY_OUTPUT_FILE)
Hi Sir,
Nice and really Good Blog for DMEE, can you share your mail id Plzee.
I have made the tree based on Bank requirement, but i am stuck when we give payment to vendor if Vendor having CITY Bank account and customer also having CITY Bank but diffrent state within Country. Bank requirment is if Vendor having CITY bank then while DMEE file generation output file there is one colmun for Product Code , in Product code contains if City Bank payment to Vendor then print in Product Column CITC other bank as Like HDFC, ICICI then Print in Product Code NEFT or RTGS, based on Amount.
Here we need the Client having CITY Bank within Country different City and the vendor also having a CITY Bank account in a different city, but while transactions through DMEE flat output file in the column should be print CITC.
What should we do in this case?
Thanks & Regards
Pranav Kumar
Hi Bohden,
I have a doubt,
The importing parameter ITEM seems to have only one invoice document details at any given time, How to configure it in a way that the EXIT gets hit for every invoice number.
We implemented an EXIT for f110, but only for last item the exit is hit.
Thanks and Regards,
Pruthvi.
Hi Pruthvi Kosala,
FM is called for each payment document i.e. roughly speaking for every entry of payment run in table REGUH (where XVORL = " " ). You might have a grouped payment i.e. one payment for several invoices at the same time (one entry in table REGUH corresponds to several entries from table REGUP). In this case, the design might be more complicated, because you will need to take it into account specifically. Otherwise, if your FM is called for one payment, but not for another - please check the configuration. Maybe there is some condition for the node of DMEE tree that skips FMs.
Regards,
Bohdan
Hi Bohdan,
Beautiful blog! Thanks for sharing. I was going through other blogs on DME shared by you . Quite informative and handy!
We have a requirement to add a segment to the structure on certain condition but The Exit FMs have the option to modify the values but no access to the Tree to add or remove a Segment. Is there a way we can add, delete or modify a Segment based on other field value?
Many thanks
Diptimay
Hi Diptimaya Mishra,
I'm not sure I understood your requirement. If you need to add a new segment to the structure of the DMEE-tree - then it's possible. Exit FMs can fill the value for a segment based on the values of other nodes of DMEE tree. Please check the post carefully, it describes how it can be done e.g. via FM Z_DMEE_COMPANY_NAME.
Regards,
Bohdan
Hi Bohdan, thanks for your reply. Our requirement is to add bunch of segments dynamically depending on few segment values on the top nodes. We want to read the segment of a higher node and add a segment if dependent segment having a desired value.
So we dont want to add segment at design time to avoid the presence of it by default. The segment needs to be added only at run time if and only if it satisfy the value of a segment at higher node.
Looking forward for your suggestion.
Many thanks
Diptimay
Hi Diptimaya Mishra,
In that case, please check out BADI DMEE_BADI_01. It can be used to adjust the resulting DMEE tree. But if you ask my personal opinion, I still suggest to include all necessary segments into DMEE-tree. Trust me, it would be much easier to maintain it in the future. Sooner or later, the key person who designs the implementation of BADI DMEE_BADI_01 will leave the project and if there will be any issues in future, it would be much more difficult to detect them. This BADI is not used very often, therefore it will take either an experienced FI consultant to check it or it will take a lot of debugging for ABAP person to find this enhancement.
Regards,
Bohdan
Appreciate Bohdan! Will explore the suggested BADI. And completely agree, its will bring bigger challenges later.
Many thanks and regards
Diptimay
Hello Bohdan,
Thanks for the Blog.
I have a requirement to add the one field in XML which is will get triggered by the T-Code F110, So I have implement the Exit function in DMEE for the write down the logic in the custom FM which was copied from standard FM (DME_EXIT_TEMPLATE_EXTEND_AB).
but I'm not able to get into the NODEID position in the FM when its run that why my logic is not implementing.
Any ideas how can I able to do so.
Thanks and Regards,
Amair Ahmed.