cancel
Showing results for 
Search instead for 
Did you mean: 

Overloaded method with SAPbouiCOM-Object parameters

Former Member
0 Kudos

Hi!

I've written an overloaded method with the following signatures:

1.


        Public Shared Sub AddCfl( _
            ByRef FormCfls As SAPbouiCOM.ChooseFromListCollection, _
            ByVal LinkedObj As SAPbouiCOM.BoLinkedObject, _
            ByRef CflEtx As SAPbouiCOM.EditText, _
            ByVal CflUidEtx As String, _
            ByVal CflAliasEtx As String, _
            Optional ByRef CflBtn As SAPbouiCOM.Button = Nothing, _
            Optional ByVal CflUidBtn As String = "", _
            Optional ByRef oCons As SAPbouiCOM.Conditions = Nothing _
        )

2.


        Public Shared Sub AddCfl( _
            ByRef FormCfls As SAPbouiCOM.ChooseFromListCollection, _
            ByVal LinkedObj As SAPbouiCOM.BoLinkedObject, _
            ByRef CflBtn As SAPbouiCOM.Button, _
            ByVal CflUidBtn As String, _
            Optional ByRef oCons As SAPbouiCOM.Conditions = Nothing _
        )

3.


        Public Shared Sub AddCfl( _
            ByRef FormCfls As SAPbouiCOM.ChooseFromListCollection, _
            ByVal LinkedObj As SAPbouiCOM.BoLinkedObject, _
            ByRef CflCol As SAPbouiCOM.Column, _
            ByVal CflUidCol As String, _
            ByVal CflAliasCol As String, _
            Optional ByRef oCons As SAPbouiCOM.Conditions = Nothing _
        )

When I try to use the method with first (1.) signature and WITHOUT the optional parameters then I get a very long exception-message: Sth. about "cannot convert into column type".

I guess that .NET is not able to distinguish between signature No 1. and No 3.: Both have the same count of parameters when using No. 1. without the optional param.

But as I understand overloading should also work with the same param.-count as long as the params are of different types, isn't it?

So am I right when saying, that the problem is the COM-Objekt and .NET simply can't distinguish between the types SAPbouiCOM.EditText and SAPbouiCOM.Column?

Thanks for comments!

Roland

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you guys for confirming and the tips

Nussi
Active Contributor
0 Kudos

Hi Roland,

i also do it like Petr - i create a big method with a switch.

there're some alternative in the web for c# like parameter arrys or create an object for it

but a switch with a single method is the easiest.

lg David

Former Member
0 Kudos

Roland,

I think that you are true. My suggestion is to add in one of method some temp variable with default value which you will not use inside or set CflCol as variant and inside check the type and call the proper method in case, that the is other than you are expecting. Its just idea...