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

creating object through pattern button in abap editor?

Former Member
0 Likes
2,898

Dear abapers,

Create object abc

Type

Xyz

Exporting

Abc = xxxx

Xxxx = abc.

above code can we make through 'pattern' button in abap editor with out mention class in the radio button 'create object'?

10 REPLIES 10
Read only

Kiran_Valluru
Active Contributor
0 Likes
1,981

Hi,

You need to specify the class name. If you always want a static patter as like in your post, you can create a custom pattern in Abap Editor -> utilities -> more utilities -> edit pattern -> create pattern.

Regards,

Kiran

Read only

Former Member
0 Likes
1,981

If you are not going to mention class, how would editor know which object to create?

Read only

0 Likes
1,981

What chinm told is the correct point . Without mentioning class name you can not add object . That is where main difference between procedural programming and object oriented programming too. In functions you can directly add function module name here with out mentioning function group.

Regards,

Praveen chitturi.

Read only

Former Member
0 Likes
1,980

thanks for quick reply

as per this link

http://zevolving.com/2011/10/abap-objects-design-patterns-decorator/

through 'pattern' button on editor how to create object?

Read only

0 Likes
1,980

Hi,

When You click on Pattern button in abap editor, you can see ABAP Objects pattern. select the radio button corresponding to ABAP Objects pattern and click on OK button(or press enter), then in the following screen, you can select 'Create Object' pattern there.

Hope this helps u.,

Regards,

Kiran

Read only

Former Member
0 Likes
1,980

thanks kiran,

but for the following code snippet what you said is not working creating object 'lo_decorator'

for the decorator pattern, which class has to mention after clicking on create object radio button

plz go through the following link once

http://zevolving.com/2011/10/abap-objects-design-patterns-decorator/

Read only

0 Likes
1,980

Hi,

Follow the steps provided by Amy. You need to give OP_PDF which is the class name as well as instance name.

But As it is a local class, you will not get the pattern. If it is a Global class once you give the Class name and instance name it will search in the repository and generate the pattern. whereas for local classes it wont find the class name and hence you will not get the pattern.

Hope this helps u.,

Regards,

Kiran

Read only

amy_king
Active Contributor
0 Likes
1,980

Hi,

Since it looks like you want to create a PDF output object, the class you want is OP_PDF.

If you still want to create a custom pattern to avoid having to provide the class name, take a look at these documents to learn how to create your own pattern. Keep in mind though that each class' constructor (potentially) has different parameters, which is the reason the create object pattern requires the name of the class.

Cheers,

Amy

Read only

Former Member
0 Likes
1,980

A very nice and step-by-step guide for creating a pattern. Many thanks Amy

Read only

naimesh_patel
Active Contributor
0 Likes
1,980

I guess you got totally confused by the "Pattern" button in the Editor and the "Design Patterns".

Patterns button creates "raw" code for you so, you don't need to write everything. They are referred as the Statement Patterns.

Design Patterns are the building blocks you create within your ABAP development. These design patterns solves lot of complex problems and make the objects/classes more reusable. There are many design patterns e.g. Singleton, Mode View Controller, Iterator, Decorator (as you mentioned) , Facade, Composite etc. They have different degree of complexity as well as flexibility.

Like the decorator provides you the flexibility to add different flavors at runtime, provided you have successfully implemented Decorator Design pattern.

Like Composite lets you to only worry about the main object. As long as you do that operation. Composite would make sure that the operation would be carried over to all the objects within it. Same as achieved in HTML in ABAP utility where the method GET_HTML is composite, which keep on generating HTML for all of it children, and its children and so on and so forth.

Hope it helps to clear the doubt.

Regards,
Naimesh Patel