I have done some deep debugging to find out that the problem is occurring in a call to FM K_ORDER_READ. It holds some entries in one of the global variables (scope function group) buffer populated in some earlier steps of the flow. So in this entry in BUFFER sales order number (KDAUF) and item number (KDPOS) are empty. As the program finds entry in this buffer it does not fetch the complete AUFK structure for the order number and hence the Sales order number and item number remain empty causing the problem in later stages.
Please take reference of the following thread for details FM K_ORDER_READ direct execution and program execution result different
I have thought about putting an enhancement in K_ORDER_READ to not use the entries in buffer when this particular flow is hit. Hope that will solve the problem.
If anybody has any better/easier solution to this kindly share with me.
regards,
Jeet