Code for Non PO invoice journal creation

Hi,

need to create a Non PO invoice journal thru code.

I want code for header creation and line creation.

Any help??

Thanks in Advance