Professional Documents
Culture Documents
00 Development guideline for implementing Tax Engine user exit for exchange of custom fields with External Tax Engine.
VERSION 1.0 JULY 2012
CHANGE LOG
Change Version 1.0 Name Sandeep Divakaran Date July, 2012
CONTENTS
Change Log.....................................................................................................................2 Contents .........................................................................................................................3 1 Motivation to run the configurator on VMC ...................................................5 2 Developing Tax Engine User Exit...............................................................................6 2.1 Setting up Java..............................................................................................6 2.2 Setting up Eclipse...................................................................................6 2.3 Downloading the tax engine-libraries ....................................................................6 2.4 Setting up the eclipse project..................................................................................7 2.5 BAdi implementation to enable passing of custom input fields from ABAP to Tax Engine JAVA............................................................................................................7 2.5.1 Using transaction properties to supply custom input fields to be exchanged with External Tax Engine...............................................................................................8 2.51.1 Customizing setting............................................................................................8 2.5.1.2 BAdi implementation to fill the runtime values to the custom fields.....9 2.5.2 Using pricing attributes to supply custom input fields to be exchanged with External Tax Engine.......................................................................................................9 2.5.2.1 Customizing setting...........................................................................................9 2.5.1.2 BAdi implementation to fill the runtime values to the custom fields. ..........9 2.6 Creating and registering Tax Engine user exit....................................................10 2.6.1 Extend the exit adapter class. ...........................................................................10 2.6.2 Overriding the methods of the adapter class...................................................10 2.6.2.2 Overriding the method preProcessRequest of the adapter class................10 2.6.2.3 Overriding the method postProcessRequest of the adapter class..............12 2.6.2 Registering of user exit.......................................................................................13 2.7.5 APIs to enable retrieval of custom fields from Tax Engine.............................13 2.7.5.1 Retrieving custom fields in an ABAP context................................................13 2.7.5.2 Retrieving custom fields in a non-ABAP context..........................................14 2.7 Creating a jar from the Tax Engine user exit.......................................................14 2.8 Uploading the Tax Engine user exit......................................................................14 2.9 Deleting uploaded Tax Engine User Exit..............................................................15 Debugging.....................................................................................................................15 3.1 Set VMC in Debug Mode .......................................................................................15 3.2 Attach Eclipse Java Debugger..............................................................................16 4 VMC logging and tracing overview..........................................................................16 4.1 Prerequisites..........16 4.2 Using VMC logging and tracing ...........................................................................17 4.2.1 Use........................................................................................................................17 4.2.2 Features ...............................................................................................................17 4.2.3 Activities ..............................................................................................................18 4.3 Displaying Log Messages..................................................................................18 4.3.1 Use........................................................................................................................18 4.3.2 Procedure.........................................................................................................18 4.4 Displaying and Changing Log Settings................................................................19 4.4.1 Use........................................................................................................................19
Debugging Each user can dynamically switch to and fro between normal operation and debugging.
5
2.3 Downloading the tte engine - libraries Following steps will download the tte engine libraries:
Start your SAP GUI, log in and start transaction /SAPCND/UE_DEV. Create a folder to place the classes. Check the 'download' section, type the above folder (or use F4 to navigate there) and press F8 to download the classes into the already created folder, lets call this folder $TTE_CLASSES$ for further references. The class files can be found in $TTE_CLASSES$/lib_api.
All you have to do is including the $TTE_CLASSES$/lib_api to your projects libraries. This folder includes all needed libraries from com.sap.taxes.* in addition to pricing and configuration classes.
2.5 BAdi implementation to enable passing of custom input fields from ABAP to Tax Engine JAVA
There are two ways to pass custom input fields from ABAP to Tax Engine JAVA so that it can be passed from Tax Engine to External Tax Engine: Using transaction properties to supply custom input fields to be exchanged with External Tax Engine. Using pricing attributes to supply custom input fields to be exchanged with External Tax Engine.
2.5.1 Using transaction properties to supply custom input fields to be exchanged with External Tax Engine 2.51.1 Customizing setting
In the above customization, transaction properties have to be defined, mentioning the transaction property types and the values these transaction property
types could take. These transaction property types would be the internal field names used when mapping of custom exchanged fields.
2.5.1.2 BAdi implementation to fill the runtime values to the custom fields.
The BAdi BADI_TTE_DOCUMENT has to be implemented where the custom fields would be set with their internal field names to their corresponding values. The internal field name should be the same as the transaction property type defined in customizing earlier. BAdi BADI_TTE_DOCUMENT has method TTE_INPUT_DOC_CHANGE which has parameter CT_TRANPROP of type TTEPDT_TRANPROP_COM_TT. The type TTEPDT_TRANPROP_COM_TT is a table type with line type: ITEMID TRANSPROPERTYTYP TRANSPROPERTYVAL CHAR 32 CHAR 4 CHAR 30
Using the above data, the custom fields could be filled with appropriate values at runtime. Also, it should be noted that the internal field name would be the same as the transaction property type.
2.5.2 Using pricing attributes to supply custom input fields to be exchanged with External Tax Engine 2.5.2.1 Customizing setting
The pricing field catalogue has to be extended to incorporate the custom field names. This would be the internal field names.
2.5.1.2 BAdi implementation to fill the runtime values to the custom fields.
The BAdi CRM_COND_COM_BADI has to be implemented where the custom fields would be set with their custom internal field names to their corresponding values. The custom internal field name should be the same as the transaction property type defined in customizing earlier. BAdi CRM_COND_COM_BADI has method ITEM_NAME_VALUE which has parameter CT_ITEM_NAME_VALUE of type PRCT_ATTR_NAME_VALUES_T. The type PRCT_ATTR_NAME_VALUES_T is a table with line type: ATTR_NAME SEQ_NUMBER ATTR_VALUE CHAR 30 NUMC 2 CHAR 50
Using the above data, the custom fields could be filled with appropriate values at runtime. Also, it should be noted that the custom internal field name would be the same as the pricing attribute name.
2.6.2 Overriding the methods of the adapter class 2.6.2.2 Overriding the method preProcessRequest of the adapter class
The method preProcessRequest would be called by Tax Engine just prior to the call to External Tax Engine. This could be overridden to provide the mapping of custom fields to be used by Tax Engine and also transform the custom fields before passing it over to the External Tax Engine. The following parameters are part of the method signature of method preProcessRequest: parameter tteInDoc of type ITteInputDocumentUserExit parameter tteInItem of type ITteInputItemUserExit parameter inToExtFldMapper of type IExtTaxInputFieldMapper parameter extFldValueSupplier of type IExtTaxDirectInputValueSupplier
Parameter Type ITteInputDocumentUserExit has the method: getInputItems() This can be used to retrieve all the input items
Parameter Type ITteInputItemUserExit has the methods: getItemID() This can be used to get the item id of the relevant item as a string
getTransactionProperties() This can be used to get the transaction property container as a type ITransPropertiesUserExit. ITransPropertiesUserExit has method get(String type) to get specific transaction property type - value as a type ITransPropertyUserExit giving the property type name as string. Further, ITransPropertiesUserExit has methods: getTransPropertyTyp() This can get the relevant transaction property type as string. getTransPropertyVal() This can get the relevant transaction property value as string.
Parameter type IExtTaxInputFieldMapper has the method: setInternalToExternalFieldMap(String intFldName, String extFldName) This can be used to set the which custom internal field is mapped to which custom external field by providing the field names for the custom internal field and the custom external field as strings.
Parameter type IExtTaxDirectInputValueSupplier has the method: setExtFldValue(String extFldName, String value) This can be used to set a specific custom field value for an custom external field name, by providing the custom external field name and the specific value for the custom external field as strings.
The above mentioned parameters and methods can be used to transfer custom fields into External Tax Engine. There are two types of mapping mechanisms provisioned: Input Field mapping This can be used to provide mapping of which custom internal field would be mapped to which custom external field by specifying the custom field names in the mapping. Parameter inToExtFldMapper (type IExtTaxInputFieldMapper) of method preProcessRequest can be made use of to achieve this. Direct Value Setting This can be used to provide a specific value to be set into a custom external field by specifying the custom external field name and the custom external field value. This is especially useful if you would want to transform the value provided by the custom internal field in some way in the user exit before passing it over to the External Tax Engine. Parameter extFldValueSupplier (type IExtTaxDirectInputValueSupplier) of method preProcessRequest can be made use of to achieve this.
Parameter Type ITteOutputDocumentUserExit has the method: getOutputItems () This can be used to retrieve all the input items
Parameter Type ITteOutputItemUserExit has the methods: getItemID() This can be used to get the item id of the relevant item as a string
Parameter type IExtTaxOutputFieldMapper has the method: setExternalToInternalFieldMap ((String extFldName, String intFldName) This can be used to set which custom external field is mapped to which custom internal field by providing the field names for the custom external field and the custom internal field as strings.
The above mentioned parameters and methods can be used to transfer custom fields from External Tax Engine into Tax Engine. This can be done only via Output field mapping mechanism. This can be used to provide mapping of which custom external field would be mapped to which custom internal field by specifying the field names in the mapping. Parameter extToInFldMapper (type IExtTaxOutputFieldMapper) of method postProcessRequest can be made use of to achieve this.
The libraries upload needs: A modifiable workbench request which must be already existing An ABAP package created by the customer beforehand The path to customer_tte_userexits.jar. The uploading is triggered by the execute button or pressing F8. The jar-file shall only contain customer coding. Uploading any other class belonging to a package com.sap.* than to package com.sap.taxes.userexit would possibly overwrite existing classes and therefore lead to an unexpected behaviour of SAP applications running on VMC. If you upload user exits to an (ABAP) package that was already used for uploading user exits, all Java classes previously uploaded to the package are deleted and replaced by the new Java classes contained in the jar-file. The VMC can cope with hot-deployment of Java-classes. No server restart is necessary. If you upload an empty jar-file, you delete the previously uploaded Java classes. The transport of Java classes is as transparent as the transport of ABAP code.
3 Debugging
3.1 Set VMC in Debug Mode
The logical application server is usually hosted on different servers and load balanced via the message server. To debug the VMC the user has to know on which host his work process run. In the SAPGUI menu System -> Status the Server name (first part) is displayed. On the next page (3rd button) also the corresponding IP address is given. Switching between hosts of one server can be done via transaction sm51. Run transaction sm52 to display the available VMCs. This window will later show the servers running virtual machines and also the debug state and port of each one. A VMC work process switches into debug mode when a program flow from ABAP to Java (RFC function module) is passed and ABAP was in debug mode (with /h). Debugging RFCs from the WebUI is quite hard and has to be reworked!
While running the transaction (e.g. order processing) each call to pricing will hold and with a step-into debugging into the RFC module (F5) a VMC debug port will be activated. This VMC will stay attached as long the ABAP transaction runs.
The debugging view will normally popup automatically and a successful attachment will show all working threads of that VMC work process. Because debugging real RFC-calls is quite hard the following chapter explains tracing and logging concepts. 10
The profile S_VMCADMIN_2 suffices to change the log levels and changing jarm-settings. Thus this profile is the minimum prerequisite to work with tracing and logging! In transaction SM52 you can see an overview of all the running Java VMs in the VM Container
4.2.2 Features
The VMC logging and tracing system is called up by Java programs to output messages that enable errors to be found later and to reproduce the program flow. These Java programs can be components of the VMC environment itself, or even applications that use the VMC to execute Java code. The Java program uses a log controller object created earlier to write the message. There are two types of log controllers. _ Categories to write the log messages. These correspond to logical components such as /system/database, the parts of the name are separated by a forward slash (/). _ Locations to write traces for developers and administrators. The names of locations correspond normally to
Java class names or packages, the parts of the name are separated by a point. When you choose Log Administration=>Log Display on the left-hand side, a new tree appears. 11 This contains the hierarchical structure for the locations. Beneath this the categories are listed. Each message has a Severity level that together with the log controller setting determines whether the message is output or not. This allows you to restrict the number of messages to those of real interest. Each log controller can enter separate settings. The path-like names of the log controllers enable them to be uniquely arranged in the tree, as settings are passed downwards in the tree. For instance, if a location is configured in such a way that it only outputs traces with a severity of at least WARNING, this is also valid for all the subordinate locations, unless these have their own settings.
4.2.3 Activities
You can view the log messages in the log administration in SM53, and you can also display and change the log settings. The sections below contain more details:
This directory also contains diverse trace files whose names begins with dev_.As you can configure which log controller writes to which file, there is no default log controller and file.
4.3.2 Procedure
In the left frame of the VMC administration (SM53) choose Log Administration =>Log Display. Select a log by choosing in the top left of the hierarchical structure the available locations and categories as the sources of the messages for which you want to see the logs. If a node of a tree is selected or deselected, all the nodes of the subtree are automatically selected/deselected too. Use the filter settings to further restrict the amount of messages found. To search specifically for errors you can for instance hide messages with a severity smaller than WARNING and restrict the time period. Errors that occurred in a specific session may be traced more easily if messages from this session only are displayed. You can restrict the number of hits in the lower left area according to the following criteria: Severity: Severity of the message. Displays only messages with the selected or higher level of severity.
Log Name: Displays only log messages with this name (for very specific searches). User: Displays only log messages that were created under the user specified. Client: Displays only log messages that were written in this client. Session: Displays only log messages from this session. You can view the session IDs of the active sessions if you choose Sessions in the initial screen of the VMC system administration and then look in the column Session ID. Thread: Displays log messages from this thread only (for very specific earches) Messages by Date/Time: Displays only log messages written after this date and time. Messages up to Date/Time: Displays only log messages written before this date and time. Choose the icon Update Log Messages. The requested log messages are now displayed in the top right area. A maximum of 1000 messages can be retrieved at one time. If more than 1000 messages exist, this is indicated in the status bar and you can scroll through them using the scrolling buttons in the function key menu bar. The messages last transferred are listed in the table. You can sort them, search them, or export them to a file. If a single line display in the table is not sufficient, you can view individual messages in detail by double-clicking on them.
4.4.2 Procedure
In the left frame of the VMC administration (SM53) choose Log Administration=>Log Configuration. The screen appears where you can configure the log settings according to your wishes. You can select any location or category you like and change their severity settings. Any changes and their effects on lower-level nodes are immediately visible in the tree displayed. You can also insert log controllers unknown up to now, by entering the full name in the input field and copying the relevant setting.
4.4.3 Result
The changes you made are effective immediately, but they are not saved they are valid only until the VM is restarted or reset.