Hi Ram,
There is slight change needed.
Instead of it_mat you can use ls_gr_item-gr_items as the RFC/FM output as it already a table kind of deep structure.
Then you don't need to run a loop.
You can keep the copy_data_to_ref method outside of the loop....endloop.
Your code should be:
CALL FUNCTION 'ZGOODSRECEIPT_POST'
EXPORTING
pur_num = PurchaseDoc
TABLES
it_gr_post = lt_gritem
it_mat_doc = ls_gr_item-gr_items
ret_bapiret = lt_return.
copy_data_to_ref(
EXPORTING
is_data = ls_gr_item
CHANGING
cr_data = er_deep_entity ).
Thanks and Regards,
Kartik Suru