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: 

delete row at errors in table control (ITAB-mark is not updating with X )

Former Member
0 Kudos

Hi,

i have created table control with 2 mandatory fields, delete functionality is working fine when data populated in those fields, but when data was not there in those fields and when i try to select that particular row and delete it. It was not deleting and error msg is coming as 'make an entry in all required fields'.

basically i wrote code for deleting in at exit-command module and added function type for the delete button as 'E' too. Basically that functionality is triggering perfectly but my internal table - MARK is not updating with 'X' to delete it.

delete itab where mark = 'X'.

itab-mark is not updating with 'X' when i select the row and try to delete it since it has an error as 'make an entry in all required fields'. i need to delete a selected record even it has errors. Could any one suggest me. I made the 2 fields mandatory in screen painter only. Is there any solution for this?

1 ACCEPTED SOLUTION

valter_oliveira
Active Contributor
0 Kudos

Sure, don't use your delete function at EXIT command because this event is triggered in the begining of screen PAI. This module exit is ok for 'BACK', LEAVE' or 'CANCEL' functions. Insert your delete in the last module of PAI (that should be normal USER_COMMAND).

In the middle, make your validations and update itab from table control (your mark = 'X').

Regards,

Valter Oliveira.

8 REPLIES 8

Former Member
0 Kudos

I wonder why you are trying to hit the delete button when the fields are anyways empty.

Anyway, try this:

Before throwing the error message.. check SY-UCOMM of delete button is not clicked.

Thanks,

SKJ

david_carballido
Active Participant
0 Kudos

Hi ... maybe into the table control, the field MARK is different with the field of the internal table, because the field MARK should update with 'X'.

Thanks and Regards

David Carballido

Former Member
0 Kudos

Did you declared that field to have the marking column in the Table Control properties?

valter_oliveira
Active Contributor
0 Kudos

Sure, don't use your delete function at EXIT command because this event is triggered in the begining of screen PAI. This module exit is ok for 'BACK', LEAVE' or 'CANCEL' functions. Insert your delete in the last module of PAI (that should be normal USER_COMMAND).

In the middle, make your validations and update itab from table control (your mark = 'X').

Regards,

Valter Oliveira.

0 Kudos

Thanks for your responses. Please see the below code...

PROCESS AFTER INPUT.
  module EXIT at exit-command.

  loop at itab.

    chain.
        field: itab-field1, itab-field2, itab-mark.
        module modify_itab.
        module delete_line at exit-command.
    endchain.
  endloop.

  MODULE USER_COMMAND.

PAI Modules - Code

   MODULE exit INPUT.
     case sy-ucomm.
           when 'BACK'.
                   perform back. 
           when 'EXIT'.
                  leave program.
        endcase.
ENDMODULE. 

 module modify_itab input.
   modify itab index tc1-current_line.
endmodule. 


module delete_line input.
if sy-ucomm = 'DEL'.
     delete itab where mark = 'X'.
       if sy-subrc <> 0.
         message w208(00) with 'Please select the line to Delete'.
       endif.
endif.
endmodule. 

the problem is .... i have a table control with 2 push buttons - one for Insert a new line and other push button is for Delete the selected line. In case user wants to enter the row first he needs to select Insert button, so new line will be allowed user to enter the data, in the table control there are 2 mandatory fields, once he clicks Insert button and wants to delete the record without entering the 2 mandatory fields then system will throw the standard error msg, now it was not allowing to delete that row till he enter the data in the mandatory fields of that particular row since the internal table was not updating X in MARK field for that selected row. I have given the same in the table control properties too.

Thanks for your great support.

0 Kudos

Remove this:

added function type for the delete button as 'E'

And then:


PROCESS AFTER INPUT.

  module EXIT at exit-command.
 
  loop at itab.
    chain.
        field: itab-field1, itab-field2, itab-mark module modify_itab ON CHAIN-REQUEST.
    endchain.
  endloop.
 
  MODULE USER_COMMAND.
*   create a perform delete_lines in module USER_COMMAND.

Regards,

Valter Oliveira.

0 Kudos

Sorry, its not working because system message is triggering before its updating the MARK as 'X'. Can you please let me know is there a solution for this or not. If not i will change my design. Thanks for your efforts.

0 Kudos

Ok, continuing what I wrote (sorry, I missed the part that you put fields required) ... the fields should not be required in the screen painter. Then make the validation that the fields have values in module modify_itab giving error message. This surely works!

Regards,

Valter Oliveira.