Skip to content

SAP Integration#

🔒 Administration.ERP

Info

ERP integration is a Critical Manufacturing optional licensed separately.

In addition to systems integrations management specification, the SAP integration has some specific definitions that must be configured for it to work properly.

ERP (Enterprise Resource Planning) provides access to the SAP integration mechanism from and to Critical Manufacturing. Critical Manufacturing provides currently the following capabilities:

  1. Make SAP RFCs available to Critical Manufacturing and Critical Manufacturing application clients by exposing them as regular Critical Manufacturing Services. These functions can then be called synchronously or asynchronously.

  2. Have a SAP IDoc trigger a DEE Action in Critical Manufacturing.

Warning

In order for the ERP integration to work properly, there are some settings that need to be configured in the app.config of the Critical Manufacturing service so that the connectivity to SAP can be established. Please refer to Enterprise Resource Planning topic in the Installation Guide for more information.

Intermediate Documents#

intermediate_documents

Add Document mapping#

🔒 ERP.NewFromERP

The configured documents can be managed through this view by associating a specific DEE Action that will handle the appropriate document. Pressing the or buttons on the top ribbon allows the user to create new mappings or to remove the existing ones. It's possible to have a SAP IDoc to call a DEE Action by following the procedure described below.

  1. Press the button in the ribbon.
  2. Provide a name and a description for the association between the IDoc and the DEE action.
  3. Provide the name of the IDoc - the name must match the name of the IDoc exactly as it is defined in SAP.
  4. Select the name of the DEE Action to be associated with the IDoc.

Warning

It is necessary to configure SAP to deliver the IDoc to the specific RFC Server, in this case the Critical Manufacturing instance. This procedure requires special SAP knowledge and SAP privileges.

Below is the example of a code to iterate through the received IDoc structure. The most important input is the Input[Cmf.Foundation.BusinessOrchestration.ErpManagement.InputObjects.ErpRuleExecInput] variable:

//key: Cmf.Foundation.BusinessOrchestration.ErpManagement.InputObjects.ErpRuleExecInput
//value: erpRuleExecInput.ErpDoc

Cmf.Foundation.BusinessOrchestration.ErpManagement.InputObjects.ErpRuleExecInput valueReceived = Input["Cmf.Foundation.BusinessOrchestration.ErpManagement.InputObjects.ErpRuleExecInput"] as Cmf.Foundation.BusinessOrchestration.ErpManagement.InputObjects.ErpRuleExecInput;
if (valueReceived != null)
{
    if (valueReceived.ErpDoc != null &&  valueReceived.ErpDoc.Segments != null)
    {
        Console.WriteLine("Segment number: " + valueReceived.ErpDoc.Segments.Count);
        foreach(var segment in valueReceived.ErpDoc.Segments)
        {
            Console.WriteLine("-"+segment.SegmentName);
            foreach(var field in segment.Fields)
            {
                Console.WriteLine(" . " + field.FieldName + " (" + field.FieldValue+")");
            }

            Console.WriteLine("Field by name (MATNR) value: " + segment.Fields["MATNR"].FieldValue);
            foreach(var innerSegment in segment.ChildSegments)
            {
                Console.WriteLine("    -" + innerSegment.SegmentName);
                foreach(var fieldFromInnerSegment in innerSegment.Fields)
                {
                    Console.WriteLine("     ." +fieldFromInnerSegment.FieldName + "(" + fieldFromInnerSegment.FieldValue+")");
                }
                foreach(var innerInnerSegment in innerSegment .ChildSegments)
                {
                    Console.WriteLine("      -" + innerInnerSegment.SegmentName);
                    foreach(var fieldFromInnerInnerSegment in  innerInnerSegment.Fields)
                    {
                        Console.WriteLine("       ." + fieldFromInnerInnerSegment.FieldName + "(" + fieldFromInnerInnerSegment.FieldValue+")");
                    }
                }
            }
        }
    }
}

For ERP Integration, it is important to insert a reference in the DEE Action to some namespaces which are both useful and necessary:

UseReference("System.dll", "System");
UseReference("Cmf.Foundation.BusinessOrchestration.dll","");
UseReference("Cmf.Foundation.CommunicationLayer.dll","");
UseReference("Cmf.Custom.BusinessObjects.ErpCustomManagement.dll", "Cmf.Custom.BusinessOrchestration.Erp.Generated.InputObjects");
UseReference("Cmf.Custom.BusinessObjects.ErpCustomManagement.dll", "Cmf.Custom.BusinessOrchestration.Erp.Generated.OutputObjects");
UseReference("Cmf.Custom.BusinessObjects.ErpCustomManagement.dll", "Cmf.Custom.BusinessOrchestration.Erp.Generated.Objects");
UseReference("Cmf.Custom.BusinessObjects.ErpCustomManagement.dll", "Cmf.Custom.BusinessOrchestration.Erp.Generated");

Remove Document mapping#

🔒 ERP.TerminateFromERP

To remove a defined mapping, press the button on the ribbon and the mapping will no longer be applied.

Remote Function Calls#

🔒 ERP.ManageToERP

It's possible to expose SAP Functions (RFC) following the procedure described below.

  1. Press the button Manage RFC button in the top ribbon of the Remote Function Calls view.
  2. In the Wizard, select or provide the names of the SAP functions that should be exposed.

    Info

    It's possible to search for a particular function by providing the initial letters of the function and searching for the function name.

  3. Press the Update button to complete the Wizard. This Wizard may take some time to complete as it generates the appropriate code, compiling it as well as creating and exposing the services.

Once the SAP Functions are exposed in Critical Manufacturing they can be called by a DEE Action. They will also appear in the available services in the Code View of DEE Action details while in edit mode under the namespace Cmf.Custom.BusinessObjects.ErpCustomManagement. Each function will be exposed in two flavors:

  • Synchronous
  • Asynchronous - with the Async suffix

erp_manage_remote_function_calls

Below is a sample code from a DEE Action that calls a SAP RFC.

// Prepare Z_ST7_ALL_DATA RFC input

Z_ST7_ALL_DATAInput input = new Z_ST7_ALL_DATAInput();

input.AGE = 33;
input.BIRTHDATE = new DateTime(1977, 2, 8);
input.CURRENTDATE = DateTime.Now;
input.ISMARRIED = "T";
input.PERSONSNAME = "Luis";
input.REF_TABLE_ZST7 = new ZST7_ALLTABLECollection();
input.REF_TABLE_ZST7.Add(new ZST7_ALLTABLE(){ DATEOFBIRTH = new DateTime(1977,2,8), HEIGHT = 167, NAME = "Luke Skywalker", TIMEOFBIRTH = new TimeSpan(8,10,00), WAGE = "256", WEIGHT = 68 });
input.REF_TABLE_ZST7.Add(new ZST7_ALLTABLE() { DATEOFBIRTH = new DateTime(1980, 10, 15), HEIGHT = 155, NAME = "Princess Leia", TIMEOFBIRTH = new TimeSpan(10, 10, 00), WAGE = "800", WEIGHT = 50 });

// Call Z_ST7_ALL_DATA RFC

Z_ST7_ALL_DATAOutput output = ErpGeneratedOrchestration.Z_ST7_ALL_DATA(input);