  In 2010, Gordan \v{Z}itkovi\'{c} introduced the notion of convex compactness
for a convex subset of a linear topological space and gave some important
applications to both nonlinear analysis and mathematical economics in [ Gordan
\v{Z}itkovi\'{c}, Convex compactness and its applications, Math. Finance
Econom. 3(1) (2010) 1--12 ]. Motivated by Gordan \v{Z}itkovi\'{c}'s idea, in
this paper we introduce the notion of $L^0$--convex compactness for an
$L^0$--convex subset of a topological module over the topological algebra
$L^0(\mathcal{F},K)$, where $L^0(\mathcal{F},K)$ is the algebra of equivalence
classes of random variables from a probability space $(\Omega,\mathcal{F},P)$
to the scalar field $K$ of real numbers or complex numbers, endowed with the
topology of convergence in probability. This paper continues to develop the
theory of $L^0$--convex compactness by establishing various kinds of
characterization theorems for $L^0$--convex subsets of a class of important
topological modules--complete random normed modules, in particular, we make use
of the theory of random conjugate spaces to give a characterization theorem of
James type for a closed $L^0$--convex subset of a complete random normed
module. As applications, we successfully generalize some basic theorems of
classical convex optimization and variational inequalities from a convex
function on a reflexive Banach space to an $L^0$--convex function on a random
reflexive random normed module. Since the usual weak compactness method fails
in the random setting of this paper and in particular, since the difficulties
caused by the partial order structure of the range of an $L^0$--valued function
also frequently occurs in the study of problems involved in this paper, we are
forced to discover a series of new skills to meet the needs of this paper.
