cancel
Showing results for 
Search instead for 
Did you mean: 

corrupt data when uploading html file with GUI_UPLOAD

ennowulff
Active Contributor
0 Kudos

Hi there!

When uploading an html file with GUI_UPLOAD and filetype 'BIN' I get corrupt data like this:

਍ℼⴭ猠癡摥映潲牵㵬〨㌱⤲楦敬⼺⼯㩃唯敳獲眯湩汫牥⽣灁䑰瑡⽡潌慣⽬楍牣獯景⽴楗摮睯⽳义瑥慃档⽥潃瑮湥⹴畏汴潯⽫䝕㙐婊婐匯䥁呎佟充〰〲ㄷ㈳ㄸ㉟㈰〴㈲ㄸ㈴㐵⸷瑨汭ⴠ㸭਍格浴㹬格慥⁤浸湬㩳瑴∽瑨灴⼺眯睷献灡挮浯琯慲獮潦浲瑡潩⵮整灭慬整≳㰾敭慴栠瑴⵰煥極㵶䌢湯t 湥⵴祔数•潣瑮湥㵴琢硥⽴瑨汭※档牡敳ãµ

The file length is correct.

When uploading text files, I get chinese characters

瑥整牲楥敦Ɱ洠瑩搠牥䈠瑩整

Afterwards I use FM SO_DOCUMENT_INSERT_API1 to add the uploaded file to GOS.

It works with images and office files. but html and text files do not work.

I also tried different code pages (utf-8, utf-16) at GUI_UPLOAD w/o success.

Any ideas?

Thanks

~Enno

Sandra_Rossi
Active Contributor
HTML file is text so you shouldn't use BIN. It depends which code page is the HTML file. notepad++ should be able to detect it. The code page depends on "who" created the HTML file. SAP GUI is usually configured to consider your Windows default code page, but you can never be sure if it will be correct or not. You may get Chinese characters because you don't display the characters with the right code page. Any error comes from a wrong input code page at any level of the transmission...
Sandra_Rossi
Active Contributor
For the fun, I had implemented the language and code page recognition of any sequence of bytes (from the ICU library): https://github.com/sandraros/abap-CSR
chaouki_akir
Contributor
0 Kudos

You are uploading a file from you PC to SAP through an ABAP program using function module GUI_UPLOAD ?

Then you save the file in the GOS ?

And then you try to open the file that is in the GOS ? This is where the problem occurs ?

 

View Entire Topic
ennowulff
Active Contributor
0 Kudos

The problem seemed to be that because of the document type or file extension "TXT", the binary content was interpreted as "text" by simply copying the binary content table into the text content table. 

I still do not know when or why this behaviour had changed.

This is an alternative to the process:

 

      DATA(lo_gos_api) = cl_gos_api=>create_instance(
        VALUE #(
          instid = CONV #( p_myid )
          typeid = 'MYTYPEID'
          catid  = 'BO' ) ).

      DATA(ls_attcont) = VALUE gos_s_attcont(
        atta_id   = 'MYTYPEID'
        atta_cat  = cl_gos_api=>c_msg
        cr_user   = sy-uname
        cr_name   = space
        cr_date   = sy-datum
        cr_time   = sy-uzeit
        filesize  = filelength
        filename  = zcl_devt_file=>get_filename_from_path( p_file )
        tech_type = zcl_devt_file=>get_extension_from_filename( p_file )
        descr     = p_descr
        lang      = sy-langu
        content   = space
        content_x = cl_bcs_convert=>xtab_to_xstring( lt_contx ) ).
      lo_gos_api->insert_al_item(
        EXPORTING
          is_attcont = ls_attcont
          iv_roltype = cl_gos_api=>c_attachment
        IMPORTING
          ev_atta_id = DATA(ev_atta_id)
        RECEIVING
          rv_commit  = DATA(commit_required)   ).
      IF commit_required = abap_true.
        COMMIT WORK.
        "file has been added.
        MESSAGE i036 WITH p_bugid.
      ENDIF.

 

 

chaouki_akir
Contributor
0 Kudos
What was the problematic code ?