Hotfix - Errors occur in K2 connect if special characters are used in ServiceObject Method names or in the XML property when trying to pass information to SAP

  • 16 February 2021
  • 0 replies
  • 17 views

Userlevel 5
Badge +20
 

Hotfix - Errors occur in K2 connect if special characters are used in ServiceObject Method names or in the XML property when trying to pass information to SAP

KB000526

PRODUCT
K2 connect
SEE ALSO

K2 connect for SAP

LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

 

Introduction

 

The following issues were encountered while using K2 connect for SAP
  1. When an underscore is used in the method name an exception is thrown
  2. When an Ampersand “&” is used as part of the XML property and later passed to SAP an exception is thrown

 

 

 

Error Scenario

Note: The following two errors are not necessarily related, however since the same assembly is used for both these two functions, the same installer is used to repair the errors.

For Error 1: When a Service Method includes an underscore in the name, for example New_Method, an exception is thrown
For Error 2: When a string, that is passed as an XML data field contains the special character “&”, an error is thrown. The reason is that the character is not recognized unless formatted correctly as “&”

Steps to Reproduce the error

Error 1

Note: To reproduce these errors the following items need to be created to replicate the issue. If you have existing items in place, they can be run against your environment to reproduce the error. It’s not recommended that this test be done against a live environment.
  1. Create a new K2 connect Service Object


     
  2. Add a new service, and name the service
  3. Add a new Custom Method to the new service that was created
  4. Change the name of the method to example “New_Method”, an underscore in the name is required to reproduce the error
  5. Add the following Parameters to the function
    [inDate] [Flat] [DateTime] [In]
    [inFirstName] [Flat] [String]  [In]
    [inLastName] [Flat] [String]  [In]


     
  6. Select a BAPI for example BAPI : “BAPI_EMPLOYEE_GETDATA”and dragged it into the “Internal Functions” Table
  7. Add a parameter : “outEmpData” and configured it as follows :
    1. Declarer : drop the declarer drop down list and select I
    2. n the Structure Definition page select to copy from a template
    3. Select “BAPIP0002B” and select the fields you want use


       
    4. Click Ok
  8. Return to the Function Screen, and from the function Interface configure the “outEmpData” as follows:
    [outEmpData] [Structure] [NewStructure] [Out]

    ]
  9. Publish the Service Object
  10. The “SmartObject Service Tester” can be used to test the Service Object
  11. Locate the Service Object and select to “Execute SmartObject”


     
  12. Type in some data and execute the Service Object

For Error 2

Note: To reproduce these errors the following items need to be created to replicate the issue. If you have existing items in place, they can be run against your environment to reproduce the error. It’s not recommended that this test be done against a live environment
  1. Create a new service object and add a blank Service


     
  2. Add a Custom method and rename the method to : “CreateEmpAddress”
  3. Add the following parameters
    [inEmpID] [Flat] [Int64]  [In]
    [inBeginDate] [Flat] [DateTime] [In]
    [inEndDate] [Flat] [DateTime] [In]


     
  4. Locate the following BAPI files and drag them into the “Internal Functions” table
    BAPI_EMPLOYEET_ENQUEUE
    BAPI_ADDRESSEMP_CREATE
    BAPI_EMPLOYEET_DEQUEUE


     
  5. Add a new Parameter “InDistrict” and configure as follows
    1. In the declarer drop down select
    2. Change the Structure name to “inSDistrict”
    3. Select the “XML Property” checkbox
    4. Add a “Structure Definition|
      [inDistrict] [String]


       
  6. Configure the “InDistrict” on the Function Interface as follows :
    [InDistrict] [Structure] [inSDistrict] [InOut]


     
  7. On the data mappings map the following
    CreateEmpAddress/In/inEmpID   >>    BAPI_EMPLOYEET_ENQUEUE/In/NUMBER
    CreateEmpAddress/In/inBeginDate   >>   BAPI_EMPLOYEET_ENQUEUE/In/VALIDBEGIN
    CreateEmpAddress/In/inEmpID   >>    BAPI_EMPLOYEET_DEQUEUE/In/NUMBER
    CreateEmpAddress/In/inBeginDate   >>   BAPI_EMPLOYEET_DEQUEUE/In/VALIDBEGIN
    CreateEmpAddress/In/inEmpID   >>   BAPI_ADDRESSEMP_CREATE/Ref/EMPLOYEERUMBER
    CreateEmpAddress/Ref/InDistrict/inDistrict   >>   BAPI_ADDRESSEMP_CREATE/In/DISTRICT
  8. Publish the Service Object and run the Service Object using the “SmartObject Service Tester”
  9. If the following XML is entered and executed,  it will fail :
    Test & Test
    This is because in XML the “&” is not recognized unless the special character is written as “&”
  10. To verify how it functions correctly, it in the XML below as follows and the whole string “Test & Test” to SAP :
    Test & Test

 

 

Error Messages

For Error 1: "An error occured while Parsing Entity Name"

For Error2: "Object Reference not set to an instance of an object"

 

 

Error Resolution

This Hotfix is contained within the latest K2 connect for SAP Update. Install the update package to resolve the error.

Note: Once the hotfix has been installed, the default K2 connect for SAP Service instance must be refreshed before the changes will take effect. Alternatively, publishing a service object to the default instance will also refesh the service instance.

The latest K2 connect Update is available as an independent installation package which can be found here: http://portal.k2.com/downloads/k2connect/Default.aspx

 


0 replies

Be the first to reply!

Reply