Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module behaves differently on a Mac and on a PC

Vlad_Ghitulescu
Participant
0 Kudos

Hey,

I'm using a report that calls a function module in order to read an Excel-file.

I do this in the SAP GUI and / or in Eclipse IDE

  • on a PC (HP Zbook running Windows 11 Enterprise Version 21H2 - SAP GUI 7.70 - Eclipse 2022-03 (4.23.0) - ADT (s. screenshots below)) and
  • on a Mac (MacBook Pro 13" M2 2022 running macOS Ventura 13.1 - SAP GUI 7.80 - Eclipse 2022-12 (4.26.0) - ADT (s. screenshots below))

using the same Excel-file.


The function module behave similarly on the PC and Mac until this statement:

SET PROPERTY OF ls_excel 'Visible' = 0.

where ls_excel is defined as following:

DATA ls_excel type ole2_object.

After this statement the SY-SUBRC is 0 on the PC and 3 on the Mac.

Do you have any idea why this different behavior happens?

Just before the SET PROPERTY… line there is this statement

	CREATE OBJECT ls_excel 'Excel.Application'.

Could it be that this line must be different on a Mac?

All the screenshots are in a ZIP-archive in Dropbox here:

https://www.dropbox.com/s/hwb8hcy5teiai59/Mac%20Anomalie.zip?dl=0

Thanks!

Regards,
Vlad

P.S. Here come a couple of relevant screenshots:

- PC

- Mac

1 ACCEPTED SOLUTION

Vlad_Ghitulescu
Participant
0 Kudos

Hey,


since the original posting I was trying in my spare time 😉 to use abap2xlsx for reading my Excel-file… and yesterday with the help of an example from codezentrale.de (it was not easy to find an example of using abap2xlsx for reading XLSX / CSV! 😞 ) I finally got it!


It's still a lot of work because

  • only one (and not even the first) of the 3 worksheets was read
  • there are a lot of empty cells that were read too
  • once in a while I get an error reclaiming not being able to access the file (… that has 777 Unix-permissions)

but at least I can (sometime 😉 read (at least parts of 😉 my XLSX-file - compared with the original error it's a huge step forward!


That's reason enough for me to close this ticket / thread and start tinkering with the abap2xlsx.

Thank you all for your input and especially c5e08e0478aa4727abc4482f5be390b2 & sandra.rossi for pointing me in the right direction 😉

Until next time,
Vlad

11 REPLIES 11

matt
Active Contributor

It looks to me like the issue is that OLE works differently between MacOS and Windows.

abo
Active Contributor

One could also use abap2xlsx to read the file and relegate OLE where it belongs 😉

To get started, you might want to follow the blogposts by bfeeb8ed7fa64a7d95efc21f74a8c135, starting from the january issue

Sandra_Rossi
Active Contributor

You can embed the screenshots directly in your question. Dropbox needs people to sign in if I'm not wrong.

NB: I didn't even know that Mac would even support OLE.

Taken from note 1682628 - Solution Manager: Limitations with Apple OS X:

  • "Functions such as Microsoft Office Integration, OLE (Active X) embedding, VML graphics, etc., do not work on non-Microsoft Windows operating systems."

Vlad_Ghitulescu
Participant
0 Kudos

Thanks for all the comments so far.

matthew.billingham I didn't think of it - I've only checked the right and permissions of the SAP GUI's temp folders on the Mac. How can I read then an Excel-file into a report from a Mac?

c5e08e0478aa4727abc4482f5be390b2 abap2xlsx sounds good but - if I understand it correctly - it's only for output-ing XLSX. In my case I need to use a XLSX-file as an input.

sandra.rossi I didn't think about Dropbox requiring a sign in :-(. I embedded 4 of the screenshots in the question. Thanks for the note! But - similar to the question to Matthew Billingham - if so, how to read an XLSX-file into an ABAP-program on a Mac?

Thanks again!

Sandra_Rossi
Active Contributor

Thanks. You're right, I was too quick, login is optional it's just that the below dialog is displayed the first time but is in fact optional. It's easy to work with Excel files using abap2xlsx, as Andrea explained. It's also for reading.

Vlad_Ghitulescu
Participant

Sorry for missing the upload part of abap2xlsx - I'm starting to read (again! 😉 the description of abap2xlsx and all the blog-posts of Paul Hardy...

abo
Active Contributor

You have both the option of reading a file cell by cell, which allows you to make quick decisions based on the contents for example, and that of reading a whole tab into an internal table.

Vlad_Ghitulescu
Participant
0 Kudos

Here I am again, after reading something 🙂 about abap2xlsx (= blog posts + Paul Hardy chapter on abap2xlsx from "ABAP to the Future").

Unfortunately everything I found so far is about outputting XLSX... so I cloned locally the GitHub-repo.

At first I was surprised by the amount of classes 😉

Just in order to begin with the ones that are possibly relevant for me (remember: I want to ONLY READ an XLSX-file with more than one tab and work with the data from each tab) I filtered the *reader*.abap* from the folder src

Am I on the right path so far or is it completely the wrong approach?

Thanks!

Vlad_Ghitulescu
Participant
0 Kudos

Hey,


since the original posting I was trying in my spare time 😉 to use abap2xlsx for reading my Excel-file… and yesterday with the help of an example from codezentrale.de (it was not easy to find an example of using abap2xlsx for reading XLSX / CSV! 😞 ) I finally got it!


It's still a lot of work because

  • only one (and not even the first) of the 3 worksheets was read
  • there are a lot of empty cells that were read too
  • once in a while I get an error reclaiming not being able to access the file (… that has 777 Unix-permissions)

but at least I can (sometime 😉 read (at least parts of 😉 my XLSX-file - compared with the original error it's a huge step forward!


That's reason enough for me to close this ticket / thread and start tinkering with the abap2xlsx.

Thank you all for your input and especially c5e08e0478aa4727abc4482f5be390b2 & sandra.rossi for pointing me in the right direction 😉

Until next time,
Vlad

abap2xlsx has a separate repository of demo programs, including one to read XLSX file.

0 Kudos

Thanks sandra.rossi, I'll give it a try - although I still have problems setting an online or offline repository of abap2xlsx on my systems. I'll report these issues in GitHub.

I was lucky to find an offline repository with the abap2xlsx from 2018 somewhere in our system (!) and this is what I used with the example from codezentrale.de and your snippet as well.

That's also why I couldn't get any of the demo programs - I couldn't find them anywhere in the system.