First of all, check and clean your code!
The bunch of select..endselect to retrieve the last record is a punch in my eyes.
This part got also some BIG issue in the logic
LOOP AT it_final.
SELECT * FROM eskl INTO eskl WHERE hpackno = it_final-packno.
ENDSELECT.
LOOP AT it_final.
IF sy-subrc = 0.
it_final-hpackno = eskl-packno.
ENDIF.
MODIFY it_final.
ENDLOOP.
SELECT * FROM esll INTO corresponding fields of TABLE it_esll
FOR ALL ENTRIES IN it_final
WHERE packno = it_final-hpackno.
ENDLOOP.
loop at it_final.
endloop.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
Even the smartform is a real mess: no name outside "window1, 2, 3" no meaning names and pretty messy design and flow.
My suggestione is to organize the code and the smartform in a logic and MORE READABLE way.
Once done, debug your code, check IT_LINE and IT_RESULT content before calling the smartform.
This part is really weird
The poor design is the cause of your problems, work on it