BSP / HowTo: Exploring BSP Development with MVC
For those of you not familiar with the series,
Standard BSP
- BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 – Introduction and beginning elements, sample data.
- BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 2 – Building the CLASSES and ITERATORS.
- Part 3 – Putting your pages in place.
- Part 4 – Extended Features
- BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 5 – Conclusions
Or for those of you wanting to take it in one large lump, you can view the article.
Again, the series was not intended to develop a high end production application but rather to give each person completing the tasks at hand a chance get their feet wet in terms of standard BSP development.
With a half a year behind us now and the forums beginning to fill up with more and more questions regarding MVC, I guess it is time. MVC, may sound strange at first but if you have been around object oriented programming long enough then the concept is not that unusual. For more information about this you can check out the following links:
The second link mentioned there also contains several examples and graphics from SAP about this topic. My attempt here is to try to simply things a bit with a working example similiar to the first tutorial series on standard BSP. With that all said, I thought this would be an apporpriate time to actually publish the second half of my tutorial series. “Exploring BSP development with MVC”, although I’m not 100% sure at the moment but I believe this series will also be broken up into 5 parts, however this could change so please bare with me. I try to keep my weblogs at a reasonable length as to not overload everyone.
- BSP / HowTo: Exploring BSP Development with MVC – Introduction, Tables, Table Types and sample data.
- Part 2 – Building the App.
- BSP / HowTo: Exploring BSP Development with MVC 2a – Building your Model
- BSP / HowTo: Exploring BSP Development with MVC 2b – Building your Controllers and Classes
- BSP / HowTo: Exploring BSP Development with MVC 2b_1 – Building your Controllers and Classes
- BSP / HowTo: Exploring BSP Development with MVC 2b_2 – Building your Controllers and Classes
- BSP / HowTo: Exploring BSP Development with MVC 2b_3 – Building your Controllers and Classes
- BSP / HowTo: Exploring BSP Development with MVC 2c – Building your views
- BSP / HowTo: Exploring BSP Development with MVC 2d – Building your views
- Part 3 – Working the App
- BSP / HowTo: Exploring BSP Development with MVC 3a – Display it and entering
- BSP / HowTo: Exploring BSP Development with MVC 3b – Editing and adding categories and subjects
- BSP / HowTo: Exploring BSP Development with MVC 4 – OTR
- BSP / HowTo: Exploring BSP Development with MVC 5 – Conclusions
As most developers will tell you there is really no need to reinvent the wheel and so to get us started we are simply going to take from the previous series as much as we can. For those of you who have not reviewed the previous series don’t despair I’ll put all the data in here as well.
Getting started
You will need to start by creating a new package, unless the package already exists.
Package Name: ZCSC_FAQ
The package is basically the container for all the elements, objects and pieces of our application.
Once the package is there we will then need to create our Dictionary Objects, these are our database tables and structures and types.
ZFAQ_CAT – Categories for your F.A.Q. | ||
ID | INT4 | |
NAME | CHAR32 | Name of the Category |
SRC | CHAR10 | Image source of the category e.g. @IY@ |
CAT_DESC | CHAR255 | Description for the category |
ZFAQ_DATA – Your F.A.Q.’s | ||
ID | INT4 | ID of Item |
CAT_ID | INT4 | Category ID |
SUBJECT | CHAR255 | Subject of the FAQ |
TITLE | CHAR255 | Title of the FAQ |
SHORT_DESC | CHAR255 | Short Description |
LONG_DESC | TEXT | Long Text description |
URL | CHAR255 | URL |
RATING | INT4 | Rating |
AUTHOR | CHAR50 | Author |
CDATE | CHAR10 | Creation Date |
ZFAQ_SDNRSS – For accessing SDN RSS Feeds | ||
TITLE | CHAR120 | |
LINK | CHAR255 | |
DESCRIPTION | CHAR255 | |
CREATOR | CHAR50 | |
PDATE | CHAR10 | |
SUBJECT | CHAR255 | |
ZFAQ_SUBJECT – FAQ Subjects | ||
ID | INT4 | ID of Item |
NAME | CHAR32 | Name of the subject |
SUBJECT_DESC | CHAR255 | Subject description |
ZFAQ_SDNRSSLINK – SDN RSS Links | ||
ID | INT4 | ID of Item |
NAME | CHAR32 | Name of the RSS link |
LINK | CHAR255 | Link |
Really, we’ll use each of them in this exercise. So now that you have those in place, you will now need to create a corresponding Table Type for each item. This is done by right clicking on your Dictionary Objects and choosing “Create” followed by “Table Type”
For ease of use and to try for some sort of naming convention I use the name of the table without spaces followed by the word TYPE on the end.
So when you are finished you should have 5 tables and 5 corresponding table types.
Now that you have the tables in place it’s time to fill them up with some initial data, just to help us get started. Just create a Program under your Package called ZFAQ_INITIAL_DATA and give it the following code.
> REPORT ZFAQ_INITIAL_DATA .
PARAMETERS: SetCat TYPE CHAR1,
SetSubj TYPE CHAR1,
SetRSS TYPE CHAR1.
DATA: wa_cat TYPE ZFAQ_CAT.
DATA: wa_subject TYPE ZFAQ_SUBJECT.
DATA: wa_rss TYPE ZFAQ_SDNRSSLINK.
IF SetCat EQ ‘X’.
wa_cat-ID = 1.
wa_cat-NAME = ‘SDN:Weblog’.
wa_cat-SRC = ‘@IY@’.
wa_cat-CAT_DESC = ‘Weblogs from the SAP Developer Network’.
insert into ZFAQ_CAT values wa_cat.
ENDIF.
IF SetSubj EQ ‘X’.
wa_subject-ID = 1.
wa_subject-NAME = ‘ABAP’.
wa_subject-SUBJECT_DESC = ‘ABAP Technology’.
insert into ZFAQ_SUBJECT values wa_subject.
wa_subject-ID = 2.
wa_subject-NAME = ‘BSP’.
wa_subject-SUBJECT_DESC = ‘Business Server Pages’.
insert into ZFAQ_SUBJECT values wa_subject.
ENDIF.
IF SetRSS EQ ‘X’.
wa_rss-ID = 1.
wa_rss-NAME = ‘SDN: Recent’.
wa_rss-LINK = ‘http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0‘.
insert into ZFAQ_SDNRSSLINK values wa_rss.
wa_rss-ID = 2.
wa_rss-NAME = ‘SDN: Craig Cmehil’.
wa_rss-LINK = ‘http://weblogs.sdn.sap.com/pub/q/weblog_rss_author?x-author=2538&x-ver=1.0‘.
insert into ZFAQ_SDNRSSLINK values wa_rss.
wa_rss-ID = 3.
wa_rss-NAME = ‘SDN: Brian McKellar’.
wa_rss-LINK = ‘http://weblogs.sdn.sap.com/pub/q/weblog_rss_author?x-author=164&x-ver=1.0‘.
insert into ZFAQ_SDNRSSLINK values wa_rss.
wa_rss-ID = 4.
wa_rss-NAME = ‘SDN: Thomas Jung’.
wa_rss-LINK = ‘http://weblogs.sdn.sap.com/pub/q/weblog_rss_author?x-author=1918&x-ver=1.0‘.
insert into ZFAQ_SDNRSSLINK values wa_rss.
ENDIF.
For those of you desiring the quick copy and paste method of code:
With that all in place we should be ready to move on to the actual application now and barring typing errors on my part and yours we should move along quite quickly.
Look for the next section coming soon!
looking forward to the other parts.
Regards
Raja