cancel
Showing results for 
Search instead for 
Did you mean: 

Where is the "Model" In the MVC paradigm of WD4A?

Former Member
0 Kudos

Hi All.

I started WD4A around a month back. I have gone through various tutorials. I have never worked before with an MVC paradigm.

I can now very well visualize a View and a controller - since these are the terms I read and encounter very often in WD4A.

But where does the MODEL fit in?

I asked my friends in WD4J and they say over there they need Model to wrap a BAPI call. In WD4A since there is no need to wrap a BAPI Call, does a model really exist?

Can someone please shed light on this concept? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member196517
Contributor
0 Kudos

Thats correct Aishi, there should be a complete seperation between UI and your business logic so what generally is done is a new webdynpro component is made without any views , its basic functionality is to interact with core classes and function modules to get data. Now another WD component is made along with all required views and this component uses the previous one to fetch the data.

thanks

Anuj

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks everyone.

Former Member
0 Kudos

Models exist in WDA.

They are i FUNCTIONs or CLASSes that you call from Comp Controller.

No access to business data directly in WDA.

Simple acid test, could some achieve some result in WDJ ?

If so they called a class/service/function , they used a model wrapper.

in WDA. The Function or Class is the model that may or maynot be a wrapper.

If you see SELECT statements in WDA componentsor views, you know they programmer doesnt care about MVC.

WDA allows you to not do MVC. But you need to be lazy and a little foolish to do so.

MODEL WDCs were originally part of design.

The use of them is not enforced since MVC is still possible with model components.

Of course now people can abuse the freedom. but a price worth paying.

cheers

Phil

SergioFerrari
Active Contributor
0 Kudos

In add, I noted that the Code Inspector reports a warning if SELECT stataments are used in the VIEWs and so if you are not using MVC...

Sergio

Former Member
0 Kudos

Hi Aishi.

Just another point of view. As Rich already stated the model contains the

business logic which is a set of data and the methods on it.

So you can imagine that the model often already exists in you SAP system, e.g.

all tables to store order data (header, items, and so on). There are BAPI's that are

the methods you can use on that model. So in this case you are right. You

wouldnt define a new model for this. You just call the BAPI which is the part of the

model you use in this case.

But if you need to define a new model for what ever the way to go is like Rich explained in his post.

Cheers,

Sascha

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

That's right, when working with WDJ, you do need to use a Model to wrap the RFC, BAPI, or web service. The model in WDA is kind of different. You know that MVC says that you should have good separation between the UI logic and the business logic, so it is suggest to put all of your business logic in a separate model class. The term "Model" class is not specific to a certain kind of class, it is simply what the class does, the business logic. The key thing to remember when creating this class, is that it should inherit from the CL_WD_COMPONENT_ASSISTANCE class. This allows it to be used as an assistance class in your WDA component. This gives you direct access to the class via the WD_ASSIST attribute which will be added when defining the assistance class in the WD component overview screen. Then in your WDA component, you can simply do the business logic by coding....

 itab = wd_assist->read_data_from_db.

Of course, you would then have to set the data to the context.

This is basically the Model concept in WDA.

Regards,

RIch Heilman