I have been working recently on issue with creating GOS attachments from files with long extensions.
We were using a solution described here which doesn’t work for files with extension longer than 3 characters.
I didn’t find an exact solution on the internet, that’s why I am publishing it here. The class CL_GOS_API is quite new, so check if you have it on your system.
You need to amend the solution a bit if you’re working with text files instead of binary (check ls_attcont-content field)
DATA: lr_gos_api TYPE REF TO cl_gos_api, ls_object TYPE gos_s_obj, ls_attcont TYPE gos_s_attcont, lv_commit TYPE boolean, lv_file_content TYPE xstring. OPEN DATASET '~/test.xlsx' FOR BINARY INPUT. READ DATASET '~/test.xlsx' INTO lv_file_content. CLOSE DATASET '~/test.xlsx'. ls_object-instid = '01800000000' "pm order number ls_object-typeid = 'BUS2007' "pm order bussiness object ls_object-catid = 'BO'. "business object TRY. lr_gos_api = cl_gos_api=>create_instance( is_object = ls_object ). ls_attcont-atta_cat = cl_gos_api=>c_msg. ls_attcont-filename = 'test.xlsx'. ls_attcont-descr = 'test.xlsx'. ls_attcont-tech_type = 'XLSX'. ls_attcont-content_x = lv_file_content. ls_attcont-filesize = xstrlen( iv_content_x ). ls_attcont-lang = sy-langu. lv_commit = lr_gos_api->insert_al_item( is_attcont = ls_attcont iv_roltype = 'ATTACHMENT' ). IF lv_commit = 'X'. COMMIT WORK AND WAIT. ENDIF. CATCH cx_gos_api. ENDTRY.