Create Batch number

Hi. I want to create batch number and serial number automatically in sales order. how can i do? i don’t use batch number group in my product to generate automatic batch and serial number because i don’t want to have automatic batch number in other journal. i think i have to create this with x++ code.