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

Mandatory Fields in Module pool

Former Member
0 Likes
6,045

HI,

I have created a module pool program in which there are around 30 input/output fields on screen.

out of which i have kept 3 fields are mandatory.

LIFNR - Vendor ID

BELNR - Acc. Dc. No.

Invoice date.

User update all the fields and and it gets saves into database.

Now i have placed one more command button on screen for display of data.

IF user enter the BELNR no. and click on display all others details should be auto populated.

But after entering BELNR and clicking in display it gives error "Fill all the required entries".

I do not want remove the mandatory tick of LIFNR and invoice date while entering data.

Any ideas to overcome this problem.

Thanks,

Amit Diwvedi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,536

I had this problem before and I prefered to control everything in P.A.I event. I did it:

----------------------------------------------------------------------------

PROCESS BEFORE OUTPUT.
   MODULE status_1000.
   MODULE bloquear_campos.

PROCESS AFTER INPUT.
   FIELD: w_xxx-belnr  MODULE check_field.    
   MODULE user_command_1000.

----------------------------------------------------------------------------

MODULE check_field.

   if belnr is initial

      MESSAGE 'xxxxxxxxx' TYPE 'E'.

   endif.

ENDMODULE.

----------------------------------------------------------------------------

You also can do that with loop at screen, setting group property for each field in your screen painter, and after:

----------------------------------------------------------------------------

LOOP AT SCREEN.
     IF screen-group1 = 'GR1'.
       screen-input = '0'.
       MODIFY SCREEN.
     ENDIF.
   ENDLOOP.

----------------------------------------------------------------------------

6 REPLIES 6
Read only

former_member218424
Participant
0 Likes
3,536

use chain endchain concept

Read only

Former Member
0 Likes
3,537

I had this problem before and I prefered to control everything in P.A.I event. I did it:

----------------------------------------------------------------------------

PROCESS BEFORE OUTPUT.
   MODULE status_1000.
   MODULE bloquear_campos.

PROCESS AFTER INPUT.
   FIELD: w_xxx-belnr  MODULE check_field.    
   MODULE user_command_1000.

----------------------------------------------------------------------------

MODULE check_field.

   if belnr is initial

      MESSAGE 'xxxxxxxxx' TYPE 'E'.

   endif.

ENDMODULE.

----------------------------------------------------------------------------

You also can do that with loop at screen, setting group property for each field in your screen painter, and after:

----------------------------------------------------------------------------

LOOP AT SCREEN.
     IF screen-group1 = 'GR1'.
       screen-input = '0'.
       MODIFY SCREEN.
     ENDIF.
   ENDLOOP.

----------------------------------------------------------------------------

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,536

I do not want remove the mandatory tick of LIFNR and invoice date while entering data.

Don't seem possible:

  • Mandatory fields in dynpro definition

As soon as there are initial mandatory fields on screen, only exit function code will be executed, other function code will trigger the Fill all the required entries message. So you cannot do that, as exit function-code will not transfer any data from screen to program and you won't be able to read data with the required database key...

  • Mandatory fields in code (FIELD/MODULE)

If you manage the mandatory field in some FIELD/MODULE statement, even after execution of a USER_COMMAND module that would fill the data. As soon as the error message for required entries is raised, no data is sent back from program to screen and you lose previous action...

Regards,

Raymond

Read only

Former Member
0 Likes
3,536

Hi Amit,

     In my opinion It is not possible without removing Mandatory fields for your requirement.

Regards,

Surya

Read only

Former Member
0 Likes
3,536

Hello Amit,

As Raymond said, it will be impossible to do if you don't remove the obligatory tick.

The only way to implement your requirement, is to remove the obligatory ticks, and use code to validate the field in PAI.

Example:

In your screen flow PAI:

PROCESS AFTER INPUT.
    FIELD INPUT_FIELD MODULE validate_initial.


And inside the module validate_initial:


IF sy-ucomm EQ 'BUTTON1' AND input_field IS INITIAL.
     MESSAGE 'Fill all required entries' TYPE 'E'.
ENDIF.


Depending on how your screen is built, you might need to use:


CHAIN.

FIELDS: field1 MODULE validate,

              field2 MODULE validate2....

....

ENDCHAIN.


Regards,


Thales Schmidt


Read only

Former Member
0 Likes
3,536

Hi Amit,

If you make user click a button to enter data entry mode then you could do it:  Define a variable GV_ENTRY_MODE that you set to X in the PAI when that button is pressed, and set to blank when the button to display an entry is clicked.

  • Do not set mandatory attribute in screen painter
  • In PBO, set SCREEN-REQUIRED = '1' if GV_ENTRY_MODE = 'X'
    • Probably also want to change SCREEN-INPUT depending on GV_ENTRY_MODE so they cannot change fields when in display mode

Jim