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

How to enable/disable I/O box field in MODULE program?

Former Member
0 Kudos
1,528

Hi All,

I have a requirement where I need to dynamically enable/disable a I/O box drop-down?

This can be easily done in Classic ABAP reporting via


AT SELECTION-SCREEN.

LOOP AT SCREEN.
  name_of_field-input = 0.
  "or
  name_of_fileld-input = 1.
ENDLOOP.

In the case of moduled program, AT SELECTION-SCREEN event and LOOP AT SCREEN are not allowed in the PBO of a module program.

Any suggestions?

Thanks.

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Kudos
1,040

Hi,

Same thing you can do in PBO EVENT in case of dialog programs. Write a MODULE under PBO event and place ur screen modification code based on ur dynamic logic.

LOOP AT SCREEN.

Modify screen fields.

ENDLOOP.

Thanks,

Vinod.

17 REPLIES 17
Read only

vinod_vemuru2
Active Contributor
0 Kudos
1,041

Hi,

Same thing you can do in PBO EVENT in case of dialog programs. Write a MODULE under PBO event and place ur screen modification code based on ur dynamic logic.

LOOP AT SCREEN.

Modify screen fields.

ENDLOOP.

Thanks,

Vinod.

Read only

0 Kudos
1,040

Hi Vinod,

Yes I did that in my PBO:


module DISABLE_INPUT output.
  "AT SELECTION-SCREEN.
  LOOP AT SCREEN.
    IO_VENDORLOT_RES-INPUT = 0. "Error: The data object has no structure and therefore no component called INPUT
  ENDLOOP.
endmodule.                 " DISABLE_INPUT  OUTPUT

How can I enable/disable the I/O box field then since AT SELECTION-SCREEN is not allowed.

thanks

Read only

0 Kudos
1,040

Hi

What's IO_VENDORLOT_RES?

Your code should be:

LOOP AT SCREEN.
    SCREEN-INPUT = 0. 
    MODIFY SCREEN.
  ENDLOOP.

Max

Read only

0 Kudos
1,040

Hi Max,

IO_VENDORLOT_RES is the name of I/O box field in SCREEN PAINTER

and also the name in my TOP include declaration.


DATA: IO_VENDORLOT_RES   LIKE  ZCHECK-STATUS.

Thanks.

Read only

0 Kudos
1,040

So

LOOP AT SCREEN.
    CHECK SCREEN-NAME = 'IO_VENDORLOT_RES'.
    SCREEN-INPUT = 0. 
    MODIFY SCREEN.
  ENDLOOP.

Max

Read only

0 Kudos
1,040

Hi Max,

Almost there, thanks. Sorry I forgot to include more details, my I/O box is defined as ListDown. I notice that yes the field was disabled but I can still access it via dropDown.

I'm expecting like that the I/O box itself should be disabled and not accessible even via the drop-down.

Am I missing any other deactivation events/attributes here?

Or it seems like SAP do it that way? Yes the drop-down is still accessible BUT the user cannot select any value(s). Comparing it to other dev tool, Unlike in .NET where we can customize the events freely.

Thanks..

Edited by: Jaime Cabanban on Dec 16, 2009 3:27 AM

Read only

0 Kudos
1,040

Hi

You wrote:

This can be easily done in Classic ABAP reporting via...

So I think if u can do it in a selection-screen u can do it in a dynpro: now what did you do in the AT SELECTION-SCREEN?

Max

Read only

0 Kudos
1,040

Yes Max,

I did nothing "AT SELECTION-SCREEN", your solution partially works as such that:

- the I/O box(DropDown) is disabled for input

- but it is still accessible via DropDown

- Is this how SAP behave in locking I/O box field?

I'm expecting like it will be a total disable wherein the dropDown is not even accessible.

Thanks.

Read only

0 Kudos
1,040

Hi

I don't believe it can changed an attribute like a listbox, I've created this little report, but the listbox isstill active:

 PARAMETERS: P_BUKRS LIKE BSEG-KOART AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.
  ENDLOOP.

Max

Read only

0 Kudos
1,040

Hi Max,

Question answered, thanks. I also notice that only one SCREEN-NAME can be check only on one LOOP AT SCREEN. Please correct me if I'm wrong.

Only the first screen-name will be disabled.


  LOOP AT SCREEN.
    CHECK SCREEN-NAME = 'IO_VENDORDESC_RES'.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.

    CHECK SCREEN-NAME = 'IO_MATERIALNUM_RES'.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.
  ENDLOOP.

It will work this way:


  LOOP AT SCREEN.
    CHECK SCREEN-NAME = 'IO_VENDORDESC_RES'.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.
 ENDLOOP.

LOOP AT SCREEN.
    CHECK SCREEN-NAME = 'IO_MATERIALNUM_RES'.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.
  ENDLOOP.

Thanks,

Read only

matt
Active Contributor
0 Kudos
1,040

>

> Hi Max,

> Question answered, thanks. I also notice that only one SCREEN-NAME can be check only on one LOOP AT SCREEN. Please correct me if I'm wrong.

>

> Only the first screen-name will be disabled.

>


>   LOOP AT SCREEN.
>     CHECK SCREEN-NAME = 'IO_VENDORDESC_RES'.
>     SCREEN-INPUT = 0.
>     MODIFY SCREEN.
> 
>     CHECK SCREEN-NAME = 'IO_MATERIALNUM_RES'.
>     SCREEN-INPUT = 0.
>     MODIFY SCREEN.
>   ENDLOOP.
> 

>

> It will work this way:

>


>   LOOP AT SCREEN.
>     CHECK SCREEN-NAME = 'IO_VENDORDESC_RES'.
>     SCREEN-INPUT = 0.
>     MODIFY SCREEN.
>  ENDLOOP.
> 
> LOOP AT SCREEN.
>     CHECK SCREEN-NAME = 'IO_MATERIALNUM_RES'.
>     SCREEN-INPUT = 0.
>     MODIFY SCREEN.
>   ENDLOOP.
> 

>

> Thanks,

Have you read the ABAP help on CHECK.

CHECK condition

is exactly the same as

IF NOT condition.
  EXIT.
ENDIF.

For multiple checks use CASE.

Read only

0 Kudos
1,040

Hi

The problem is LOOP AT SCREEN can't have a WHERE condition, so it need to use an alternative solution in order to change the attribute of I/O fields.

It needs to consider everytime LOOP AT SCREEN is used, all I/O fields will be read in the LOOP, anyway the command is very fast, so it hasn't performance problem if it uses several LOOP AT SCREEN instead of one.

That means all these abap lines have the same effect:

LOOP AT SCREEN.
    CASE SCREEN-NAME.
        WHEN  'IO_VENDORDESC_RES'.
              SCREEN-INPUT = 0.
              MODIFY SCREEN.
         WHEN ' 'IO_MATERIALNUM_RES'.
             SCREEN-INPUT = 0.
             MODIFY SCREEN.
     ENDCASE:
 ENDLOOP.

or

LOOP AT SCREEN.
    IF SCREEN-NAME = 'IO_VENDORDESC_RES'.
              SCREEN-INPUT = 0.
              MODIFY SCREEN.
   ENDIF.
   IF SCREEN-NAME = 'IO_MATERIALNUM_RES'.
             SCREEN-INPUT = 0.
             MODIFY SCREEN.
     ENDIF.
 ENDLOOP.

or

LOOP AT SCREEN.
    CHECK SCREEN-NAME = 'IO_VENDORDESC_RES'.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.
 ENDLOOP.
 
LOOP AT SCREEN.
    CHECK SCREEN-NAME = 'IO_MATERIALNUM_RES'.
    SCREEN-INPUT = 0.
    MODIFY SCREEN.
  ENDLOOP.

Max

Read only

matt
Active Contributor
0 Kudos
1,040

But the first of those is the best programming.

matt

Read only

0 Kudos
1,040

Thanks Max and Bran,

I just revise my code in a better way.

Question answered at best state.

Read only

Former Member
0 Kudos
1,040

Why not just hide it completely?

Rob

Read only

0 Kudos
1,040

Hi Rob,

I can't hide it because it's part of a toggle screen for Display/Change. Thanks.

Question Answered,

Solution:

1. In PBO, create a module for Enable/Disable of I/O box Field

2. In the module, use LOOP AT-SCREEN .. ENDLOOP (as shown in my code above)

Note: if you have multiple screen values, you need to put them in one LOOP AT-SCREEN container.

Friendly Reminder: Ensure that the variable name in your Screen Painter and ABAP declaration(TOP include) are exactly the same.

Thanks.

P.S.

Hi Rob & Max,

You might as well want to check a closely relevant thread on module pool - I/O box field: How to Clear Value(s)

Edited by: Jaime Cabanban on Dec 16, 2009 4:04 AM

Read only

0 Kudos
1,040

Thanks for the update.

Rob