IDoc

The IDoc Outbound generator combines sql-based and model-based outbound generation to give the flexibility of either using SQL's or Models to pass on to the IDocMapper. The IDocMapper will then generate one or more IDocs

Procedure 16.10. Generating an outbound IDoc

  1. Create an Outbound Interface

    Platform uses Outbound Interfaces to generate data in IDoc format. Choose format type as IDoc
    images/download/attachments/144836083/IDocOutboundInterface-version-1-modificationdate-1645137122000-api-v2.png

  2. Configure the generator for generating the IDoc outbound.

    The generator can be either Model-based or Net-change based implementation to retrieve the models accordingly and the mapper will be used to generate the IDoc from the corresponding models.
    images/download/attachments/144836083/IDocOutboundGenerator-version-1-modificationdate-1645137131000-api-v2.png
    The generator should implement its default constructor which should invoke the superclass parameterized constructor:

    public SampleIDocOrderGenerator() {
    super(Order.MODEL_TYPE, transactionSetIdentifier);
    }

  3. Converting ModelList to IDocs

    The mapper class must provide the implementation for converting ModelList to List<IDoc>. This is done by overriding the method generate(List<? extends Model> modelList) which returns List<IDoc>.

    @Override
    public List<IDoc> generate(List< ? extends Model> modelList) {
    List<IDoc> idocs = new ArrayList<IDoc>();
    for (com.onenetwork.platform.data.model.Model model : modelList) {
    Order order = (Order) model;
    IDoc idoc = new IDoc();
    idoc.setIDocDef(idocDefObj);
    IDocSegment controlSegment = idoc.addSegment("EDI_DC40");
    controlSegment.addField("TABNAM", "EDI_DC40");
    controlSegment.addField("DOCNUM", Services.get(IDocService.class).generateIDocNumber());
    controlSegment.addField("MESTYP", "ORDERS");
    controlSegment.addField("SNDPOR", "RCVPOR");
    controlSegment.addField("RCVPOR", "SNDPOR");
    IDocSegment segE1EDKA1 = idoc.addSegment("E1EDKA1");
    segE1EDKA1.addField("LIFNR", "BUY");
    segE1EDKA1.addField("NAME1", order.getBuyingEnterpriseName());
    IDocSegment segE1EDKA2 = idoc.addSegment("E1EDKA1");
    segE1EDKA2.addField("LIFNR", "SEL");
    segE1EDKA2.addField("NAME1", order.getSellingEnterpriseName());
    IDocSegment segE1EDK01 = idoc.addSegment("E1EDK01");
    segE1EDK01.addField("KZABS", "N");
    segE1EDK01.addField("BELNR", order.getOrderNumber());
    IDocSegment segE1EDK14 = idoc.addSegment("E1EDK14");
    segE1EDK14.addField("QUALF", "014"); //Purchasing organization
    segE1EDK14.addField("ORGID", order.getBuyingOrganizationName());
    IDocSegment segE1EDK142 = idoc.addSegment("E1EDK14");
    segE1EDK142.addField("QUALF", "018"); //Purchasing organization
    segE1EDK142.addField("ORGID", order.getSellingOrganizationName());
    for (OrderLineItem orderLineItem : order.getOrderLineItems()) {
    IDocSegment segE1EDP01 = idoc.addSegment("E1EDP01");
    segE1EDP01.addField("POSEX", orderLineItem.getItemName());
    segE1EDP01.addField("MENGE", String.valueOf(orderLineItem.getShippedQuantity()));
    segE1EDP01.addField("BMNG2", String.valueOf(orderLineItem.getUnitPrice()));
    segE1EDP01.addField("PMENE", orderLineItem.getCurrency());
    }
    idocs.add(idoc);
    }
    return idocs;
    }
  4. Setup EdiOutboundRoute

    Similar to EdiInboundRoute, the base IDoc outbound generator uses EdiOutboundRoute to locate the mapper to be used to generate an IDoc. While this can optionally be overridden based on module-specific needs, having the generator use the EdiOutboundRoute to find the mapper is best as it decouples the generator and mapper. It also allows for a common generator to be implemented used by various mappers.

    The EdiOutboundRoute can be used to configure the interface for a sender, receiver, transaction set or message type, outbound queue and outbound queue enteprise Name.

  5. Invoking the IDoc outbound interface

    IDoc outbound generation leverages Platform’s Integration Subscription feature.
    images/download/attachments/144836083/IDocSubscriptionTab-version-1-modificationdate-1645137143000-api-v2.png
    For an outbound IDoc sent, Platform updates the parent transaction on EdiMessageQueue with Accepted/Rejected status.