purchase order-ledger account

Hye,

While i was posting the purchase order i face this error. It happen because i didn’t assign ledger account number to the purchase order. Can anyone give me the sample select statement for this and how to assign the ledger account through coding.