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

sushant_singh
Participant
0 Kudos

hi all,

in my program i need to make fields in ALV GRID control ,mandatory.

how can i do this. please send me the code also.

thanks.

1 REPLY 1

Former Member
0 Kudos

use this code or change ur code as per this code -

&----


*& Report ZUS_SDN_ALV_ERROR_LOG

*&

&----


*&

*&

&----


REPORT zus_sdn_alv_error_log.

DATA:

er_data_changed TYPE REF TO cl_alv_changed_data_protocol.

START-OF-SELECTION.

  • Dynpro is empty (contains no elements)

CALL SCREEN '0100'.

END-OF-SELECTION.

&----


*& Module PBO_0100 OUTPUT

&----


  • text

----


MODULE pbo_0100 OUTPUT.

  • Event DATA_CHANGED was fired due to changes in the editable ALV grid

IF ( er_data_changed IS BOUND ).

  • User did not change any values

ELSE.

CREATE OBJECT er_data_changed

  • EXPORTING

  • I_CONTAINER =

  • I_CALLING_ALV = <your ALV grid instance>

.

ENDIF.

  • That is how your code probably looks like

  • LOOP AT gt_outtab INTO gs_outtab.

  • IF ( gs_outtab-obligatory IS INITIAL ).

  • CALL METHOD go_alvlog->add_protocol_entry

  • EXPORTING

  • i_msgid = '00'

  • i_msgty = 'E'

  • i_msgno = '398'

  • I_MSGV1 = 'Field OBLIGATORY must not be empty'

    • I_MSGV2 =

    • I_MSGV3 =

    • I_MSGV4 =

  • i_fieldname = 'OBLIGATORY'

    • I_ROW_ID =

  • I_TABIX = syst-tabix

  • .

*

  • ENDIF.

*

  • ENDLOOP.

  • Generate a protocol for testing purposes

DO 5 TIMES.

CALL METHOD er_data_changed->add_protocol_entry

EXPORTING

i_msgid = '00'

i_msgty = 'E'

i_msgno = '398'

i_msgv1 = 'Field OBLIGATORY must not be empty'

  • I_MSGV2 =

  • I_MSGV3 =

  • I_MSGV4 =

i_fieldname = 'OBLIGATORY'

i_row_id = syst-index

i_tabix = syst-index

.

ENDDO.

CALL METHOD er_data_changed->display_protocol

  • EXPORTING

  • I_CONTAINER =

.

ENDMODULE. " PBO_0100 OUTPUT

Please note that this report dumps as soon as you close the log popup. However, this will not happen within your event handler method..

reward points if helpfull