Application Development and Automation 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: 
Read only

Enabling a button using checkbox in module pool

manish_malakar0316
Active Participant
0 Likes
5,923

MODULE USER_COMMAND_9000 INPUT.

CASE SY-UCOMM.

WHEN 'SUBMIT'.

SELECT WERKS
FROM   MARD
INTO   TABLE IT_MARD
WHERE  MATNR GE L_MATNR
AND    MATNR LE H_MATNR.

IDX = 1.

LINE = 0.

          LOOP AT it_mard INTO wa_x .

            line = line + 1.

          ENDLOOP.

  CALL SCREEN 9001.

  WHEN 'CLEAR'.
    CLEAR: L_MATNR, H_MATNR.

when 'BACK'.
  LEAVE TO SCREEN 0.

    ENDCASE.

ENDMODULE.

For screen 9001.

MODULE FILLDATA OUTPUT.

if idx > 0.

  READ TABLE it_MARD INTO wa_MARD INDEX idx.

  idx = idx + 1.

  endif.

ENDMODULE.

MODULE RESET_IDX OUTPUT.

idx = idx - 5.

ENDMODULE.              

MODULE USER_COMMAND_9001 INPUT.

DATA: i_tmp_line like line.

loop at screen.     <------ This is where I need to know how to enable/disable the buttons. Rest of the code is working fine.
             

    IF SCREEN-GROUP1 eq 'CHK'.

       SCREEN-NAME = 'FAIL'.

       screen-ACTIVE = '1'.

       modify screen.

       ENDIF.

   endloop.


CASE Sy-ucomm.

      WHEN 'PGDN'.

      i_tmp_line = line - 5.

      if idx > i_tmp_line.

        else.

          idx = idx + 5.

      ENDIF.

      WHEN 'PGUP'.

      IF IDX <= 6.

        IDX = 1.

        else.

          idx = idx - 5.

      ENDIF.

      when 'BACK'.

      LEAVE TO SCREEN 0.

        ENDCASE.

ENDMODULE       

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

Please help me with the code as to how to achieve the enable/disable functionality of the buttons based on my requirement.

Regards.

Manish.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,875

Whatever modification you execute on internal table SCREEN in PAI is reset to dynpro definition at start of next PBO. You must store the information in PAI and execute the LOOP AT SCREEN in the PBO.

Regards,

Raymond

13 REPLIES 13
Read only

former_member226419
Contributor
0 Likes
3,875

Can you please tell your problem in detail what you want to achieve and what problem you are facing ,with screenshots?

Read only

0 Likes
3,875

It seems that my entire thread did not get posted properly due to some reason. I apologise.

In my first screen 9000, I am entering the material number:

In my second screen 9001, I get the following output in a step loop,.

Now there are 2 buttons: "Pass" and "Fail" which are invisible in the PBO of the screen. Below is the screen layout.

My requirement is that, when one or more than one field is checkboxed, the "Fail" button will be enabled, the "Pass" button remains disabled. If all the fields are checkboxed, then the "Pass" button is enabled and the "fail" button is disabled.

Regards.

Manish.

Read only

0 Likes
3,875

Hi,

Kindly find the below code.

tables: mara.

select-OPTIONS: s_matnr for mara-matnr.

types: begin of t_tab,

        mark(1) type c,

        flag(1) type c,

        matnr type matnr,

        end of t_tab.

data: i_mara type TABLE OF t_tab,

       w_mara type t_tab,

       w_mara1 type t_tab.

data: lv_flag type flag.

select matnr from mara

              into CORRESPONDING FIELDS OF  TABLE i_mara

              where  matnr in s_matnr.

loop at i_mara into w_mara.

   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

     EXPORTING

       INPUT  = w_mara-matnr

     IMPORTING

       OUTPUT = w_mara1-matnr.

   MODIFY i_mara from w_mara1 INDEX sy-tabix.

endloop.

call SCREEN 100.

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_ZTEST' ITSELF

CONTROLS: TC_ZTEST TYPE TABLEVIEW USING SCREEN 0100.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_ZTEST'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR

MODULE TC_ZTEST_CHANGE_TC_ATTR OUTPUT.

   DESCRIBE TABLE I_MARA LINES TC_ZTEST-lines.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TC_ZTEST'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MODIFY TABLE

MODULE TC_ZTEST_MODIFY INPUT.

   if sy-ucomm = 'CHK'.

*    lv_tabix = TC_ZTEST-CURRENT_LINE.

     clear: w_mara.

     READ TABLE i_mara into w_mara index TC_ZTEST-CURRENT_LINE.

     if  w_mara-flag = ' '.

       w_mara-flag = 'X'.

     else.

       w_mara-flag = ' '.

     endif.

     MODIFY I_MARA

        FROM W_MARA

        INDEX TC_ZTEST-CURRENT_LINE.

*    endloop.

   endif.

   data: n type i.

   if sy-ucomm = 'CHK'.

     DESCRIBE TABLE i_mara LINES N.

     loop at i_mara into w_mara.

       if w_mara-flag = 'X' and sy-tabix <> n.

         continue.

       elseif sy-tabix = n.

         CLEAR: lv_flag.

       else.

         lv_flag = 1.

         exit.

       endif.

     endloop.

   endif.

ENDMODULE.

*&SPWIZARD: INPUT MODUL FOR TC 'TC_ZTEST'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MARK TABLE

MODULE TC_ZTEST_MARK INPUT.

   DATA: g_TC_ZTEST_wa2 like line of I_MARA.

   if TC_ZTEST-line_sel_mode = 1

   and W_MARA-MARK = 'X'.

     loop at I_MARA into g_TC_ZTEST_wa2

       where MARK = 'X'.

       g_TC_ZTEST_wa2-MARK = ''.

       modify I_MARA

         from g_TC_ZTEST_wa2

         transporting MARK.

     endloop.

   endif.

   MODIFY I_MARA

     FROM W_MARA

     INDEX TC_ZTEST-CURRENT_LINE

     TRANSPORTING MARK.

ENDMODULE.

*&---------------------------------------------------------------------*

*&      Module  STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*

*       text

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

MODULE STATUS_0100 OUTPUT.

   SET PF-STATUS 'ABC'.

   SET TITLEBAR 'ABC'.

   case sy-ucomm.

     when 'CHK'.

*      loop at screen.

*        if screen-name = 'PASS'.

*          endif.

*        endloop.

       if lv_flag <> 1 .

         loop at screen.

*      screen-name = 'FAIL'.

           if screen-name = 'FAIL'.

             screen-active = 0.

             MODIFY SCREEN.

           endif.

         endloop.

       else.

         loop at SCREEN.

*      screen-name = 'PASS'.

           if screen-name = 'PASS'.

             screen-active = 0.

             MODIFY SCREEN.

           endif.

         endloop.

       endif.

   ENDCASE.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*

*&      Module  USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*

*       text

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

MODULE USER_COMMAND_0100 INPUT.

   case sy-ucomm.

     when 'BACK'.

       leave to SCREEN 0.

     when 'UP'.

       exit..

   endcase.

BR

Sumeet

ENDMODULE.                 " USER_COMMAND_0100  INPUT

Read only

Former Member
0 Likes
3,875

Hi Manish,

Please refer to the link below

https://scn.sap.com/thread/990459

Best Regards

Akshay

Read only

0 Likes
3,875

Hi,

The thread you have referred is not of any relevance to my issue.

Regards.

Manish.

Read only

AnjaneyaBhardwaj
Contributor
0 Likes
3,875

Hi Manish,

you need to heck screen field name as well.

if SCREEN-NAME = 'FAIL'.

Read only

0 Likes
3,875

I did that in my MODULE USER_COMMAND_9001 INPUT.

loop at screen.

    IF SCREEN-GROUP1 eq 'CHK'.

       SCREEN-NAME = 'FAIL'.

       screen-ACTIVE = '1'.

       modify screen.

       ENDIF.


   endloop.

In my first screen 9000, I am entering the material number:

In my second screen 9001, I get the following output in a step loop,.

Now there are 2 buttons: "Pass" and "Fail" which are invisible in the PBO of the screen. Below is the screen layout.

My requirement is that, when one or more than one field is checkboxed, the "Fail" button will be enabled, the "Pass" button remains disabled. If all the fields are checkboxed, then the "Pass" button is enabled and the "fail" button is disabled.

Regards.

Manish

Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
3,875

Hi Manish,

Check like

    IF SCREEN-GROUP1 eq 'CHK' and SCREEN-NAME = 'FAIL'..

      

      screen-ACTIVE = '1'.

       modify screen.

       ENDIF.

   endloop.


Arivazhagan S

Read only

0 Likes
3,875

Hi,

I tried your approach, however when I checkbox a few fields and scroll down for the next 5 records, the checkboxes disappear. Which means the records do not remain selected after the scroll option.   Also, the "Fail" button doesnt not get enabled as per your logic.

Read only

Former Member
0 Likes
3,875

HI Manish,

U can do below way.

Check your RadioBUtton First.

if Your radiobutton eq = 'X'.

Loop at screen.

    SCREEN-NAME = Button Field Name.

       screen-ACTIVE = '1'. " Acrtivate Button 0 = Disabled Button


       modify screen.

       ENDIF.

   endloop.

endif.

Thanks

Tarak

Read only

0 Likes
3,875

I tried your approach, however when I checkbox a few fields and scroll down for the next 5 records, the checkboxes disappear. Which means the records do not remain selected after the scroll option.   Also, the "Fail" button doesnt not get enabled as per your logic.

Read only

manish_malakar0316
Active Participant
0 Likes
3,875

I have figured out how to enable the "Fail" button, however, my issue now is to make the checkbox work as a push button. The only way the "Fail" button is enabling is when a user-command is triggered. But as per my requirement, the checkbox will trigger the "fail" button. Adding a function code to the checkbox is not solving the issue as the checkbox is not getting ticked.  Please advise.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,876

Whatever modification you execute on internal table SCREEN in PAI is reset to dynpro definition at start of next PBO. You must store the information in PAI and execute the LOOP AT SCREEN in the PBO.

Regards,

Raymond