Create pointer to model<br>
model ?= get_model( 'mf' ).
clear lt_data.
lt_data = model->GET_FAQ_CAT( ).
if selectedRowIndex IS INITIAL.
selectedRowIndex = -1.
endif.
Data definitions<br>
data: default_view type ref to if_bsp_page.
Create view<br>
default_view = create_view( view_name = 'obj/cat.htm' ).
default_view->set_attribute( name = 'lv_data'
value = lt_data ).
default_view->set_attribute( name = 'iterator'
value = me ).
default_view->set_attribute( name = 'sri'
value = selectedRowIndex ).
default_view->set_attribute( name = 'lv_desc'
value = lt_desc ).
default_view->set_attribute( name = 'lv_id'
value = lt_id ).
default_view->set_attribute( name = 'lv_name'
value = lt_name ).
default_view->set_attribute( name = 'lv_src'
value = lt_src ).
default_view->set_attribute( name = 'lv_edit'
value = lt_edit ).
Call view<br>
call_view( default_view ).
endmethod.
|
DO_HANDLE_EVENT |
> |
Table Types<br>
data: wa TYPE ZFAQ_CAT.
Object definitions<br>
data: lt_event TYPE REF TO if_htmlb_data.
method DO_REQUEST .
Create pointer to model
model ?= get_model( 'mf' ).
clear lt_data.
lt_data = model->GET_FAQ_CAT( ).
if selectedRowIndex IS INITIAL.
selectedRowIndex = -1.
endif.
Data definitions
data: default_view type ref to if_bsp_page.
Create view
default_view = create_view( view_name = 'obj/cat.htm' ).
default_view->set_attribute( name = 'lv_data'
value = lt_data ).
default_view->set_attribute( name = 'iterator'
value = me ).
default_view->set_attribute( name = 'sri'
value = selectedRowIndex ).
default_view->set_attribute( name = 'lv_desc'
value = lt_desc ).
default_view->set_attribute( name = 'lv_id'
value = lt_id ).
default_view->set_attribute( name = 'lv_name'
value = lt_name ).
default_view->set_attribute( name = 'lv_src'
value = lt_src ).
default_view->set_attribute( name = 'lv_edit'
value = lt_edit ).
Call view
call_view( default_view ).
endmethod.
method DO_HANDLE_EVENT .
Table Types
data: wa TYPE ZFAQ_CAT.
Object definitions
data: lt_event TYPE REF TO if_htmlb_data.
data: table TYPE REF TO CL_HTMLB_TABLEVIEW.
data: table_event TYPE REF TO cl_htmlb_event_tableview.
lt_event = cl_htmlb_manager=>get_event_ex( request ).
if lt_event IS NOT INITIAL.
table ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
name = 'tableView'
id = 'cat_cattable' ).
if table IS NOT INITIAL.
table_event = table->data.
selectedRowIndex = table_event->SELECTEDROWINDEX.
READ TABLE lt_data INTO wa index selectedRowIndex.
lt_id = wa-id.
lt_desc = wa-cat_desc.
lt_name = wa-name.
lt_src = wa-src.
endif.
CASE event.
WHEN 'del'.
IF selectedRowIndex NE 0.
DELETE FROM ZFAQ_CAT WHERE ID = lt_id.
selectedRowIndex = 0.
lt_data = model->GET_FAQ_CAT( ).
lt_edit = ''.
SELECTEDROWINDEX = -1.
ENDIF.
WHEN 'edit'.
IF selectedRowIndex NE 0.
lt_edit = 'X'.
ENDIF.
WHEN 'add'.
CLEAR wa.
IF request->GET_FORM_FIELD( name = 'cat_id' ) IS NOT INITIAL.
wa-ID = request->GET_FORM_FIELD( name = 'cat_id' ).
wa-NAME = request->GET_FORM_FIELD( name = 'cat_name' ).
wa-SRC = request->GET_FORM_FIELD( name = 'cat_src' ).
wa-CAT_DESC = request->GET_FORM_FIELD( name = 'cat_desc' ).
UPDATE ZFAQ_CAT FROM wa.
lt_data = model->GET_FAQ_CAT( ).
ELSE.
"* Assign automatic ID for the next DATA entry
wa-ID = model->GET_NEXT_DATA_ID( table = 'ZFAQ_CAT' ).
wa-NAME = request->GET_FORM_FIELD( name = 'cat_name' ).
wa-SRC = request->GET_FORM_FIELD( name = 'cat_src' ).
wa-CAT_DESC = request->GET_FORM_FIELD( name = 'cat_desc' ).
INSERT INTO ZFAQ_CAT VALUES wa.
lt_data = model->GET_FAQ_CAT( ).
ENDIF.
lt_edit = ''.
ENDCASE.
endif.
endmethod.
Fingers cramping yet? So moving on...
ZFAQ_C_CL_SUBJECT
ZFAQ_C_CL_SDNLINKS
ZFAQ_C_CL_SUBJECT
LT_SRC
Attributes
as we don't need that one, then in theDO_REQUEST
you can remove the line where we assign the value ofLT_SRC
to thedefault_view
and modify the line where we assign data toLT_DATA
you will need to use the methodlt_data = model->GET_FAQ_SUBJECT( )
. Alsohighly
important is to change the line inDO_REQUEST
to default_view = create_view( view_name = 'obj/subject.htm' ).Method
the IF_HTMLB_TABLEVIEW_ITERATORRENDER_CELL_START</b>, remove all the code from there, however, do not "undefine it" just remove the code. This of course leaves us with the <b>DO_HANDLE_EVENT</b> and <b>IF_HTMLB_TABLEVIEW_ITERATORGET_COLUMN_DEFINITIONSTable Types<br>
data: wa TYPE ZFAQ_SUBJECT.
Object definitions<br>
data: lt_event TYPE REF TO if_htmlb_data.
method DO_HANDLE_EVENT .
Table Types
data: wa TYPE ZFAQ_SUBJECT.
Object definitions
data: lt_event TYPE REF TO if_htmlb_data.
data: table TYPE REF TO CL_HTMLB_TABLEVIEW.
data: table_event TYPE REF TO cl_htmlb_event_tableview.
lt_event = cl_htmlb_manager=>get_event_ex( request ).
if lt_event IS NOT INITIAL.
table ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
name = 'tableView'
id = 'subject_subjecttable' ).
if table IS NOT INITIAL.
table_event = table->data.
selectedRowIndex = table_event->SELECTEDROWINDEX.
READ TABLE lt_data INTO wa index selectedRowIndex.
lt_id = wa-id.
lt_desc = wa-subject_desc.
lt_name = wa-name.
endif.
CASE event.
WHEN 'del'.
IF selectedRowIndex NE 0.
DELETE FROM ZFAQ_SUBJECT WHERE ID = lt_id.
selectedRowIndex = 0.
lt_data = model->GET_FAQ_SUBJECT( ).
lt_edit = ''.
SELECTEDROWINDEX = -1.
ENDIF.
WHEN 'edit'.
IF selectedRowIndex NE 0.
lt_edit = 'X'.
ENDIF.
WHEN 'add'.
CLEAR wa.
IF request->GET_FORM_FIELD( name = 'subject_id' ) IS NOT
INITIAL.
wa-ID = request->GET_FORM_FIELD( name = 'subject_id' ).
wa-NAME = request->GET_FORM_FIELD( name = 'subject_name' ).
wa-SUBJECT_DESC = request->GET_FORM_FIELD( name =
'subject_desc' ).
UPDATE ZFAQ_SUBJECT FROM wa.
lt_data = model->GET_FAQ_SUBJECT( ).
ELSE.
"* Assign automatic ID for the next DATA entry
wa-ID = model->GET_NEXT_DATA_ID( table = 'ZFAQ_SUBJECT' ).
wa-NAME = request->GET_FORM_FIELD( name = 'subject_name' ).
wa-SUBJECT_DESC = request->GET_FORM_FIELD( name =
'subject_desc' ).
INSERT INTO ZFAQ_SUBJECT VALUES wa.
lt_data = model->GET_FAQ_SUBJECT( ).
ENDIF.
lt_edit = ''.
ENDCASE.
endif.
endmethod.
ZFAQ_C_CL_SDNLINKS
LT_SRC
Attributes
as we don't need that one, then in theDO_REQUEST
you can remove the line where we assign the value ofLT_SRC
to thedefault_view
and modify the line where we assign data toLT_DATA
you will need to use the methodlt_data = model->GET_FAQ_RSSLINKS( )
. Now a bit differnt to the last as well we are going to changeLT_DESC
toLT_LINK
. So change it underAttributes
and then inDO_REQUEST
as well. Alsohighly
important is to change the line inDO_REQUEST
to default_view = create_view( view_name = 'obj/sdnlinks.htm' ).Method
the IF_HTMLB_TABLEVIEW_ITERATORRENDER_CELL_START</b>, remove all the code from there, however, do not "undefine it" just remove the code. This of course leaves us with the <b>DO_HANDLE_EVENT</b> and <b>IF_HTMLB_TABLEVIEW_ITERATORGET_COLUMN_DEFINITIONSTable Types<br>
data: wa TYPE ZFAQ_SDNRSSLINK.
Object definitions<br>
data: lt_event TYPE REF TO if_htmlb_data.
method DO_HANDLE_EVENT .
Table Types
data: wa TYPE ZFAQ_SDNRSSLINK.
Object definitions
data: lt_event TYPE REF TO if_htmlb_data.
data: table TYPE REF TO CL_HTMLB_TABLEVIEW.
data: table_event TYPE REF TO cl_htmlb_event_tableview.
lt_event = cl_htmlb_manager=>get_event_ex( request ).
if lt_event IS NOT INITIAL.
table ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
name = 'tableView'
id = 'sdnlinks_sdnlinkstable' ).
if table IS NOT INITIAL.
table_event = table->data.
selectedRowIndex = table_event->SELECTEDROWINDEX.
READ TABLE lt_data INTO wa index selectedRowIndex.
lt_id = wa-id.
lt_link = wa-link.
lt_name = wa-name.
endif.
CASE event.
WHEN 'del'.
IF selectedRowIndex NE 0.
DELETE FROM ZFAQ_SDNRSSLINK WHERE ID = lt_id.
selectedRowIndex = 0.
lt_data = model->GET_FAQ_RSSLINKS( ).
lt_edit = ''.
SELECTEDROWINDEX = -1.
ENDIF.
WHEN 'edit'.
IF selectedRowIndex NE 0.
lt_edit = 'X'.
ENDIF.
WHEN 'add'.
CLEAR wa.
IF request->GET_FORM_FIELD( name = 'sdnlinks_id' ) IS NOT
INITIAL.
wa-ID = request->GET_FORM_FIELD( name = 'sdnlinks_id' ).
wa-NAME = request->GET_FORM_FIELD( name = 'sdnlinks_name' ).
wa-LINK = request->GET_FORM_FIELD( name =
'sdnlinks_link' ).
UPDATE ZFAQ_SDNRSSLINK FROM wa.
lt_data = model->GET_FAQ_RSSLINKS( ).
ELSE.
"* Assign automatic ID for the next DATA entry
wa-ID = model->GET_NEXT_DATA_ID( table = 'ZFAQ_SDNRSSLINK' ).
wa-NAME = request->GET_FORM_FIELD( name = 'sdnlinks_name' ).
wa-LINK = request->GET_FORM_FIELD( name =
'sdnlinks_link' ).
INSERT INTO ZFAQ_SDNRSSLINK VALUES wa.
lt_data = model->GET_FAQ_RSSLINKS( ).
ENDIF.
lt_edit = ''.
ENDCASE.
endif.
endmethod.
Each of these controllers will handle all of our setup and configuration tasks that we will associate with this application.