When an IDoc is passed to the communication layer, it is assigned a globally unique transaction identifier (TID). If the IDoc has been successfully dispatched, this information is not automatically passed to the ALE communication layer. So that ALE processing sets the IDoc status to Dispatch OK, you should compare the TID numbers in the communication layer and the ALE layer.
The program RBDMOIND checks that the IDocs passed to the transactional RFC have already been sent to the receiving SAP system. If they have been sent, the IDoc status is changed to "12" - Dispatch OK.
To set the IDoc dispatch status, run the program RBDOIND after the IDocs have been passed to the communication layer.