Hi Swathi,
Since this thread has already been answered, you might want to post this as a new question.
As far as I can see (and assume) the relationship between the entities getCodesTables and CodesTableDetails appears correct. Then I believe the issue could be in your custom script for getCodesTables. Did you populate CodesTableDetails data when $expand is applied to getCodesTables read operation?
Regards,
Mustafa.