Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to control buttons

Hello Experts,

Iu2019m new in dialog programming and need some help. Iu2019ve created few transactions for Display, Change & Create. On my Change transaction Iu2019m checking for material number (Matnr). I want to check if matnr is initial then Display button get enable and change button get disable. If matnr has some material number already fill in then display button gets disable and change button gets enable. Can please somebody look at my code and suggest me what should I do to accomplish this task. Also please point me out if Iu2019m doing something wrong.

=======================================================================

module set_change_screen output.

if sy-tcode eq 'ZAD_M02'.

loop at screen.

if screen-name eq 'MATNR'.

if MATNR is initial.

screen-input = 1.

elseif screen-name eq 'MARA-MTART' or

screen-name eq 'MARA-MBRSH' or

screen-name eq 'MARA-MEINS' or

screen-name eq 'MARC-WERKS' or

screen-name eq 'MARC-PSTAT' or

screen-name eq 'MARC-EKGRP' or

screen-name eq 'MARD-LGORT' or

screen-name eq 'MAKT-SPRAS' or

screen-name eq 'MAKT-MAKTX' or

screen-name eq 'CHNG'.

screen-input = 0.

else.

screen-input = 0.

endif.

endif.

if screen-name eq 'MATNR'.

if MATNR is not initial.

screen-input = 1.

elseif screen-name eq 'MARA-MTART' or

screen-name eq 'MARA-MBRSH' or

screen-name eq 'MARA-MEINS' or

screen-name eq 'MARC-WERKS' or

screen-name eq 'MARC-PSTAT' or

screen-name eq 'MARC-EKGRP' or

screen-name eq 'MARD-LGORT' or

screen-name eq 'MAKT-SPRAS' or

screen-name eq 'MAKT-MAKTX' or

screen-name eq 'DISP'.

screen-input = 1.

else.

screen-input = 1.

endif.

endif.

MODIFY SCREEN.

endloop.

endif.

endmodule. " set_change_screen OUTPUT

=======================================================================

Thanks.

replied

I don;t know if your code works, but i suggest rewriting a bit to make things easier to understand and maintain:

if sy-tcode eq 'ZAD_M02'.

   loop at screen.

     case screen-name.
       when 'MATNR'.
           if matnr is initial.
 
           else.

           endif.

      when 'MARA-MTART' or 'MARA-MBRSH'  or .....

    endcase.

   endloop.

endif.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question