SAP GUI – XLS Upload Problem SOLVED

Some of our users had a problem with binary Excel uploads (XLS, XLSX) through SAP GUI. I have solved the problem with two different approaches.

Preferred solution

I have simply repaired ALSM_EXCEL_TO_INTERNAL_TABLE.

  DEFINE m_message.
    COMMIT WORK.
    COMMIT WORK AND WAIT.
    CASE sy-subrc.
      WHEN 0.
        WAIT UP TO 1 SECONDS. " <- REPAIR
      WHEN 1.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      WHEN OTHERS. RAISE upload_ole.
    ENDCASE.
  END-OF-DEFINITION.

But why?

Apparently, on some machines, Windows can’t respond fast enough to Excel OLE commands. If I make them wait 1 second after every command, their OS catches up and can continue working.

Additional info: The following command sometimes returns SY-SUBRC = 2, despite the file being opened correctly:

CALL METHOD OF workbook 'Open' 

Therefore, you may want to repair even further and accept SY-SUBRC = 2 as a valid response.

  DEFINE m_message.
    COMMIT WORK.
    COMMIT WORK AND WAIT.
    CASE sy-subrc.
      WHEN 0 OR 2. " <- REPAIR
        WAIT UP TO 1 SECONDS. " <- REPAIR
      WHEN 1.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      WHEN OTHERS. RAISE upload_ole.
    ENDCASE.
  END-OF-DEFINITION.

Alternative solution

If the solution above doesn’t work for you, you can modify your Z-programs so that they can accept text based .TXT or .CSV files too.

Your users will have to convert the binary .XLS file to one of those formats before uploading to SAP though.

I have published a central class called ZCL_BC_EXCEL_UPLOAD , which can be used to upload any spreadsheet file, regardless of their format (TXT, CSV, XLS, …). This might be useful as a central class to be consumed by client programs.

Advertisement

Posted

in

,

by

Tags:

Comments

One response to “SAP GUI – XLS Upload Problem SOLVED”

  1. kkayacan Avatar
    kkayacan

    A better solution would be using [abap2xlsx](https://github.com/sapmentors/abap2xlsx). I converted it into a [single include local class](https://github.com/kkayacan/abap2xlsx-simple) for easier installation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s