SAP4 updated with if statements and Log redirect