Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
craigcmehil
Community Manager
Community Manager
0 Kudos
BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 3a
BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 3b

    1. Part 4 - Extended Features

BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 4a
BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 4b




As you've seen BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 gave us the foundation for holding all of our data and then in BSP / HowTo: Exploring BSP Development and the MiniWAS 6.20 Part 2 we put our background data handling and rendering classes into place. Now as we move into Part 3 we will begin to build our pages and start to see this take shape.



OK, we've got some changes and additions to make so let's get those out of the way first OK.



We need to create 2 more Tables and Table Types.



ZFAQ_SUBJECT and ZFAQSUBJECTAB with corresponding Table Types ZFAQ_SDNRSSLINK and ZFAQSDNRSSLINKTAB



ZFAQ_SUBJECT

ID INT4

NAME CHAR32 Name of the Subject

SUBJECT_DESC CHAR255 Description for the subject



ZFAQ_SDNRSSLINK

ID INT4

NAME CHAR32 Name of the RSS Link

LINK CHAR255 Link





Now we also need to add our new methods for retrieving the data.



GET_FAQ_CAT, GET_FAQ_SUBJECT, and GET_FAQ_RSSLINK each of these are the same with simply the table name changed.


  select * from
  into table DATA.
Page Fragments, the idea here is not to show perfect form but rather to show the various possiblities and
    real life applications of the BSP programming language that we have so often talked about
    on SDN
   





As you may be tempted to change content of the pages I ask that you please leave the content in tact until we are finished with this little exercise (around Part 5 I think).
  • event handler for checking and processing user input and
  • for defining navigation


DATA: event TYPE REF TO IF_HTMLB_DATA.


  • Get HTML Manager
event = CL_HTMLB_MANAGER=>get_event_ex( request ).


  • Check if one of the image buttons was clicked.
IF event IS NOT INITIAL
   AND event->event_name = htmlb_events=>button.
  navigation->goto_page( 'faq.htm' ).
ENDIF.



For more information on the Event Handlers please take a look BSP Trouble Shooting: Frequently Asked (Short) Questions.
  • this handler is called once the page is first created (stateful mode)
  • it performs a once-off data initialization or object creation


CREATE OBJECT obj.


faqtab = obj->GET_FAQ_DATA( ).





OnInputProcessing:


  • BSP Elements and Events
DATA: tabStrip TYPE REF TO CL_XHTMLB_TABSTRIP.
DATA: table TYPE REF TO CL_HTMLB_TABLEVIEW.
DATA: table_event TYPE REF TO cl_htmlb_event_tableview.
DATA: event TYPE REF TO IF_HTMLB_DATA.
DATA: ddlb TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.
DATA: listbox TYPE REF TO CL_HTMLB_LISTBOX.
DATA: rbg TYPE REF TO CL_HTMLB_RADIOBUTTONGROUP.


  • Data definitions
DATA: selectedRowIndex TYPE i.
DATA: myCategory TYPE STRING.
DATA: myRating TYPE STRING.
DATA: tmpSubject TYPE i,
      mySubject TYPE STRING,
      mySubjects TYPE STRING.


  • Table Types
DATA: wa TYPE ZFAQ_DATA.
DATA: fitab TYPE ZFAQ_DATA.


  • Get HTML Manager
event = CL_HTMLB_MANAGER=>get_event_ex( request ).


  • Get Tab Strip and check for tab selected.
tabStrip ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                 name    = 'xhtmlb:tabstrip'
                                 id      = 'myTabs' ).


  • Retrieve selected tab name and check if it is already selected
IF tabStrip->selection NE me->myTab.
  me->myTab = tabStrip->selection.
  CASE me->myTab.
    WHEN 'FAQ'.
  • Here we can do specific processing if the tab is selected.


  ENDCASE.
ENDIF.


  • Retrieve selected row FAQ table if the tab is
  • FAQ tab
CASE me->myTab.
  WHEN 'FAQ'.
    table ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                      name    = 'tableView'
                                      id      = 'faqData' ).
ENDCASE.


IF table IS NOT INITIAL.
  table_event = table->data.
  selectedRowIndex = table_event->SELECTEDROWINDEX.
ENDIF.


  • Check if one of the image buttons was clicked.
IF event IS NOT INITIAL
   AND event->event_name = htmlb_events=>image.


  CASE event->event_id.
    WHEN 'SDNIMP'.
      navigation->goto_page( 'sdn.htm' ).
    WHEN 'ADDSUBJECTFORM'.
      navigation->goto_page( 'cat.htm' ).
    WHEN 'ADDCATFORM'.
      navigation->goto_page( 'subject.htm' ).
    WHEN 'ADDFAQFORM'.
      visibleForm = 'addfaq'.
    WHEN 'VIEWFAQ'.
      visibleForm = 'viewfaq'.
      READ TABLE faqtab INTO curfaq INDEX selectedRowIndex.
    WHEN 'CANADDFAQ'.
      visibleForm = ''.
    WHEN 'ADDFAQ'.
      CLEAR wa.
  • In this case we will gather the values from the different
  • HTMLB form elements. Notice the various ways to do this.
      ddlb ?= CL_HTMLB_MANAGER=>GET_DATA(
                        request = request
                        id = 'faq_category'
                        name = 'dropdownListBox' ).
      myCategory = ddlb->selection.


      rbg ?= CL_HTMLB_MANAGER=>GET_DATA(
                        request = request
                        id = 'faq_rating'
                        name = 'radioButtonGroup' ).
      myRating = rbg->selection->value.


      listbox ?= CL_HTMLB_MANAGER=>GET_DATA(
                        request = request
                        id = 'faq_subject'
                        name = 'listBox' ).
      CLEAR mySubjects.
      LOOP AT listbox->selections INTO mySubject.
        tmpSubject = mySubject.
        mySubject = obj->GET_SUBJECT_NAME( id = tmpSubject ).
        CONCATENATE
          mySubject
          mySubjects
        INTO mySubjects SEPARATED BY ','.
      ENDLOOP.


      wa-ID = obj->GET_NEXT_DATA_ID( table = 'ZFAQ_DATA' ).
      wa-CDATE =  SY-DATUM.
  • Get from select list
      wa-CAT_ID = myCategory.
      wa-SUBJECT = mySubjects.
  • Get from radio group
      wa-RATING =  myRating.
  • Get from form data
      wa-AUTHOR = request->GET_FORM_FIELD( name = 'faq_author' ).
      wa-TITLE =  request->GET_FORM_FIELD( name = 'faq_title' ).
      wa-URL =  request->GET_FORM_FIELD( name = 'faq_url' ).
      wa-SHORT_DESC =  request->GET_FORM_FIELD(
                                name = 'faq_short_desc' ).
      wa-LONG_DESC =  request->GET_FORM_FIELD( name = 'faq_long_desc' ).


      INSERT INTO ZFAQ_DATA VALUES wa.
      faqtab = obj->GET_FAQ_DATA( ).
    WHEN 'DELFAQ'.
      IF selectedRowIndex NE 0.
        READ TABLE faqtab INTO fitab index selectedRowIndex.
        DELETE FROM ZFAQ_DATA WHERE ID = fitab-id.
        selectedRowIndex = 0.
        faqtab = obj->GET_FAQ_DATA( ).
      ENDIF.
  ENDCASE.


ENDIF.



Watch for comments in the code itself for various tips and hints on how to do things and what could possibly be changed.



Due to the size of this weblog in the moment I've decided to break Part 3 into two sub parts. This first part will let you add a new entry, display the entry, delete the entry and should give you very good examples for working with BSP's in various different ways. Remember this is an example of the various ways of working with the different elements, this is in no means an "efficient" production application.



Please go ahead and get these elements built and in place and in the next weblog we will finish of the "EDITING" and the additions of categories and subject types and we'll also cover how to create your text for the various menus using the OTR.



Oh and for those of you interested I'll be redoing this application into a "Model View" application type after we have completed these exercises. Look for that sometime in October.



<b>Error found:</b> Sorry about that please adjust these lines.

style="border:thin none;width:300px;background-color:lightgrey;background:lightgrey">
WHEN 'ADDSUBJECTFORM'.

navigation->goto_page( 'cat.htm' ).

WHEN 'ADDCATFORM'.

navigation->goto_page( 'subject.htm' ).




Please change the cat.htm and subject.htm around.




10 Comments