09-11-2018 10:35 AM
I really like to work with quick fixes, but I’m missing one feature in creation of methods from quick fix. If I take an existing class “ZCL_NEW_CLASS” and try to instatiate an object from it there is no quick fix to add a constructor from the given context. Is this planned or could it be added to the list of quick fixes to enable in future?
Example:
DATA(example) = NEW ZCL_NEW_CLASS( is_marc = ls_marc ).
CTRL+1 on “ZCL_NEW_CLASS” should give the suggestion “Create constructor” with parameter is_marc with type of the supplied ls_marc, as in the normal object->new_method( ) Quick fix.
Regards, Phillip
09-11-2018 12:31 PM
Quick fixes exist to create constructors, class constructors and factory methods. But you need to do it from the class, just position your cursor on the class definition statement. It will ask you which attributes to create importing parameters for and generate the code for those too.
09-11-2018 12:31 PM
Quick fixes exist to create constructors, class constructors and factory methods. But you need to do it from the class, just position your cursor on the class definition statement. It will ask you which attributes to create importing parameters for and generate the code for those too.
09-19-2018 7:48 AM
Hey Mike,
okay so there is no other way at the moment? I'm aware of this feature but I hoped there was a way to avoid jumping into the class just for creating the constructor..
Regards,
Phillip
09-20-2018 10:11 AM
No, but it's not a huge effort. <F3>, <ctrl-1>, generate constructor/factory method/...
But this won't include parameters. But the quick-fix for creating constructors or factory methods will offer to include the class's attributes as parameters - and I think that makes more sense than your calling code proposing the names.
IMHO constructors should be local or internal to a class anyway, factory method are a far better alternative. If you want, you can include parameters with a quick fix when creating methods. So if you do a quick fix on 'new' it should propose i as a parameter:
data(obj) = zcl_class=>new( i = 1 ).
09-25-2018 8:47 AM
Thats the clue I needed thanks. I totally ignored factory methods.