I try to autodefine the preamble using this and that approach but do get Undefined control sequence. \@ifundefined{\KOMAClassName } in case I write report for scrreprt. for both options.
\documentclass[12pt,a4paper,notitlepage,oneside]{report}
%NOTE Packages, my Macros und Formatdefinitions
\usepackage[T1]{fontenc} % Allows different font encodings and hyphenation -> ctan.org/pkg/fontenc
\usepackage[utf8]{inputenc} % Translates input encodings into LaTeX internal language -> ctan.org/pkg/inputenc
\usepackage{blindtext}
\makeatletter
\@ifundefined{KOMAClassName }{\newcommand{\test}{num1} }{\newcommand{\test}{num2} } %option1
\@ifclassloaded{KOMAClassName }{\newcommand{\testb}{num1} }{\newcommand{\testb}{num2} } %option2
\makeatother
\begin{document}
\section{hi}
\test \\
\testb\\
\end{document}
Using scrreprt or report I get printed num1 and num2 for \test and \testb (which isnt also the case)
\@ifundefined{KOMAClassName}{...}{...}, i.e. no backslash – Apr 11 '16 at 19:55\@ifclassloaded{\KOMAClassName}{...}{...}, since this does not expect a macro name. Your code tests whether the classKOMAClassNameis loaded, which is not the case – Apr 11 '16 at 20:00