How to firm planned purchase orders through X++ in D365?

I want to create a batch job to firm the planned purchase orders through X++. if the planned order has some same fields, they will be in the one purchase order. does anyone can help me ?