If you read earlier, you'd see that I mentioned SORTOUT was missing. SORTOUT is not mandatory, unless you are using it. It seems that you are (you are not showing your control cards, but you are using it, hence the message).
You have put DCB information (RECFM) on SORTTEMP in the JCL, and got it wrong. Or are creating the wrong RECFM in the control cards (can't tell, as we can't see them).
The order of DDnames is not important, except to do it the way the others you are working with do it. For now, put it after the input file.
Without seeing your code, detail is not possible.