Hello lvgandhi,
It seems you placed 3 basket orders:
1. One at 9:12am. This got rejected as the market had not opened
2. One basket order during the market. This was to square off the july position and create a fresh August position.
In case of a basket order the individual order first goes through the RMS and only if it goes through, it goes as a live order to the exchange. So your August contract order got rejected due to lack of margin as it was to create a fresh position. However, the July contract passed the RMS and went to the exchange and got executed.
3. Another basket order during the market itself. This was to create the August position and to also square off the July position (which had already been squared off).
Since the July position was already squared off margin was not available. Hence the August order got executed. Since a position was already there in August series, your July order got rejected this time. The orders will be sent to RMS in the same order in which you enter them in the basket. In this case the August order must have been entered before the July order so the new position was created in August series and not in July.
When using a basket order, it'd be advisable to check the status of each order in the order window.