Hi Nicolas,
Documents with that number of lines are always going to be a problem and it's not what I'd recommend. I typically wouldn't recommend more than 100 lines on any marketing document unless there are very strong reasons to import it in this way. Have you considered splitting the import file in to separate sales orders with 50 or 100 lines each, all linked by a common reference number?
Having said all that, SBO shouldn't crash with that number of lines. I would expect it to freeze (and it will probably freeze other users if they are working in the same area of SBO) and it would take a long time to process, as it's doing a lot of validation and inserts in to SQL.
You could potentially read the data from your import file and populate the sales order screen, rather than using the DI API. However, you can't write directly to the datasources on a system screen which would make it slower. Have you tried manually creating a sales order with 5000 lines using the sales order screen (or even just a few hundred as a starting point)? I've never tried above a few hundred lines but I would be surprised if it was any faster than the DI API method.
Kind Regards,
Owen