Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV OOPS (Top-Of-Page)

Former Member
0 Kudos

Hi Experts

When i am doing the total records in top-of-page. its picking all the buttons same . how can i do total records for each button in oops concept.please help me and one more thing is when you double click on cell its displaying the secondary list and coming back to first list i am loosing the total expect double click colum.how does it happen.

21 REPLIES 21

narin_nandivada3
Active Contributor
0 Kudos

Hi Reddy,

Please check this blog..

Hope this would help you.

Good luck

Narin

0 Kudos

Hi Narin

Already i got the top-of-page but total records is not changing when u click on other buttons . its giving the same records

Edited by: reddy on Sep 26, 2008 9:34 AM

0 Kudos

When you click on the Button , Refresh the TOP of page control , Initialize the topofpage control, again call the Display method with the updated content.

0 Kudos

Hi,

Everytime after the click before anything happens Refresh the control.

Hope it helps.

Good luck

Narin

0 Kudos

Hi Vijay Garu

How can i do that . Do u have any sample program with different buttons and different top-of-page please help me and other thing is i am having problem with double click event.its working fine but as soon as i am coming back initial screen its only giving the total one that i click rest of the colums its not giving total.how can i do that.

0 Kudos

I just Modifed my weblog code. and i set the UPDATE button in the Status on application toolbar.

REPORT  z_oo_alv_top_of_page  MESSAGE-ID zz  .
DATA: it_flight TYPE TABLE OF sflight.

DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm.

DATA:
g_container   TYPE scrfname VALUE 'CONTROL',
o_dyndoc_id   TYPE REF TO cl_dd_document,
o_splitter    TYPE REF TO cl_gui_splitter_container,
o_parent_grid TYPE REF TO cl_gui_container,
o_parent_top  TYPE REF TO cl_gui_container,
o_html_cntrl  TYPE REF TO cl_gui_html_viewer.

*----------------------------------------------------------------------*
*       CLASS LCL_EVENT_HANDLER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
  PUBLIC SECTION .
    METHODS:
*Event Handler for Top of page
    top_of_page FOR EVENT top_of_page
           OF cl_gui_alv_grid
           IMPORTING e_dyndoc_id.
ENDCLASS.             "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*       CLASS LCL_EVENT_HANDLER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
  METHOD top_of_page.
* Top-of-page event
    PERFORM event_top_of_page USING o_dyndoc_id.

  ENDMETHOD.                            "top_of_page
ENDCLASS.       "LCL_EVENT_HANDLER IMPLEMENTATION


DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
      g_handler TYPE REF TO lcl_event_handler. "handler

START-OF-SELECTION.
  SELECT *
  FROM sflight
  UP TO 20 ROWS
  INTO TABLE it_flight.

END-OF-SELECTION.

  IF NOT it_flight[] IS INITIAL.
    CALL SCREEN 100.
  ELSE.
    MESSAGE i002 WITH 'NO DATA FOR THE SELECTION'(004).
  ENDIF.
*----------------------------------------------------------------------*
*  MODULE STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS'.
  SET TITLEBAR 'TITLE'.
  IF g_custom_container IS INITIAL.
    PERFORM create_and_init_alv.
  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*----------------------------------------------------------------------*
*  MODULE USER_COMMAND_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
    when 'UPDATE'.
     free o_dyndoc_id.
* Create TOP-Document
  CREATE OBJECT o_dyndoc_id
  EXPORTING style = 'ALV_GRID'.
* Top-of-page event
  PERFORM event_top_of_pageupd USING o_dyndoc_id.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  CREATE_AND_INIT_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM create_and_init_alv .

  DATA: g_grid TYPE REF TO cl_gui_alv_grid.
  CREATE OBJECT g_custom_container
  EXPORTING container_name = g_container.

* Create TOP-Document
  CREATE OBJECT o_dyndoc_id
  EXPORTING style = 'ALV_GRID'.
* Create Splitter for custom_container
  CREATE OBJECT o_splitter
  EXPORTING parent  = g_custom_container
  rows    = 2
  columns = 1.
  CALL METHOD o_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = o_parent_top.

  CALL METHOD o_splitter->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = o_parent_grid.

* Set height for g_parent_html
  CALL METHOD o_splitter->set_row_height
    EXPORTING
      id     = 1
      height = 50.

  CREATE OBJECT g_grid
  EXPORTING i_parent = o_parent_grid.
  CREATE OBJECT g_handler.

  SET HANDLER g_handler->top_of_page FOR g_grid.
*Calling the Method for ALV output
  CALL METHOD g_grid->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SFLIGHT'
    CHANGING
      it_outtab        = it_flight[].
*
  CALL METHOD o_dyndoc_id->initialize_document
    EXPORTING
      background_color = cl_dd_area=>col_textarea.

* Processing events
  CALL METHOD g_grid->list_processing_events
    EXPORTING
      i_event_name = 'TOP_OF_PAGE'
      i_dyndoc_id  = o_dyndoc_id.

ENDFORM.                     "CREATE_AND_INIT_ALV
*&---------------------------------------------------------------------*
*&      Form  EVENT_TOP_OF_PAGE
*&---------------------------------------------------------------------*
FORM event_top_of_page USING   dg_dyndoc_id TYPE REF TO cl_dd_document.

CALL METHOD dg_dyndoc_id->initialize_document
    EXPORTING
      background_color = cl_dd_area=>col_tree_level4.

  DATA : dl_text(255) TYPE c.  "Text
  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text         = 'Flight Details'
      sap_style    = cl_dd_area=>heading
      sap_fontsize = cl_dd_area=>large
      sap_color    = cl_dd_area=>list_heading_int.

  CALL METHOD dg_dyndoc_id->add_gap
    EXPORTING
      width = 200.

  CALL METHOD o_dyndoc_id->add_picture
    EXPORTING
      picture_id = 'ENJOYSAP_LOGO'.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.

  CALL METHOD dg_dyndoc_id->new_line.


  CLEAR : dl_text.

* program ID
  dl_text = 'Program Name :'.

  CALL METHOD dg_dyndoc_id->add_gap.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_heading_int.

  CLEAR dl_text.

  dl_text = sy-repid.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.


  CLEAR : dl_text.


* program ID
  dl_text = 'User Name :'.

  CALL METHOD dg_dyndoc_id->add_gap.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_heading_int.

  CLEAR dl_text.

  dl_text = sy-uname.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.


  CLEAR : dl_text.

* Run Date
  dl_text = 'Run Date :'.



  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_heading_int.

  CLEAR dl_text.
  CALL METHOD dg_dyndoc_id->add_gap exporting WIDTH = 2.
* Move date
  WRITE sy-datum TO dl_text.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.

  CLEAR : dl_text.

*Time
  dl_text = 'Time :'.

  CALL METHOD dg_dyndoc_id->add_gap.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_heading_int.

  CLEAR dl_text.

* Move time
  WRITE sy-uzeit TO dl_text.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.


 PERFORM display.

ENDFORM.                    " EVENT_TOP_OF_PAGE

*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM display.

* Creating html control
  IF o_html_cntrl IS INITIAL.
    CREATE OBJECT o_html_cntrl
         EXPORTING
              parent    = o_parent_top.
  ENDIF.
  CALL METHOD o_dyndoc_id->merge_document.
  o_dyndoc_id->html_control = o_html_cntrl.
* Display document
  CALL METHOD o_dyndoc_id->display_document
    EXPORTING
      reuse_control      = 'X'
      parent             = o_parent_top
    EXCEPTIONS
      html_display_error = 1.
  IF sy-subrc NE 0.
    MESSAGE i999 WITH 'Error in displaying top-of-page'(036).
  ENDIF.
ENDFORM.                    " display

FORM event_top_of_pageupd USING   dg_dyndoc_id TYPE REF TO cl_dd_document.

  DATA : dl_text(255) TYPE c.  "Text
  CALL METHOD dg_dyndoc_id->add_text
    EXPORTING
      text         = 'Flight Details'
      sap_style    = cl_dd_area=>heading
      sap_fontsize = cl_dd_area=>large
      sap_color    = cl_dd_area=>list_heading_int.

  CALL METHOD dg_dyndoc_id->add_gap
    EXPORTING
      width = 200.

* Run Date
  dl_text = 'Run Date :'.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_heading_int.

  CLEAR dl_text.
  CALL METHOD dg_dyndoc_id->add_gap exporting WIDTH = 2.
* Move date
  WRITE sy-datum TO dl_text.

  CALL METHOD o_dyndoc_id->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.
  CLEAR : dl_text.

* Add new-line
  CALL METHOD dg_dyndoc_id->new_line.

 PERFORM display.

ENDFORM.                    " EVENT_TOP_OF_PAGE

Flow logic.

PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.

Check it and let me know .

Former Member
0 Kudos

Hi Vijay garu

Its not Working .

0 Kudos

what is not working..? did you place custom control on the screen and name it 'CONTROL' . and set the status in PBO , Did you add any application toolbar button with function code 'UPDATE'.

are you getting any output..?

0 Kudos

Hi vijay garu

i did what exactly u explained in above but i am not getting refresh . i am not getting any error . its giving the same total for all the buttons.

i did put the update button on application toolbar.

Edited by: reddy on Oct 1, 2008 12:20 PM

Former Member
0 Kudos

Hi vijay Garu

actuvally i am displlaying the ouput on screen200 and in that screen i got 6 buttons . 3rd button got double click event for this one i am using screen 300 .when you double click on cell its displaying the secondary list and coming back to first list i am loosing the total expect double click colum.how does it happen.

Edited by: reddy on Sep 29, 2008 8:43 AM

0 Kudos

Hi,

There probably is an issue with you Fieldcat can you paste the PBO code of screen 200 and 300.

santhosh

Former Member
0 Kudos

PROCESS BEFORE OUTPUT.

MODULE get_absencedata.

MODULE create_object300.

MODULE STATUS_0300.

MODULE get_absencedata.

REFRESH IT_SecAbs.

CLEAR IT_SecAbs.

IF W_PERNR is initial.

Loop at IT_AbsDet.

MOVE-CORRESPONDING IT_AbsDet TO IT_SecAbs.

APPEND IT_SecAbs.

clear IT_SecAbs.

ENDLOOP.

ELSE.

Loop at IT_AbsDet WHERE PERNR = W_PERNR.

MOVE-CORRESPONDING IT_AbsDet TO IT_SecAbs.

APPEND IT_SecAbs.

clear IT_SecAbs.

ENDLOOP.

ENDIF.

endmodule.

MODULE create_object300.

var300-report = sy-repid.

var300_save = 'A'.

  • clear cont100.

IF cont300 is initial.

Perform build_fcat300.

Create object cont300

Exporting

container_name = 'ALV300'.

  • create an instance of alv control

Create object grid300

Exporting i_parent = cont300.

Layo300-zebra = 'X'.

Call method grid300->set_table_for_first_display

EXPORTING

is_layout = layo300

is_variant = var300

i_save = var300_save

CHANGING

it_fieldcatalog = fcat300[]

it_outtab = IT_SecAbs[].

ELSE.

call method grid300->set_frontend_fieldcatalog

EXPORTING

it_fieldcatalog = fcat300[].

call method grid300->refresh_table_display.

call method cl_gui_control=>set_focus

EXPORTING

control = grid300.

call method cl_gui_cfw=>flush.

endif.

endmodule.

MODULE STATUS_0300 OUTPUT.

SET PF-STATUS '0300'.

SET TITLEBAR '300'.

endmodule.

screen 400 is same as above .

alv400

used grid400

cont400

0 Kudos

Hi,

ELSE.

*call method grid300->set_frontend_fieldcatalog

*EXPORTING

*it_fieldcatalog = fcat300[].

call method grid300->refresh_table_display.

call method cl_gui_control=>set_focus

EXPORTING

comment the set_frontend_fieldcatalog method and try

santhosh

Edited by: Kaluvala Santhosh on Sep 29, 2008 12:53 PM

0 Kudos

Hi,

How exactly you have done the field catalog ? Are you getting any error ?

Regards

Narin

Former Member
0 Kudos

I did try

*call method grid100->set_frontend_fieldcatalog

  • EXPORTING

  • it_fieldcatalog = fcat100[].

still its not working.

0 Kudos

Hi,

There is some confusion in your screen numbers you have pasted screen 300 PBO your comment shows screen 100 code you are talking abt screen 200 and 300 some times 400..can please clear about the screen numbers and thier PBO's

santhosh

Former Member
0 Kudos

I am not getting any error . its displaying ouput only when i am doing double-click event than i am not getting total . its reflecting the all buttons.

Former Member
0 Kudos

Hi Santosh garu

screen 100 (Buttons)

screen 200 (to dispay the o/p)

screen 300(to display the o/p button 3rd Doudle click event . 4th colum(each Cells) )

screen 400(to display the o/p button 3rd Double click event 5th colum (each Cells) )

0 Kudos

HI,

What is the PBO of screen 100 you have.

santhosh

Former Member
0 Kudos

screen 200.

Edited by: reddy on Sep 30, 2008 1:39 PM

Former Member
0 Kudos

I found myself

Thanks for helping Experts.