Well, table variables are easy to use in SQLScript and actually quite fundamental.
Instead of your
INSERT INTO #TMP SELECT...
you would assign the statement to ,well, a table variable, e.g.
myTempData := SELECT ...
Your further processing can then access the data via the variable, e.g.
SELECT bla, blupp, blipp FROM :myTempData WHERE bla < blupp...
This and lots more is explained at length in the SQLScript documentation (actually built-in SAP HANA Studio and the WebIDE...).
Other than that, I suggest you take a good look at the amount of data your code is supposed to work on and check if this can fit into your SAP HANA instance.
- Lars