cancel
Showing results for 
Search instead for 
Did you mean: 

how to develop drop down menu on ever table cell

Former Member
0 Kudos

Hi Gurus,

Does anybody know how to develop drop down menu on <b>every</b> tableview cell?

Kindly refer to the below url at the 3rd screenshot where the drop down menu is.

/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator

I need this menu to be appeared into all my table cell. Any suggestion on how to those menus to be applied into my codes? Below are my codes.

<b>Layout</b>


<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
  <htmlb:page title="Modify table " >
    <htmlb:form>
      <htmlb:tray id     = "tray1"
                  title  = "Period Control Data"
                  design = "BORDER" >
        <htmlb:trayBody>
          <htmlb:tableView id             = "TV"
                           table          = "<%= itab %>"
                           design         = "ALTERNATING"
                           onRowSelection = "MyEventRowSelection"
                           selectionMode  = "MULTILINEEDIT"
                           columnWidth    = "150%"
                           filter         = "SERVER"
                           visibleRowCount = "16"
                           sort            = "SERVER"
                           iterator        = "<%= lw_iterator %>"/>
 
          <br>
          <br>
          <center>
          <htmlb:button id       = "update"
                        text     = "Update Record"
                        onClick  = "onInputProcessing"
                        design   = "emphasized"
                        disabled = "false" />
          </center>
        </htmlb:trayBody>
      </htmlb:tray>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

<b>Event Handler (OnInputProcessing)</b>


* To get the selected RowIndex...
CLASS cl_htmlb_manager DEFINITION LOAD.
 
DATA: tv          TYPE REF TO cl_htmlb_tableview,
      event       TYPE REF TO cl_htmlb_event,
      table_event TYPE REF TO cl_htmlb_event_tableview.
 
 
 
 
FIELD-SYMBOLS <i> LIKE LINE OF selectedrowindextable.
 
tv  ?= cl_htmlb_manager=>get_data( request = request
                                   name    = 'tableView'
                                   id      = 'TV' ).
 
IF tv IS NOT INITIAL.
  table_event = tv->data.
  CLEAR selectedrowindextable.
  selectedrowindextable = table_event->prevselectedrowindextable.
  IF table_event->event_type EQ cl_htmlb_event_tableview=>co_row_selection.
    READ TABLE selectedrowindextable WITH KEY table_line = table_event->row_index TRANSPORTING NO FIELDS.
    IF sy-subrc EQ 0.
      DELETE selectedrowindextable INDEX sy-tabix.
    ELSE.
      APPEND INITIAL LINE TO selectedrowindextable ASSIGNING <i>.
      <i> = table_event->row_index.
      zindex = table_event->row_index.
 
    ENDIF.
  ENDIF.
ENDIF.
 
 
 
 
* get the button event.
IF event_id = cl_htmlb_manager=>event_id.
  event = cl_htmlb_manager=>get_event( runtime->server->request ).
 
  IF event->name = 'button' AND event->event_type = 'click'.
    DATA : button_event TYPE REF TO cl_htmlb_event_button.
    button_event ?= event.
  ENDIF.
 
  CASE event->id.   " Use this for specifying code for different buttons.
    WHEN 'update'.          " This is the button id.
      tv ?= cl_htmlb_manager=>get_data(
             request      = request
             name         = 'tableView'
             id           = 'TV' ).
 
      IF tv IS NOT INITIAL.
        DATA : tv_data TYPE REF TO cl_htmlb_event_tableview .
        tv_data = tv->data.
*get values from screen to work-area...get_cell_value is for tableView and get_data is for other objects like inputfield
 
        wa-class     = tv_data->get_cell_value(
                                         row_index     = zindex
                                         column_index  = 1 ).
 
 
        wa-fiscper3  = tv_data->get_cell_value(
                                         row_index     = zindex
                                         column_index  = 2 ).
 
        wa-fiscyear  = tv_data->get_cell_value(
                                         row_index     = zindex
                                         column_index  = 3 ).
 
 
        wa-zg_pver   = tv_data->get_cell_value(
                                         row_index     = zindex
                                         column_index  = 4 ).
 
 
        MODIFY itab INDEX  zindex FROM wa .
 
        MODIFY ZRM_PERIOD_CTRL FROM wa.
 
 
      ENDIF.
  ENDCASE.
ENDIF.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Gary,

If your issue is resolved, Please Reply/Reward/Close this thread.

Thanks,

Tatvagna.

Former Member
0 Kudos

Hi Gary,

Would love to give you a code snippett...but sorry...too busy to spend time on this right now...

I know I already owe you two replies...

Anyways, the DDLB is defined in RENDER_CELL_START method...


When 'your_column_name'.
IF p_edit_mode IS NOT INITIAL.
<!--code-->      p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY(
<!--code-->                            id                = p_cell_id
<!--code-->                            selection     =  you_can_deprecate_this
<!--code-->                            table           = pass_table
<!--code-->                            nameOfKeyColumn   = 'NAME'
<!--code-->                            nameOfValueColumn = 'VALUE' ).

Pass an internal table type TIHTTPNVP to iterator while creating it.(This is discussed by Brian in his WL.)

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.

Former Member
0 Kudos

Hi Tatvagna,

I am so touched with all your answers. I sincerely thank god there's such a person who's willing to help I hope you'll spend some time with a newbie SAP programmer.

<b>What is a DDLB? Is the below codes a DDLB?</b>


When 'your_column_name'.
IF p_edit_mode IS NOT INITIAL.
<!--code-->      p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY(
<!--code-->                            id                = p_cell_id
<!--code-->                            selection     =  you_can_deprecate_this
<!--code-->                            table           = pass_table
<!--code-->                            nameOfKeyColumn   = 'NAME'
<!--code-->                            nameOfValueColumn = 'VALUE' ).

<b>So i'll apply the above coding to the below result in HTMLBTABLEVIEW_ITERATOR~RENDER_CELL_START right?</b>


method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

When 'CLASS'.
IF p_edit_mode IS NOT INITIAL.
      p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY(
                            id                = p_cell_id
                           selection     =  you_can_deprecate_this
                           table           = pass_table
                            nameOfKeyColumn   = 'NAME'
                            nameOfValueColumn = 'VALUE' ).

endmethod.

<b>What should be the value I have to fill in for table, nameOfKeyColumn & nameOfValueColumn.</b>

Thanks alot,

Gary

null

Former Member
0 Kudos

Hi Tatvagna or anyone,

I might need a little help on this to solve my development issue. It is slight on priority and your help will be very much appreciated.

Tatvagna has provided me some code snippett unfortunately I still couldn't figure it out as I am a very new SAP Developer here. I am still on training. Hope someone could provide a solution for this.

Thanks !

Gary

Former Member
0 Kudos

Hi,

as you took Tatvanga's coding for is the correct way. For your last question:

<i>What should be the value I have to fill in for table, nameOfKeyColumn & nameOfValueColumn.</i>

For attribute table you should give a table of values of which the user can select values in the dropdown.

Attribute nameOfKeyColumn is the (DDIC-)name of the column in internal table where you can find a key value.

Attribute nameOfValueColumn is the (DDIC-)name of the column in internal table where you can find the displayed text of dropdown-list.

(Perhaps it is the other way around - I often confuse this Simply test.)

Regards,

Sebastian

Patrick_McMahon
Contributor
0 Kudos

Hi Gary,

To populate the drop down value table, first build the value table. I usually use the table type TIHTTPNVP.

Then declare the following:

data: pass_table type ref to tihttpnvp.

When 'your_column_name'.
  IF p_edit_mode IS NOT INITIAL.
    get reference of value_table into pass_table.
    p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY( ...

Regards,

Patrick.

Former Member
0 Kudos

Help me to check if my steps are correct.

Alright now I’ve created an internal table on <b>Page Attributes</b>

Attribute – <b>iterator</b>

TypingMeth – <b>TYPE</b>

Associated Type – <b>TIHTTPNVP</b>

When I cicked on the internal table TIHTTPNVP, I couldn't find <b>HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START</b>. So, how do I insert the below codes into it? :



data: pass_table type ref to tihttpnvp.
 
When 'your_column_name'.
  IF p_edit_mode IS NOT INITIAL.
    get reference of value_table into pass_table.
    p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY( ...

My table name in se16 is <b>ZRM_PERIOD_CTRL.</b>

It has 4 fields which are: <b>CLASS, FISCPER3, FISCYEAR, ZG_PVER</b>

Each field contains some values in it.

Now I want each field, for example field <b>(FISCPER3)</b> has only few selection based on the drop down menu.

My questions are:

1) How do I insert those values into my <b>(FISCPER3)</b> drop down menu

2) How to develop those drop menu into each of my table cells

I need your help in providing me steps.

Thanks,

Gary

null

Patrick_McMahon
Contributor
0 Kudos

Hi Gary,

TIHTTPNVP is just the table type for the drop down table in your listbox. The code goes into your iterator class which you need to create using an iterface called IF_HTMLB_TABLEVIEW_ITERATOR - this will give you the methods to redefine.

Regards,

Patrick.

Former Member
0 Kudos

Hi again,

you have

<htmlb:tableView id = "TV"

table = "<%= itab %>"

design = "ALTERNATING"

onRowSelection = "MyEventRowSelection"

selectionMode = "MULTILINEEDIT"

columnWidth = "150%"

filter = "SERVER"

visibleRowCount = "16"

sort = "SERVER"

iterator = "<%= lw_iterator %>"/>

and the variable lw_iterator should point to an instance of a Z-class implementing the interface IF_HTMLB_TABLEVIEW_ITERATOR. So far this is in your system ? If not, create this Z-class.

In this Z-Class you have to implement method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START with Tatvangas coding. In this method you need the internal table for passing the values (not in page attributes). Since the method is called for every rendered cell in the tableview you should select the data of internal table somewhere else (e.g. an addinitional method 'init').

Back to your page with flow logic: You have to defined lw_iterator as a page attribute (TYPE REF your_new_class). Make an instance of your class and put it to lw_iterator in OnInitialization-Eventhandler of your page. Test it and all will be fine

I think that Brian's Weblog <a href="/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator:///people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator you've read, is the more detailed answer.

Regards,

Sebastian

Former Member
0 Kudos

Alright I've created a new class called Z_CLASS in se24.

I've applied the codes into IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START, but there is an error saying:

<b>

My Codes:</b>

method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

When 'CLASS'.

IF p_edit_mode IS NOT INITIAL.

p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY(

id = p_cell_id

selection = you_can_deprecate_this

table = pass_table

nameOfKeyColumn = 'NAME'

nameOfValueColumn = 'VALUE' ).

endmethod.

<b>

Error Message:</b>

“WHEN” is allowed only after “CASE”

Former Member
0 Kudos

Hi,

The when will come inside a CASE-ENDCASE.

CASE p_column_key.
   when 'CLASS'.
.....
ENDCASE.

Thanks,

Tatvagna.

Former Member
0 Kudos

Ok,

Lemme give you a sample code of what you need....!! <b>Note that this is a sample code...doing this for each column may cause performance issues....</b>

1) First, declare a table type TIHTTPNVP.

2) TIHHTTPNVP is the name-value pair table....for a DDLB(DropdownListBox) you need a name...which will be passed, and a value, which will be displayed on screen...!

3) Then create name value pair in internal table of type TIHTTPNVP.....

TYPES : begin of ty_class,
         class type DEL_OF_CLASS, " Use the data element of CLASS field in the Z table...
	end of ty_class.

data : itab_cl type standard table of ty_class.
	wa_cl like line of itab_cl.

data : NVP_TABLE type TIHTTPNVP,
       wa_nvp    type IHTTPNVP.


select CLASS from  ZRM_PERIOD_CTRL into table itab_cl.

loop at itab_cl into wa_cl.

  read table itab_cl into wa_cl index sy-tabix.
  wa_nvp-NAME = wa_cl-CLASS.
  wa_nvp-VALUE = wa_cl-CLASS. 
  append wa_nvp to NVP_TABLE.
endloop.

<b>Now....CASE - ENDCASE on column name....</b>

CASE p_column_key.
  when 'CLASS'.
    p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY(
                      id = p_cell_id
                   table = NVP_TABLE
         nameOfKeyColumn = 'NAME'
       nameOfValueColumn = 'VALUE' ).


ENDCASE.

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.

Message was edited by:

Tatvagna Shah

Former Member
0 Kudos

Hi Patrick,

Is table TIHTTPNVP a class & created in transaction se24?

Where should I put the following codes?

<b>

Insert into Event Handler?</b>

data: pass_table type ref to tihttpnvp.

<b>Insert into TIHTTP -> IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START </b>?

When 'your_column_name'.

IF p_edit_mode IS NOT INITIAL.

get reference of value_table into pass_table.

p_replacement_bee = CL_HTMLB_DROPDOWNLISTBOX=>FACTORY( ...

Thanks,

Gary

Former Member
0 Kudos

Hi Tatvagna,

<b>Where should I populate the below coding? into Event Handler -> OnInputProcessing?</b>

loop at itab_cl into wa_cl.
 
  read table itab_cl into wa_cl index sy-tabix.
  wa_nvp-NAME = wa_cl-CLASS.
  wa_nvp-VALUE = wa_cl-CLASS. 
  append wa_nvp to NVP_TABLE.
endloop.

Thanks,

Gary

Patrick_McMahon
Contributor
0 Kudos

Hi Gary,

TIHTTPNVP is a table type and is delivered as standard.

Both bits of code go into IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

Regards,

Patrick.

Former Member
0 Kudos

Hi Gary,

sorry but I think you should first become familiar with ABAP and than start on BSPs and not the other way around - get a good book like Programming with ABAP Objects from SAPPRESS and go through it. Or youput questions about CASE / ENDCASE or table types in the ABAP forum.

Regards,

Sebastian

Former Member
0 Kudos

Hi Sebastian,

Thanks for your advice. I understand that I have to be more knowledgable in abap programming before jumping into BSP but unfortunately this project is on the go, so somehow I have to complete it & I hope you could bare with me for sometime. I am sure I can be an expert in the future as I'm just starting out now.

From the reply you posted, you said:

<u>since the method is called for every rendered cell in the tableview you should select the data of internal table somewhere else (e.g. an addinitional method 'init').</u>

<b>My Question for the above: how do I create & select the internal table (not in page attributes). & How do I populate method 'init'</b>

<u>Make an instance of your class and put it to lw_iterator in OnInitialization-Eventhandler of your page</u>

<b>My Question for the above: How do I make an instance to lw_iterator?</b>

Thanks,

Gary

Former Member
0 Kudos

Hello guys,

I tried using the very 1st code as an example, but instead of updating the record its adding 1 more record to the tableview....any clues???