cancel
Showing results for 
Search instead for 
Did you mean: 

auto populate column based on other in tableview

Former Member
0 Kudos

Hi,

I have a requirement in which there is a column accounts, which has one to one relation with the column division in the master table. Now when i select any account, the division field should get auto populated and it should not be editable.

I am using iterator for displaying columns in the tableview.

<i>Suggestions are always rewarded</i>

Regards,

Rohit Khetarpal

Accepted Solutions (1)

Accepted Solutions (1)

raja_thangamani
Active Contributor
0 Kudos

Rohit,

Same issue discussed in below thread..

<i>* Reward each useful answer</i>

Raja T

Former Member
0 Kudos

Hi,

I saw that thread, there u have used MVC concept... but i dont want to use that as i have devolped other functionalities without using it.. cant we do it without that?

Please suggest.

Regards,

Rohit

Former Member
0 Kudos

Hi Rohit,

There is a rather ugly way to accomplish this.

You can create a dummy column in the GET_COLUMN_DEFINITIONS.

In the RENDER_CELL_START, you check on this column to get the data in the iterator. Generate a replacement bee like this:


  CASE p_column_key.
    WHEN 'DUMMY'.
* Get data
...

* Generate replacement bee
        p_replacement_bee ?= cl_htmlb_textview=>factory( text = text_you_want_to_output ).
  ENDCASE.

Kind regards,

Luk

raja_thangamani
Active Contributor
0 Kudos

Rohit,

There is not much difference between MVC & Flowlogic apart of methods..

I modifed the code as per Flowlogic..

Write the below code in Iterator of tableview TV1:

Lets assume TV1 has field Account, Division & button('3rd column'):

<b>Layout of TV1</b>


      <htmlb:tableView id               = "tv1"
                       width            = "200"
                       headerVisible    = "true"
                       design           = "alternating"
                       visibleRowCount  = "10"
                       fillUpEmptyRows  = "true"
                       selectionMode    = "SINGLESELECT"
                       selectedRowIndex = "<%= row_index %>"
                       onRowSelection   = "MyEventRowSelection"
                       showNoMatchText  = "true"
                       filter           = "server"
                       sort             = "server"
                       onHeaderClick    = "MyEventHeaderClick"
                       table            = "<%= it_initial %>"
                       iterator         = "<%= iterator1 %>" >
      </htmlb:tableView>

<b>Write the below code in Iterator1:</b>

In method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START:

        WHEN 'Expand'.
          CONCATENATE 'expand' row_ref->account INTO l_event SEPARATED BY '-'.
          p_replacement_bee = cl_htmlb_button=>factory( id      = l_cell_id
                                                                   text    = 'select'
                                                                   onclick = l_event
                                                                   tooltip = l_tooltip ).
      ENDCASE.

  • Here button event l_event will have value "event-exapnd-youraccount_numnber"

<b>OnInputprocessing:</b>

DATA EVENT TYPE REF TO CL_HTMLB_EVENT.

EVENT ?= CL_HTMLB_MANAGER=>GET_EVENT_EX( REQUEST ).

IF event->server_event+0(6) = 'expand'.

SPLIT event->server_event AT '-' INTO l_dummy l_account.

account = l_accout.

  • Pass the account into another page which has the table_view TV2.

<b>* Page for tv2</b>

<b>Accthelp.htm</b>

* The moment user selects the Particular row, event will trigger & populate the "Division" in TV1 of previous View

      <htmlb:tableView id               = "tv2"
                       width            = "200"
                       headerVisible    = "true"
                       design           = "alternating"
                       visibleRowCount  = "10"
                       fillUpEmptyRows  = "true"
                       selectionMode    = "SINGLESELECT"
                       selectedRowIndex = "<%= row_index %>"
                       onRowSelection   = "MyEventRowSelection"
                       showNoMatchText  = "true"
                       filter           = "server"
                       sort             = "server"
                       onHeaderClick    = "MyEventHeaderClick"
                       table            = "<%= model->it_account %>"
                       iterator         = "<%= iterator2 %>" >
      </htmlb:tableView>



<b>Oninputprocessing:</b>

* To capture the row select event

  DATA: IND TYPE I.
  DATA: TV TYPE REF TO CL_HTMLB_TABLEVIEW.
  DATA: EVENT1 TYPE REF TO CL_HTMLB_EVENT.
  EVENT1 = CL_HTMLB_MANAGER=>GET_EVENT( RUNTIME->SERVER->REQUEST ).
  TV ?= CL_HTMLB_MANAGER=>GET_DATA(
  REQUEST = RUNTIME->SERVER->REQUEST
  NAME = 'tableView'
  ID = 'tv2' ).
  IF TV IS NOT INITIAL.
    DATA: TV_DATA TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
    TV_DATA = TV->DATA.
 
    IF TV_DATA->SELECTEDROWINDEX IS NOT INITIAL.
      DATA: ROW LIKE LINE OF model->it_account.
      READ TABLE model->it_account INDEX TV_DATA->SELECTEDROWINDEX INTO ROW.
      DATA VALUE TYPE STRING.
 * Here ROW will have the selected row records
      division = ROW-division.

* Pass this division & account to the main page.

    ENDIF.
  ENDIF.
 

Now at last, To update the division in the tableview, write the below code in Oninitialization of main htm page.

If division is not initial.

  loop at your it_initial  into wa.
    wa-division =  division. "Which we received from another page.
modify the it_initial from wa.

  endloop.

endif.

Hope this will help you

Raja T

Former Member
0 Kudos

Hi Raja,

Sorry for coming back so late, actually there was a change in requirement.

Presently i have a field say account in a tableview, when i enter something in the field either manually or through pop up help, corresponding division (adjacent column in same tableview) should get auto populated from the table. (may be by pressing enter in the accounts field)

How can i achieve that... how can we capture enter in tableview..?? I am using iterator to display tableview.

Regards,

Rohit Khetarpal

Answers (0)