Retirement tax questions

So I have a 1099R . I pulled $30,000 out of a Roth IRA that I had contributed $50,000 to so over the years with after tax dollars. These should be able to be pulled out tax free, at any time.  My 1099R shows the 30,000 distribution on line 1,  line 2a is blank, line 2b is "taxable amount not determined" , and yet the distribution is coded as "J".  

 

How do I update the cost basis to equal the disbursement and what do I put in 9a? What do I need to do  make sure this is not a taxable/penalized event?

 

Help is appreciated!

Cheers!