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: 

unable to display classical report when save button is pressed in oops alv

Former Member
0 Kudos

Hi All,

       I have developed the report using oops alv, in the output screen added save button  and check button as well, when user select check box for  particular row and then press save button classical report should be shown, that is write statement report, but can;t able to show , break point is going by write statement but report is not getting displayed,'

  please see the below code.

WHEN  'SAVE'.

        

CALL METHOD go_grid->check_changed_data

     IMPORTING

       e_valid = lv_valid.

   IF lv_valid EQ 'X'.

*** Get the filtered out values from ALV (line indexes)

     CALL METHOD go_grid->get_filtered_entries

       IMPORTING

         et_filtered_entries = lt_filtered_entries.

   

   LOOP AT  it_detail856 INTO wa_detail856 .

     WRITE wa_detail856-lifnr     TO wa_output_detail-vendor_number.

     WRITE wa_detail856-stceg    TO wa_output_detail-vendor_tax_number.

     WRITE wa_detail856-name1     TO wa_output_detail-vendor_name .

     WRITE wa_detail856-street    TO wa_output_detail-vendor_street.

     WRITE wa_detail856-city1     TO wa_output_detail-vendor_city  .

     WRITE wa_detail856-augdt     TO wa_output_detail-augdt       .

     WRITE wa_detail856-dmbtr     TO wa_output_detail-gross_payment

       CURRENCY wa_loccur.

     WRITE wa_detail856-wt_qsshh  TO wa_output_detail-wht_base

       CURRENCY wa_loccur.

     WRITE wa_detail856-wt_qbshh  TO wa_output_detail-wht

       CURRENCY wa_loccur.

     WRITE wa_detail856-netamt    TO wa_output_detail-netamt

       CURRENCY wa_loccur.

     WRITE wa_detail856-augbl     TO wa_output_detail-augbl.

     WRITE wa_detail856-whtrt     TO wa_output_detail-wht_rate      .

     WRITE wa_detail856-vatpd     TO wa_output_detail-total_vat     .

     WRITE wa_detail856-belnr     TO wa_output_detail-belnr.

     WRITE wa_detail856-land1     TO wa_output_detail-land1.

     APPEND wa_output_detail TO it_output_detail.

   ENDLOOP.

   IF repchk1  = 'X'.

     LOOP AT  it_output_detail INTO wa_output_detail.

       lw_index = sy-tabix.

       IF lw_index <= 6.

         WRITE:/   wa_output_detail-vendor_number    ,

                   wa_output_detail-vendor_tax_number,

                   wa_output_detail-vendor_name      ,

                   wa_output_detail-vendor_street    .

       ENDIF.

       IF lw_index > 6.

         WRITE:/2   wa_output_detail-vendor_number    ,

                18  wa_output_detail-vendor_tax_number,

                59  wa_output_detail-vendor_name      ,

                82  wa_output_detail-vendor_street    ,

               104  wa_output_detail-vendor_city      ,

               118  wa_output_detail-augdt            ,

               129  wa_output_detail-gross_payment    ,

               146  wa_output_detail-wht_base         ,

               163  wa_output_detail-wht              ,

               180  wa_output_detail-netamt           ,

               197  wa_output_detail-augbl            ,

               208  wa_output_detail-wht_rate         ,

               213  wa_output_detail-total_vat     ,

               222  wa_output_detail-belnr,

               233  wa_output_detail-land1.

*------ WRITE VERTICAL LINES

         PERFORM write_vertical_line.

         ULINE.

       ENDIF.

     ENDLOOP.

i have commented the code

*    LOOP AT gt_detail856 INTO gs_detail856 WHERE checkbox = 'X'.

*      lv_tabix = sy-tabix.

*      READ TABLE lt_filtered_entries FROM lv_tabix TRANSPORTING NO FIELDS.

*      IF sy-subrc IS INITIAL.

       

*        write: 'hello'.

*      ENDIF.

*    ENDLOOP.

*  ENDIF.


please help me this....can we dsiplay classcal report when i press save button in interactive oops alv..?

Thanks in advance..

regards,

Ram

9 REPLIES 9

former_member184569
Active Contributor
0 Kudos

at the end, add this statement.

leave to list-processing.

WHEN  'SAVE'.

         .........

      write 😕 .......

       ENDIF.

     ENDLOOP.

leave to list-processing.

0 Kudos

Hi Susmitha,

    Thanks for your replay, i have tried as you said, but it's going to call 900  statement ,i want to execute write statement above leave screen 0. i am getting different write statement error. is there any way where we can display write statements in oops alv..?

Ramu

0 Kudos

Hi susmitha,

   your correct , output is coming but not when i press save but when i press Back button, could you please tel me where i might done the mistake..? any idea

Thanks,

Regards,

ramu

0 Kudos

Hi

Can you try as below before the loop where you write data

      

SET SCREEN 0.     
LEAVE TO LIST-PROCESSING.       
SET PF-STATUS 'STANDARD1'.       
NEW-PAGE NO-TITLE NO-HEADING.       
WRITE: 'TEST'.

0 Kudos

You have given leave to list-processing under save function code, after all the write statements right?

In the PAI module,

when 'SAVE'.
       write : / 'Testing the classical report'.
      leave to LIST-PROCESSING.

That's working fine for me.

Can you share your entire PAI code?

0 Kudos

Hi Susmitha,

   please find the below code...


CLASS lcl_event_receiver DEFINITION DEFERRED.  "for event handling

DATA:event_receiver     TYPE REF TO lcl_event_receiver,

      g_event_receiver   TYPE REF TO lcl_event_receiver.

*----------------------------------------------------------------------*

*       CLASS lcl_event_receiver DEFINITION

*----------------------------------------------------------------------*

CLASS lcl_event_receiver DEFINITION.

   PUBLIC SECTION.

* This local class handles event HANDLE_TOOLBAR.

* This defines the buttons in the toolbar

     METHODS:handle_toolbar  FOR EVENT toolbar OF cl_gui_alv_grid

                             IMPORTING e_object e_interactive,

* This local class handles event HANDLE_TOP-OF-PAGE.

* This defines header of the ALV report.

             handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid

                                IMPORTING e_dyndoc_id,

* This local class handles event USER_COMMAND.

* When the user clicks on a custom button in the toolbar

             handle_user_command  FOR EVENT user_command OF cl_gui_alv_grid

                                  IMPORTING  e_ucomm.

ENDCLASS.                    "lcl_event_receiver DEFINITION

*----------------------------------------------------------------------*

*       CLASS lcl_event_receiver IMPLEMENTATION

*----------------------------------------------------------------------*

CLASS lcl_event_receiver IMPLEMENTATION.

* In event handler method for event TOOLBAR: Append own functions

* by using event parameter E_OBJECT.

   METHOD handle_toolbar.

* Append a separator to normal toolbar

     CLEAR gs_toolbar.

     MOVE 3 TO gs_toolbar-butn_type.

     APPEND gs_toolbar TO e_object->mt_toolbar.

* Append an icon for SAVE [Push-button]

     CLEAR gs_toolbar.

     MOVE 0 TO gs_toolbar-butn_type.

     MOVE 'SAVE' TO gs_toolbar-function.

     MOVE icon_system_save TO gs_toolbar-icon.

     MOVE 'SAVE' TO gs_toolbar-quickinfo.

     MOVE ' Save' TO gs_toolbar-text.

     MOVE ' ' TO gs_toolbar-disabled.

     APPEND gs_toolbar TO e_object->mt_toolbar.

   ENDMETHOD.                    "handle_toolbar

   METHOD handle_top_of_page.

     PERFORM event_top_of_page USING go_dyndoc_id.

   ENDMETHOD.                    "handle_top_of_page

   METHOD handle_user_command.

     CASE e_ucomm.

** SAVE User command

       WHEN 'SAVE'.

         PERFORM get_save_changed_data.

*          PERFORM save_data.

         CALL METHOD go_grid->refresh_table_display.

     ENDCASE.

   ENDMETHOD.                           "handle_user_command

ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

FORM get_save_changed_data.

   DATA:lv_valid            TYPE c,

        lv_tabix            LIKE sy-tabix,

        lt_filtered_entries TYPE lvc_t_fidx.

* If all entries are ok, ALV transferes new values to the output

* table which you then can modify.

   CALL METHOD go_grid->check_changed_data

     IMPORTING

       e_valid = lv_valid.

   IF lv_valid EQ 'X'.

*** Get the filtered out values from ALV (line indexes)

     CALL METHOD go_grid->get_filtered_entries

       IMPORTING

         et_filtered_entries = lt_filtered_entries.

PERFORM frm_detailed856_output.

ENDIF.

   leave to list-processing.                     " leave list processing.

ENDFORM.               

DATA: lw_index TYPE sy-index.

   SORT it_detail856 BY lifnr augbl.

*----- BUILD UP THE HEAD FOR DETAIL856

   PERFORM frm_buildup_head.

   CLEAR: wa_output_detail.

   APPEND wa_output_detail TO it_output_detail.

   PERFORM frm_build_title_detail.

***added by ramu

   LOOP AT  gt_detail856 INTO gs_detail856 WHERE checkbox = 'X'.

     MOVE-CORRESPONDING gs_detail856 TO wa_detail856.

     APPEND wa_detail856 TO it_detail856.

     CLEAR gs_detail856.

   ENDLOOP.

*******************

   LOOP AT  it_detail856 INTO wa_detail856 .

     WRITE wa_detail856-lifnr     TO wa_output_detail-vendor_number.

     WRITE wa_detail856-stceg    TO wa_output_detail-vendor_tax_number.

     WRITE wa_detail856-name1     TO wa_output_detail-vendor_name .

     WRITE wa_detail856-street    TO wa_output_detail-vendor_street.

     WRITE wa_detail856-city1     TO wa_output_detail-vendor_city  .

     WRITE wa_detail856-augdt     TO wa_output_detail-augdt       .

     WRITE wa_detail856-dmbtr     TO wa_output_detail-gross_payment

       CURRENCY wa_loccur.

     WRITE wa_detail856-wt_qsshh  TO wa_output_detail-wht_base

       CURRENCY wa_loccur.

     WRITE wa_detail856-wt_qbshh  TO wa_output_detail-wht

       CURRENCY wa_loccur.

     WRITE wa_detail856-netamt    TO wa_output_detail-netamt

       CURRENCY wa_loccur.

     WRITE wa_detail856-augbl     TO wa_output_detail-augbl.

     WRITE wa_detail856-whtrt     TO wa_output_detail-wht_rate      .

     WRITE wa_detail856-vatpd     TO wa_output_detail-total_vat     .

     WRITE wa_detail856-belnr     TO wa_output_detail-belnr.

     WRITE wa_detail856-land1     TO wa_output_detail-land1.

     APPEND wa_output_detail TO it_output_detail.

   ENDLOOP.

   IF repchk1  = 'X'.

     LOOP AT  it_output_detail INTO wa_output_detail.

       lw_index = sy-tabix.

       IF lw_index <= 6.

         WRITE:/   wa_output_detail-vendor_number    ,

                   wa_output_detail-vendor_tax_number,

                   wa_output_detail-vendor_name      ,

                   wa_output_detail-vendor_street    .

       ENDIF.

       IF lw_index > 6.

         WRITE:/2   wa_output_detail-vendor_number    ,

                18  wa_output_detail-vendor_tax_number,

                59  wa_output_detail-vendor_name      ,

                82  wa_output_detail-vendor_street    ,

               104  wa_output_detail-vendor_city      ,

               118  wa_output_detail-augdt            ,

               129  wa_output_detail-gross_payment    ,

               146  wa_output_detail-wht_base         ,

               163  wa_output_detail-wht              ,

               180  wa_output_detail-netamt           ,

               197  wa_output_detail-augbl            ,

               208  wa_output_detail-wht_rate         ,

               213  wa_output_detail-total_vat     ,

               222  wa_output_detail-belnr,

               233  wa_output_detail-land1.

*------ WRITE VERTICAL LINES

         PERFORM write_vertical_line.

         ULINE.

       ENDIF.

     ENDLOOP.

   ENDIF.

endform

*****PAI CODE****

CASE sy-ucomm.

     WHEN 'BACK'.

  *     SET SCREEN 0.         " commented also not coming

       LEAVE TO SCREEN 0.

     WHEN 'CANCEL'.

       LEAVE PROGRAM.

     WHEN 'EXIT'.

       LEAVE PROGRAM.

   ENDCASE.

******

0 Kudos

Hi susmita,

  Please find the below also.

FORM frm_detailed856_alv.

   LOOP AT  it_detail856 INTO wa_detail856.

     MOVE-CORRESPONDING wa_detail856 TO gs_detail856.

     APPEND gs_detail856 TO gt_detail856.

     CLEAR gs_detail856.

   ENDLOOP.

   CALL SCREEN 900.

ENDFORM.    

MODULE status_0900 OUTPUT.

   SET PF-STATUS 'KEYS'.

   SET TITLEBAR 'TITLE'.

* For Fieldcatalog building.

   PERFORM build_fcat.

* For container creation

   CREATE OBJECT go_cust

     EXPORTING

       container_name              = 'DETAILED'

     EXCEPTIONS

       cntl_error                  = 1

       cntl_system_error           = 2

       create_error                = 3

       lifetime_error              = 4

       lifetime_dynpro_dynpro_link = 5

       OTHERS                      = 6.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

* Create TOP-Document

   CREATE OBJECT go_dyndoc_id

     EXPORTING

       style = 'ALV_GRID'.

* Create Splitter for custom_container

   CREATE OBJECT go_split

     EXPORTING

       parent  = go_cust

       rows    = 2

       columns = 1.

* Split the custom_container to two containers and move the reference

* to receiving containers g_parent_html and g_parent_grid

* I am allocating the space for grid and top of page

   CALL METHOD go_split->get_container

     EXPORTING

       row       = 1

       column    = 1

     RECEIVING

       container = go_parent_html.

   CALL METHOD go_split->get_container

     EXPORTING

       row       = 2

       column    = 1

     RECEIVING

       container = go_parent_grid.

* Set height for g_parent_html

   CALL METHOD go_split->set_row_height

     EXPORTING

       id     = 1

       height = 25.

* Creating object for Grid.

   CREATE OBJECT go_grid

     EXPORTING

       i_parent = go_parent_grid.

   CREATE OBJECT g_event_receiver.

   SET HANDLER g_event_receiver->handle_top_of_page FOR go_grid.

* setting focus for created grid control

   CALL METHOD cl_gui_control=>set_focus

     EXPORTING

       control = go_grid.

   CALL METHOD go_grid->set_table_for_first_display

     EXPORTING

*      is_print                      = gs_print

*      is_layout                     = gs_layout

       it_toolbar_excluding          = gt_exclude

     CHANGING

       it_outtab                     = gt_detail856

       it_fieldcatalog               = gt_fieldcat

     EXCEPTIONS

       invalid_parameter_combination = 1

       program_error                 = 2

       too_many_lines                = 3

       OTHERS                        = 4.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

* Initializing document

   CALL METHOD go_dyndoc_id->initialize_document.

* Processing events

   CALL METHOD go_grid->list_processing_events

     EXPORTING

       i_event_name = 'TOP_OF_PAGE'

       i_dyndoc_id  = go_dyndoc_id.

** Set editable cells to ready for input initially

*  CALL METHOD go_grid->set_ready_for_input

*    EXPORTING

*      i_ready_for_input = 1.

   SET HANDLER g_event_receiver->handle_user_command FOR go_grid.

   SET HANDLER g_event_receiver->handle_toolbar FOR go_grid.

* Call method 'set_toolbar_interactive' to raise event TOOLBAR.

   CALL METHOD go_grid->set_toolbar_interactive.

ENDMODULE.                 " STATUS_0900  OUTPUT

MODULE user_command_0900 INPUT.

   CASE sy-ucomm.

     WHEN 'BACK'.

       SET SCREEN 0.

       LEAVE TO SCREEN 0.

     WHEN 'CANCEL'.

       LEAVE PROGRAM.

     WHEN 'EXIT'.

       LEAVE PROGRAM.

   ENDCASE.

ENDMODULE.  

0 Kudos

Hi Ramu,

I have two solutions. Both will solve your issue.

Suggestion 1.

In the handle user command module, comment out the call to  refresh_table_display method. Add leave to screen 0 also.

METHOD handle_user_command.

     CASE e_ucomm.

** SAVE User command

       WHEN 'SAVE'.

         PERFORM get_save_changed_data.

         leave to list-processing.  

        leave to screen 0.

(You can comment out the other leave to list processing if you are writing it here)

*          PERFORM save_data.

         CALL METHOD go_grid->refresh_table_display.

     ENDCASE.

   ENDMETHOD.                           "handle_user_command




Suggestion 2  -


Comment out that entire section in handle user command method and add it in the PAI.


METHOD handle_user_command.

     CASE e_ucomm.

** SAVE User command

       WHEN 'SAVE'.

         PERFORM get_save_changed_data.

        leave to list-processing.   

(You can comment out the other leave to list processing if you are writing it here)

*          PERFORM save_data.

         CALL METHOD go_grid->refresh_table_display.

     ENDCASE.

   ENDMETHOD.

*****PAI CODE****

CASE sy-ucomm.

     WHEN 'BACK'.

  *     SET SCREEN 0.         " commented also not coming

       LEAVE TO SCREEN 0.

     WHEN 'CANCEL'.

       LEAVE PROGRAM.

     WHEN 'EXIT'.

       LEAVE PROGRAM.

     WHEN 'SAVE'.

         PERFORM get_save_changed_data.

         leave to list-processing.  

   ENDCASE.

0 Kudos

Hi Ramu,

Did you get the desired results?