Creating multiple idocs in SAP through one ISA

I am trying to post multiple idocs into SAP.
We receive a large document with multiple SDQ segments and we need to create separate orders in SAP based on the the different stores.

I tried two methods.

  1. I tried to send multiple idocs at the same time but i get an error
    com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: ERROR B1022
    at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeExecute(Native Method)
    at com.sap.mw.jco.rfc.MiddlewareRFC$Client.execute(Unknown Source)
    at com.sap.mw.jco.JCO$Client.execute(Unknown Source)
    at com.sap.mw.jco.JCO$Client.execute(Unknown Source)
    at com.sap.mw.jco.JCO$Client.execute(Unknown Source)
    at com.wm.pkg.sap.rfc.SAPSession.invokeTransaction(Unknown Source)
    at pub.sap.transport.ALE.OutboundProcess(Unknown Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:281)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:140)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:292)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:559)
    at com.wm.lang.flow.FlowState.step(FlowState.java:430)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:400)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1786)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:450)
    at com.wm.app.b2b.server.Service.doInvoke(Service.java:495)
    at com.wm.app.b2b.server.Service.doInvoke(Service.java:464)
    at com.wm.app.tn.route.RoutingActions.invokeWrapper(RoutingActions.java:794)
    at com.wm.app.tn.route.RoutingActions.invoke(RoutingActions.java:708)
    at wm.tn.route.route(route.java:583)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:281)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:140)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:292)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:559)
    at com.wm.lang.flow.FlowState.step(FlowState.java:430)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:400)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1786)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:140)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:292)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:559)
    at com.wm.lang.flow.FlowState.step(FlowState.java:430)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:400)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1786)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:140)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:292)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:559)
    at com.wm.lang.flow.FlowState.step(FlowState.java:430)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:400)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1786)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:450)
    at com.wm.app.b2b.server.Service.doInvoke(Service.java:495)
    at com.wm.app.b2b.server.Service.doInvoke(Service.java:464)
    at wm.b2b.editn.EDIGroupDocType.createEnvelope(EDIGroupDocType.java:143)
    at com.wm.app.tn.doc.BizDocTypeReg.recognizeAndCreate(BizDocTypeReg.java:423)
    at wm.tn.doc.recognize(doc.java:634)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:281)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:140)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:292)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:559)
    at com.wm.lang.flow.FlowState.step(FlowState.java:430)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:400)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1786)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:450)
    at com.wm.app.b2b.server.Service.doInvoke(Service.java:495)
    at com.wm.app.b2b.server.Service.doInvoke(Service.java:464)
    at wm.b2b.editn.EDIEnvelopeDocType.createEnvelope(EDIEnvelopeDocType.java:376)
    at com.wm.app.tn.doc.BizDocTypeReg.recognizeAndCreate(BizDocTypeReg.java:423)
    at wm.tn.doc.recognize(doc.java:634)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:281)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:140)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:292)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:559)
    at com.wm.lang.flow.FlowState.step(FlowState.java:430)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:400)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1786)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:688)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:480)
    at com.wm.app.b2b.server.HTTPInvokeHandler.process(HTTPInvokeHandler.java:168)
    at com.wm.app.b2b.server.HTTPDispatch.run(HTTPDispatch.java:457)
    at com.wm.util.pool.PooledThread.run(C:/NT/Perforce/basis/4.1.0-terra/module/core/source/com/wm/util/pool/PooledThread.java:103)
    at java.lang.Thread.run(Thread.java:479)

  2. I tried sending one idoc at a time. Now, it creates the first idoc. It doesnt post any other idoc into SAP after the first one.

Just make sure that you are looping over the all # of IDOC_CONTROL_REC, before calling pub.sap.transport.ALE:InboundProcess

Hope this helps.

Thanks
-Muzeer