Application Development and Automation 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: 
Read only

why is it now a protected method?

Former Member
0 Likes
1,553

Hi all,

i coded a report in system A with some fine working public method calls.

Now we transported the coding to system B. but here the mothod is protected.

Why can this happen and what can i do to make it public?

Thank you!!

Best regards

Stefan

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,518

Hello Stefan

Assuming that you are talking about methods of SAP standard classes the only explanation I have is that the systems A and B have different support package levels which exactly affect the methods you are calling.

To exclude this possibility you should make a <b>REMOTE comparison</b> (<i>version management</i>) of the public and protected sections of the affected classes.

Regards

Uwe

Hello Stefan

Assuming that you are talking about methods of SAP standard classes the only explanation I have is that the systems A and B have different support package levels which exactly affect the methods you are calling.

To exclude this possibility you should make a <b>REMOTE comparison</b> (<i>version management</i>) of the public and protected sections of the affected classes.

Regards

Uwe

11 REPLIES 11
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,519

Hello Stefan

Assuming that you are talking about methods of SAP standard classes the only explanation I have is that the systems A and B have different support package levels which exactly affect the methods you are calling.

To exclude this possibility you should make a <b>REMOTE comparison</b> (<i>version management</i>) of the public and protected sections of the affected classes.

Regards

Uwe

Read only

0 Likes
1,518

Hallo Uwe,

Thanks for your answer.

Yes, i use the standard methods like GET_DETAIL in IF_REBD_RENTAL_OBJECT. I tried the remote-Comparison, but i can only see, that the Interface coding is different. But what can i do to make it public method or how can i get the data i need out of the Object?

Here is a little peace of coding. here's the problem (I think you know this piece )

DATA: gs_detail           TYPE              rebd_rental_object,
go_rental_object           TYPE REF TO CL_REBD_RENTAL_OBJECT_RU.

  go_rental_object ?= IO_OBJECT.
  gs_detail = go_rental_object->ms_detail.

Thank you

Stefan

Read only

0 Likes
1,518

Before a solution can be offered, the nature of the problem needs to be identified. As Uwe said, it appears that you have different versions of the class in your different systems.

If the method is public in system A, and protected in system B, then A and B must be at different releases. <b>What version and support packages are you on in both A and B?</b>

If B is at higher release, then you need to reconsider how you are using a the class. Perhaps there is a different method to be used now? If A is at a higher release than B, then you need to upgrade B to the same release as A.

rgds Matt

Read only

0 Likes
1,518

Hallo,

Yes we have different Packages, System B with the protected one is higher Package but same Release.

But no new method to use. No Methos that returns the Details or sets my data.

Is it usual, that sap changes such things with package upgrades?

Regards

Stefan

Read only

0 Likes
1,518

SAP can change anything with a new package. But they don't usually change the functionality much.

The code that you have posted is not using a method. It is accessing the attribute "ms_detail" directly. Try using

gs_detail = go_rental_object->get_detail().

instead.

Not having access to your systems, I can't tell precisely, but I suspect that the difference is that SAP have tightened up their coding, so that you can only access attributes via the GET_* and SET_* methods, which is, after all, better oo programming practice.

rgds, matt

Read only

0 Likes
1,518

Hi,

Still doesn't work with your code.

it doesn't realize the method call. it mention that there is an existing data ms_detail. (was that correct english?)

in my other Programm i have the same problem with the method call:

data go_rental_object    TYPE REF TO if_rebd_rental_object.

  go_specific ?= go_rental_object.  " narrowing cast
  call METHOD go_specific->SET_SNUNR
        EXPORTING ID_SNUNR = p_SNUNR.

System A is public method, System B protected

Best regards

stefan

Read only

0 Likes
1,518

How is method GET_DETAIL defined in A and in B. How is attribute ms_detail defined in A and in B.

It may be that the only resolution to your problem is to bring A and B to the same support level.

rgd, matt

Read only

0 Likes
1,518

The definitions are the same. It's just transported to System B.

No other solution than upgrade System A?

okay thank you for your help

Read only

0 Likes
1,518

Got some new information.

The Methods in Class CL_REBD_RENTAL_OBJECT_RU are all Public.

The Aliases in System A are public. in System B they are Protected.

example: IF_REBD_RENTAL_OBJECT~SET_SNUNR

Can i use the class-method without usind the alias?

Read only

0 Likes
1,518

That might work. Try something like

... = go_rental_object->if_rebd_rental_object~get_detail( ).

matt

Read only

0 Likes
1,518

GREAT!

Thank you!!

It works fine again.

I called the Method (secon problem) like this:

go_specific->if_rebd_rental_object~set_snunr( p_SNUNR ).

And it works finem, too

Many thanks again

Stefan