Openbravo Issue Tracking System - Modules
View Issue Details
0041142ModulesSAP Connectorpublic2019-06-20 18:242022-02-01 08:05
martinsdan 
Triage Platform Base 
normalmajoralways
newopen 
4510.12
 
 
0041142: Problem creating several mappings for the same iDoc
We need to sync several transactions like shipments and distribution orders for example.
In this case, we have a problem because we want to map 2 Openbravo entities with the same idoc.
In this case, we should have 2 Mapping entries with the same External Entity but a different Openbravo Entity.

Everything seems ok when generating the idoc, but an error is thrown when getting the path to save the idoc.
org.openbravo.service.integration.sapecc.process.SapEccExporterSynchronizableBusinessObjectExporter.java

String fileName = getFilePath(idocType);

This will eventually call:
org.openbravo.service.integration.sapecc.process.SapEccExporterSynchronizableBusinessObjectExporter.java

  private EntityMapping getEntityMapping(String idocType) {
    OBCriteria<EntityMapping> criteria = OBDal.getInstance().createCriteria(EntityMapping.class);
    criteria.add(Restrictions.eq(EntityMapping.PROPERTY_SYSTEMTYPE, SapEccConstants.SYSTEM_TYPE));
    criteria.add(Restrictions.eq(EntityMapping.PROPERTY_MAPPEDENTITY, idocType));
    criteria.add(Restrictions.eq(EntityMapping.PROPERTY_INTEGRATIONDIRECTION,
        IntegrationDirection.EXPORT_FROM_OB.getLabel()));
    criteria.setFilterOnReadableClients(false);
    criteria.setFilterOnReadableOrganization(false);
    return (EntityMapping) criteria.uniqueResult();
  }

Here is the problem, this will throw an error because the query returns 2 results.
org.hibernate.NonUniqueResultException: query did not return a unique result: 2
We need to create 2 mappings to export the same idoc.
I think we should get this information somehow from the context we are executing the process because it should be possible to have several combinations for the same idoc and entity and schedule the selected implementation.

A proposed solution patch is attached.
No tags attached.
diff noUniqueError.diff (4,327) 2019-06-20 18:24
https://issues.openbravo.com/file_download.php?file_id=13041&type=bug
Issue History
2019-06-20 18:24martinsdanNew Issue
2019-06-20 18:24martinsdanAssigned To => platform
2019-06-20 18:24martinsdanFile Added: noUniqueError.diff
2022-02-01 08:05alostaleAssigned Toplatform => Triage Platform Base

There are no notes attached to this issue.