Hi Krish,
You need to set up automatic batch determination for component material B in the production order during the production order release. This is possible in standard SAP. Once the the batch is updated for component material B in the production order, you need to make some enhancement or trigger relevant user exit so that Batch component material B is updated as header material A batch in the production order. Take the help of your technical consultant.
Check the below thread..
Default batch selection for the Header material | SCN
If the above one is done sales order stock of header material A will have the batch of component material B.
Hope this helps.
Thanks
Kumar