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: 

How to clear OOO ALV header text in TOP_OF_PAGE

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

   I have a ABAP OO ALV report.

  

   There are 2 ALV tables one below the other.

   The first ALV has checkbox in the row.

    The second ALV has a user defined button "Create SD" in the toolbar.

   When the user selects a checkbox in the first ALV and presses "Create SD" button in the second then I display status text "SD 9678 created successfully" in the top of page header.

  When the user deselects the checkbox then I need to clear the text displayed on the top of page.

  When again the user selects the checkbox I need to display the updated text on the top of page.

  For the first time when checkbox is selected by default the top of page test is getting populated.

But when I deselect the checkbox then the top of page text is not getting cleared?  Also it is not getting updated when I again select the checkbox?

Not sure what is wrong in my code.

  My code is as below:

  FORM event_top_of_page USING p_flg TYPE c.
  

IF p_flg IS INITIAL.
     "Populating header to top-of-page

     CLEAR : dl_text.

     "Move shipment doc status

     CONCATENATE 'Shipment Document :' v_sddoc 'Successfully created' INTO dl_text SEPARATED BY space.

     "Add shipmemnt doc status to Document
     v_type = 'S'.
     PERFORM add_text USING dl_text
                            v_type.

     "Add new-line

     CALL METHOD v_doc_id->new_line.

     CLEAR : dl_text.

     "Move handling unit status

     CONCATENATE 'Pallet ID :' v_palletid  'Successfully created' INTO dl_text SEPARATED BY space.

     "Add handling unit status to Document
     v_type = 'E'.
     PERFORM add_text USING dl_text
                            v_type.

     CLEAR : dl_text.
     PERFORM html.
   ELSE.  <-- Here is the code to clear the top of page text.
     " Initializing document
     CALL METHOD v_doc_id->initialize_document
       EXPORTING
         background_color = cl_dd_document=>col_textarea
         no_margins       = abap_true.

     "Creating html control
     CREATE OBJECT v_html_cntrl
       EXPORTING
         parent = v_parent_html.

     CALL METHOD v_doc_id->display_document
       EXPORTING
         reuse_control      = 'X'
         parent             = v_parent_html
       EXCEPTIONS
         html_display_error = 1.
   ENDIF.

ENDFORM.

FORM add_text USING p_text TYPE sdydo_text_element
                     p_type TYPE c.

   "Adding text

   IF p_type = 'S'.
     CALL METHOD v_doc_id->add_text
       EXPORTING
         text         = p_text
         sap_fontsize = cl_dd_area=>large
         sap_color    = cl_dd_document=>list_heading_int
         sap_emphasis = cl_dd_document=>strong.
   ELSEIF p_type = 'E'.
     CALL METHOD v_doc_id->add_text
       EXPORTING
         text         = p_text
         sap_fontsize = cl_dd_area=>large
         sap_color    = cl_dd_area=>list_negative_inv "red color
         sap_emphasis = cl_dd_document=>strong.
   ENDIF.

ENDFORM.                    " ADD_TEXT


FORM html.

   DATA : v_length  TYPE i,                          " Length
          v_html_cntrl        TYPE REF TO cl_gui_html_viewer.       "Reference to html container

   "Creating html control
   CREATE OBJECT v_html_cntrl
     EXPORTING
       parent = v_parent_html.

   CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
     EXPORTING
       document = v_doc_id
       bottom   = space
     IMPORTING
       length   = v_length.

   "Get TOP->HTML_TABLE ready

   CALL METHOD v_doc_id->merge_document.

   "Connect TOP document to HTML-Control

   v_doc_id->html_control = v_html_cntrl.

   "Display TOP document

   CALL METHOD v_doc_id->display_document
     EXPORTING
       reuse_control      = 'X'
       parent             = v_parent_html
     EXCEPTIONS
       html_display_error = 1.

   IF sy-subrc NE 0.

     "MESSAGE I999.

   ENDIF.

ENDFORM.

Thanks

Gopal

7 REPLIES 7

former_member212002
Active Contributor
0 Kudos

Check the thread below -

http://scn.sap.com/thread/996330

Cheers!

Abhinab

former_member221372
Participant
0 Kudos

Hi,

Try like this...

if  v_doc_id is initial.

CALL METHOD v_doc_id->display_document
     EXPORTING
       reuse_control      = space
       parent             = v_parent_html
     EXCEPTIONS
       html_display_error = 1.

else.

CALL METHOD v_doc_id->display_document
     EXPORTING
       reuse_control      = 'X'
       parent             = v_parent_html
     EXCEPTIONS
       html_display_error = 1.

endif.

Regards

0 Kudos

I have tried all these. But still top of page test is not not getting cleared.

I even used the

"Creating html control
   IF v_html_cntrl IS INITIAL.
     CREATE OBJECT v_html_cntrl
       EXPORTING
         parent = v_parent_html.
   ENDIF.

     "Get TOP->HTML_TABLE ready

     "CALL METHOD v_doc_id->merge_document.

     "Connect TOP document to HTML-Control

     v_doc_id->html_control = v_html_cntrl.

     "Display TOP document

     CALL METHOD v_doc_id->display_document
       EXPORTING
         reuse_control      = p_flg  <--- this parameter is initial when i want to clear the top of page text
         parent             = v_parent_html
       EXCEPTIONS
         html_display_error = 1.

     IF sy-subrc NE 0.

       "MESSAGE I999 WITH 'Error in displaying top-of-page'(036).

     ENDIF.

   " Initializing document
   FREE: v_doc_id, v_html_cntrl, v_parent_html.

Please help.

0 Kudos

First of all you will have to use cocepts of Events. If you have a look at CL_GUI_ALV_GRID you will see various event HANDLE_DATA_CHANGED, TOP_OF_PAGE etc. I believe if you make an OOPs based ALV and register these event you will be able to play with the header.

Former Member
0 Kudos

Hi,

First of all you need to use an event from the class cl_gui_alv_grid.

Now i suppose that you are using an appropriate event from the above class, you need to  use the following code,

1)  up TYPE REF TO cl_gui_container,

2)  SET HANDLER obj->handle_event FOR o_grid1

                                                        "obj is the class object and o_grid1 is the grid object.

3)  CALL METHOD up->free.        

                                                        "Use this to free the top of page.

This is all you need. Just find the correct event.

Hope you get it solved. If you don't find than just message me back. I'll send you the code.

Regards

0 Kudos

HI Amaranatha,

   i tried what you have mentioned. I used

CALL METHOD v_parent_html ->free.    Here v_parent_html is the container for top of page.
Now top of page text is getting cleared . But now if I try to refill the text in top of box on again pressing "Create SD" button it does not display the same. It remains blank.

I am not getting what is wrong.

Please help.

-Gopal

0 Kudos

hi,

For the text to be displayed for the button click try using one of this events in cl_gui_alv_grid :

MENU_BUTTON

TOOLBAR_MENUBUTTON_CLICK

TOOLBAR_BUTTON_CLICK.

If its still not working then try exploring the events in the above class.

Once you declare the event, use set handler to register the event.

So when you click that button the method gets called. In the method use these methods.

CREATE OBJECT dd                                 (of cl_dd_document)

CALL METHOD dd->add_text

CALL METHOD dd->display_document

Hope this helps.

Regards