Many a times we have notice that Order Header has value FLOW_STATUS_CODE = 'Closed', open_flag ='N', where as all the lines associated with the Order Header in status Cancelled. FLOW_STATUS_CODE ='Cancelled', Open_flag = 'N' and Cancelled_flag ='Y', well that's what we expect from the system. Though that is the expectations , but many a time user debate that since all the orders lines are cancelled , order header should be in Cancelled status and NOT in Closed status.
Please Note that if we cancelled the order header , in that case cancellation process will cancel all the open lines and then cancel the order header and set the Header flow status code = cancelled and cancelled flag = Y and open_flag = N.
But the case that we are discussing here is not the cancel order process, here we have not cancelled the Order Header rather we have cancel all the line.Please note that when we cancel a order line , it cancels(if possible) the order line and associated delivery details (if possible) and then execute the "CLOSE LINE" workflow process to set the cancel flag = Y and flow_status_code = Y, and at the same time it let the Order header workflow knows that this line is cancelled and open_flag = N.
Thus the moment last order line got cancelled and inform order header that openflag for it is N , order header workflow evaluate that if there are no more open lines , it progress towards the Close Order process and close the Order ( if you have setup close the order header when all the lines has open_flag = N) .That is the reason when you query such order you can see the Order STATUS as CLOSED and NOT the CANCELLED. Please note that cancelling all lines are different from the Cancel Order .
In Cancel order we explicitly tell the system to cancel the order , but if you cancel all the order lines individually , system will not considered that action same as that of Close Header.
Hope that helps