Skip to Content

Objective


B1if has default error handling by logging errors and in some cases debugging information.  These errors can be found by using the Error Inbox under Monitoring -> Message Log but a more graceful way would be to notify the somebody an error has occurred instead of always having to monitor B1if Error Inbox.  B1if has the ability to add additional steps to handle errors that may happen throughout a scenario package. 

In this example we are going to add error handling to the outbound channel for B1if by Example: Text File to Sales Order so that we can capture any errors that were encountered during the insert of the Sales Order.  Error Handling can be defined for Inbound Step, Processing Steps and Outbound Step.  This document will focus on handling errors produced by the outbound step to write to a log file and to alert a user that an error has occurred.

ProcessDiagram.JPG

Scenario Step


The key to creating an error handling scenario step is to define the Inbound channel type as an Internal Queue and to define the queue identifier.  Information placed on the queue is the trigger for the error handling scenario step to be called. 

ScenarioStep.JPG

ScenarioStepInbound.JPG

ScenarioStepInboundChannel.JPG

The key to defining an error handling scenario step is to define the inbound type as internal queue and give the queue and identifier.

ScenarioStepOutbound.JPG

Processing

ScenarioStepProcessing.JPG

When an error occurs, this scenario step is going to use the xform to generate the text to be stored in a log file and then send a user a message alerting them of the error.  The scenario step uses 3 properties to allow for this step to be configurable when loaded in other systems.

ScenarioStepProperties.JPG

B1MessageSystemID defines the SLD system ID for the Business One instance the B1 Message atom will send the internal message in.

B1MsgUser defines the user that will receive the message

LogFile defines the output file path that the StoreFile atom will store the error message in.

These properties will be used in the StoreFile and B1 Message atom definitions below.

XFORM (Atom 4)

This xform is used to structure the input for the StoreFile atom and the message for the B1 Message.  Instead of forcing the user to read through xml, this transform is creating a text file from the xml passed to it.  The output can be viewed later in this document.

<xsl:template name=“transform”>

    <xsl:text>=======================================================================&#013;&#010;</xsl:text>

    <xsl:text>TIME: </xsl:text>

    <xsl:call-template name=“formatTime”>

           <xsl:with-param name=”timeValue“>

                  <xsl:value-of select =“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/@BeginTimeStamp”/>

           </xsl:with-param>

    </xsl:call-template><xsl:text>&#013;&#010;&#013;&#010;</xsl:text>

    <xsl:text>ERROR: </xsl:text><xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/@exceptionmsg” /><xsl:text>&#013;&#010;</xsl:text>

    <xsl:text>———————————————————————–&#013;&#010;</xsl:text>

    <xsl:text>CUSTOMER:&#009;</xsl:text><xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/Documents/row/CardCode” />       <xsl:text>&#013;&#010;</xsl:text>

    <xsl:text>ADDRESS:&#009;</xsl:text>

    <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/AddressExtension/row/ShipToStreet” />

    <xsl:text>&#013;&#010;</xsl:text>

    <xsl:text>&#009;&#009;</xsl:text>

    <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/AddressExtension/row/ShipToBlock” />

    <xsl:text>&#013;&#010;</xsl:text>

    <xsl:text>&#009;&#009;</xsl:text>

    <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/AddressExtension/row/ShipToCity” />

    <xsl:text>, </xsl:text

    <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/AddressExtension/row/ShipToState” />

    <xsl:text>  </xsl:text>

    <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/AddressExtension/row/ShipToZipCode” />

    <xsl:text>&#013;&#010;&#013;&#010;</xsl:text>

    <xsl:text>PO #: </xsl:text>

    <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/Documents/row/NumAtCard” />

    <xsl:text>&#013;&#010;&#013;&#010;</xsl:text>

    <xsl:text>DATE: </xsl:text>

    <xsl:call-template name=“formatDocDate”>

           <xsl:with-param name=“dateValue”>

                  <xsl:value-of select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/Documents/row/DocDate” />

           </xsl:with-param>

    </xsl:call-template>

    <xsl:text>&#013;&#010;</xsl:text>

    <xsl:text>&#009;ITEM&#009;&#009;QUANTITY&#013;&#010;</xsl:text>

    <xsl:for-each select=“/vpf:Msg/vpf:Body/vpf:Payload[./@Role=’S’]/vpf:Msg/vpf:Body/vpf:Payload[./@id=’atom0′]//B1out/Document_Lines/row”>

      <xsl:text>&#009;</xsl:text>

      <xsl:value-of select=“ItemCode”/>

      <xsl:text>&#009;&#009;</xsl:text>

      <xsl:value-of select=“Quantity”/>

      <xsl:text>&#013;&#010;&#013;&#010;</xsl:text>

    </xsl:for-each>

    <xsl:text>———————————————————————–&#013;&#010;</xsl:text>

  </xsl:template>

  <xsl:template name=“formatTime”>

         <xsl:param name=“timeValue”/>

         <xsl:value-of select=“substring($timeValue,5,2)”/><xsl:text>/</xsl:text><xsl:value-of select=“substring($timeValue,7,2)”/><xsl:text>/</xsl:text>

         <xsl:value-of select=“substring($timeValue,1,4)”/>

         <xsl:text>&#009;</xsl:text>

         <xsl:value-of select=“substring($timeValue,9,2)”/><xsl:text>:</xsl:text><xsl:value-of select=“substring($timeValue,11,2)”/><xsl:text>:</xsl:text>

         <xsl:value-of select=“substring($timeValue,13,2)”/>

  </xsl:template>


  <xsl:template name=“formatDocDate”>

         <xsl:param name=“dateValue” />

         <xsl:value-of select=“substring($dateValue,5,2)”/><xsl:text>/</xsl:text><xsl:value-of select=“substring($dateValue,7,2)”/><xsl:text>/</xsl:text>

         <xsl:value-of select=“substring($dateValue,1,4)”/>

  </xsl:template>

StoreFile

StoreFileDefinition.JPG

The File Specification defines the full file path.  In this case the File Specification is defined by the LogFile property that was defined for the scenario step.  Again Atom 4 is defined as the input and therefore the file output.

Note: You may notice that the payload type is set to txt but in the LogFile property the file is named Log.rtf.  This is so that when a user opens the file by double clicking windows will choose to open the file either in Word or Word Pad.

B1 Message

B1MessageCallDefinition.JPG

The B1 Message atom notifies a user of the error.  The SysId and the User Code that will receive the message are defined in the B1MessageSystemID and MsgUser Properties.  The Subject defines the message that shows up in the Message/Alerts window within Business One while the MessageText defines what will show up when the user clicks on the message.

Error Handling Definition


The error handling for the various steps are defined in the Scenario Package Definitions.  One of the definition choices is Error Handling.  The Error Handling window is where you define the scenario step to call when an error occurs.  In this case we are only defining Error Handling for the Outbound Step but you could add Error Handling for the other steps as well.

ErrorHandlingDefinition.jpg

Scenario Package Setup


This scenario step needs to be activated.  To do this go to Scenario -> Setup, choose the package in which the scenario step was defined in and click on the Steps button just like in any other scenario setup.

ScenarioPackageSetup.JPG

Output


Log File

LogFileOutput.JPG


Business One Message

B1Message.JPG

Summary


Adding Error Handling to your Scenario Packages allows you to manage errors more gracefully. Most users will want to be notified of the error and the information that caused the error so that they may fix it manually.  In this case we added error handling to log the error along with a more user friendly representation of the data  that caused the error, then alerted a system user of the error.  By providing the user with the information, the user can now add the sales order manually therefore preventing a call from the customer later asking why they haven’t received the order. 

References

SAP Business One 8.82 PL10

B1if 1.14.10

Attachment

Test ImportFile with an updated date that is not defined within a posting period in Business One.

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply