Calculate displacement from acceleration signal data using Fourier transformation
I can perform integration on the time-domain data by dividing the transformed acceleration data by the scale factor (-2πf) where f is the frequency in Hz.

Well, not quite, but it looks like you have pieces of it.  To integrate once, you divide by $2i \pi f$ -- note the fact that the divisor is purely imaginary.  To integrate twice you just divide by that factor twice.  You can do that explicitly, or you can note that $\left (2i \pi f\right)^2 = -4 \pi^2 f^2$

However, the transformed data is a complex number. Should I divide the real part or the imaginary part or the magnitude by the scale factor?

The key phrase here is &quot;complex number&quot;.  Almost always with complex numbers, you do arithmetic on the whole thing, real and complex parts equally.  If you're just plucking out the real or the imaginary parts out to do math on, you're almost certainly taking some shortcut, and you should understand the &quot;right&quot; way to do that task.
In this case, you're just doing plain old arithmetic, so you should divide the entire number (meaning: the real and the imaginary parts) by $-4 \pi^2 f^2$.

Also, the software can perform Inverse Fourier transformation just for complex transformed data to obtain displacement in the time domain. how to calculate displacement?

Theoretically, divide throughout by $-4 \pi^2 f^2$ and do an inverse Fourier transform.  In reality, you'll have some non-zero signal content at low frequencies, and dividing that by 0 will cause problems.
So you need to multiply it by some function $A\left(f\right)$ that is $A\left(f\right) = 0$ for $f = 0$, $A\left(f\right) = -\frac{1}{4 \pi^2 f^2}$ for $f$ above some threshold frequency (which will be determined by your accelerometer, BTW), and that transitions smoothly in between.
At worst, just make a function $$A(f) = 
\begin{cases}
0 &amp;&amp; |f| &lt; f_0 \\
-\frac{1}{4 \pi^2 f^2} &amp;&amp; |f| \ge f_0
\end{cases}$$
This will hopefully work well enough to tell you that you're doing your work right, but will suffer from time-domain ringing around $f_0$.  Then you can either try out ways to make a smooth transition, or ask back here and we'll suggest something.