cancel
Showing results for 
Search instead for 
Did you mean: 

Message logs duplicating during round trip

former_member193460
Contributor
0 Kudos

Hi Experts,

     i have done a message print at the top of the application and the set up of the area is as below.

Window INIT method:

METHOD wddoinit .
  DATA: l_api_mycomp TYPE REF TO if_wd_window_controller.
  DATA: l_wd_message_area TYPE REF TO if_wd_message_area.
  l_api_mycomp ?= wd_this->wd_get_api( ).
  l_wd_message_area = l_api_mycomp->get_message_area( ).
  l_wd_message_area->set_display_attributes( i_for_all_instances = 'X'
   i_use_toggle_area  = 'X'
   i_show_only_current = 'X'
    ).
ENDMETHOD.


Print method is inside view controller which is called where ever the message needs to be printed.

  DATA: lo_controller TYPE REF TO if_wd_controller.

lo_controller ?= wd_this->wd_get_api( ).

CALL METHOD wd_this->lo_message_manager->report_t100_message
        EXPORTING
          msgid                    = <lfs_messages>-id
          msgno                    = <lfs_messages>-number
          msgty                    = <lfs_messages>-type
          p1                       = <lfs_messages>-message_v1
          p2                       = <lfs_messages>-message_v2
          p3                       = <lfs_messages>-message_v3
          p4                       = <lfs_messages>-message_v4
          is_permanent             = abap_true
          VIEW                     = 'V_DASHBOARD'                        " View Name
          controller_permanent_msg = lo_controller
        RECEIVING
          message_id               = lv_msg.


The problem i am facing:

The message log is duplicated evertime there is a round trip on the page.(no code inside wddomodify method)
please help me with tips

Thanks & Regards,

tashi

Accepted Solutions (0)

Answers (1)

Answers (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Tashi,

Are you getting message duplicated again on subsequent action PRINT button, you have set the messages as parmanent, hence old message remains as it is.


Replace :       is_permanent                  = abap_true

with         :       is_parmanent                = abap_false

Hope this helps you.

Regards,

Rama

former_member193460
Contributor
0 Kudos

Hi Rama,

     if i do that , then for every round trip i loose the current message and its available only in log.

i want to retain the message till i do another print method , thats why i have made is_permanent = abap_true.

when a user does any round trip operation like changing view layout .. the current message section is emptied. i want to retain the current message and at the same time dont want any duplicates to be copied to the log.

Thanks & Regards,

Tashi

ramakrishnappa
Active Contributor
0 Kudos

Hi Tashi,

I got your point

I suggest you to clear messages in PRINT method before reporting any messages. So that it clears all existing messages.

  1.   "======================================= 
  2.   "Clear messages from message manager 
  3.   "======================================= 
  4.   wd_this->lo_message_manager->clear_messages( 
  5.     EXPORTING 
  6.       including_permanent_msg = abap_true 
  7.   ). 

Hope this helps you.

Regards,

Rama

former_member193460
Contributor
0 Kudos

Hi Rama,

     Clear_message clears only the current messages but not from the log. the messages are getting duplicated on the log.

when i keep the message as permanent, any round trip copies the current message to the log even though the same message is already present in the log.

Thanks ,

Tashi

ramakrishnappa
Active Contributor
0 Kudos

Hi Tashi,

To delete messages from message log, use the method reset_messages( ) as below

wd_this->lo_message_manager->reset_messages( i_keep_current = 'X' ).

the above statement clears the messages from only log and keep the current messages untouched.

Hope this helps you.

Regards,

Rama

former_member193460
Contributor
0 Kudos

Hi Rama,

     i already tried that, but it clears the log altogether ..i want to delete only the duplicates but the log should remain.

Regards,

tashi

ramakrishnappa
Active Contributor
0 Kudos

Hi Tashi,

You cannot delete only the duplicate messages from log as each time the message is generated with a unique id.

I suggest you to reset the log when user presses the PRINT button. so that old messages gets cleared and new log gets generated.

Regards,

Rama

former_member193460
Contributor
0 Kudos

Hi Rama,

     Really appreciate your help, i have communicated this to my client. The would want the message to be permanent and can bear with the duplication of log entries on round trip .

Thanks & Regards,

Tashi

ramakrishnappa
Active Contributor
0 Kudos

Hi Tashi,

If you still looking for avoiding the reporting of duplicate messages, I would suggest you the below workaround solution... use the method WDDOMODIFYVIEW( ) method

May not be very cleaner in approach.

  • Get the messages from message area using method GET_MESSAGES( )
  • Now, sort the internal table based on message text " err_message "
  • Loop over messages internal table and remove the duplicate message comparing message text using method REMOVE_MESSAGE( )

Sample:

    


if lv_action_name = 'PRINT_MESSAGES'.

          data lt_messages type if_wd_message_manager=>ty_t_messages.

          data ls_messages like line of lt_messages.

          data ls_messages2 like ls_messages.

          data lv_msg type string.

          lt_messages = wd_this->lo_message_manager->get_messages( ).

         

          sort lt_messages by err_message.

         

          clear: ls_messages2, lv_msg.

          loop at lt_messages into ls_messages.

               ls_messages2 = ls_messages.

    

               if     lv_msg = ls_messages2-err_message.

                    wd_this->lo_message_manager->remove_message( msg_id = ls_messages2-msg_id ).

               endif.

               at new err_message.

                    lv_msg = ls_messages2-err_message.

               endat.

          endloop.

Hope this work around approach helps you.

Regards,

Rama