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

Former Member
0 Likes
12,168

  Hi gurus. I Have screen no 100 ( main screen). in this screen i have kunnr field. Then i called a sub screen 110. In the sub screen 110 i have 'land1'   is mandatory and 'name1' is optional. And TWO PUSH BUTTONS 'DISPLAY' AND 'SAVE' . After giving 'kunnr' if i entered a 'display' button

land1 and name1 should be fill.Because of Land1 is mandatory in sub screen the error raised 'fill required data' after i enter KUNNR . if i changed land1 is mandatory to recommended the problem is solved. so i want solution with land1 is mandatory but i want details.

Thanking you.

1 ACCEPTED SOLUTION
Read only

VenkatRamesh_V
Active Contributor
0 Likes
10,698

Hi Srinivas,

Try,

Created two push buttons  one with exit command(dispay). make the fields mandatory using the code for  change push button.

process before output.

module status_0100.

process after input.

module icon_100 at exit-command.

module status_0100 output.

  set pf-status 'STATUS'.

*  SET TITLEBAR 'xxx'.

if sy-ucomm = 'CHANGE'.

loop at screen.

check screen-name = 'VBAP-VBELN'.

screen-required = '1'.

modify screen.

endloop.

else.

endif.

endmodule.                 " STATUS_0100  OUTPUT

module icon_100 input.

case sy-ucomm.

when 'BACK'.

leave program.

when 'DISP'.

loop at screen.

check screen-name = 'VBAP-VBELN'.

screen-required = '0'.

modify screen.

endloop.

endcase.

endmodule.                 " ICON_100  INPUT

Hope it helpful,

Regards,

Venkat.

28 REPLIES 28
Read only

Former Member
0 Likes
10,698

Hi Srinivas,

I suggest you to remove the mandatory to the land1, and try to raise the popup to warn that that the mandatory field should not be  blank do you wish to continue.

Please refer the below code.

data: land1 TYPE land1,

       LV_ANSWER TYPE STRING.


IF land1 is INITIAL .

CALL FUNCTION 'POPUP_TO_CONFIRM'

   EXPORTING

     TEXT_QUESTION               = 'Land 1 is mandatory field and cannot be blank do you wish to continue still'

  IMPORTING

    ANSWER                      = LV_ANSWER.

           .

IF LV_ANSWER = '1'.

        

             * Proceed further

ELSE.

           

              *  Stop   ,

ENDIF.



Output:

Thanks and Regards,

Girish Kumar V.

Read only

0 Likes
10,698

Hi girish ,

thanks for giving replay.  here i have two push buttons i.e., 'DISPLAY' And 'SAVE'. We don't know the end user may click on 'SAVE' at that time he takes help( drop down) at that time the empty space occurs so my client ask i don't want to see that empty space. Then i need to use 'LAND1' field as a mandatory.

Read only

Former Member
0 Likes
10,698

Firstly I hope that the push buttons are standard (ie the save in the toolbar) etc ?

Secondly,  SAP generally has different transactions for display and edit variants,  the screen attributes are changed at run time dependant on either the Transactiuon type (defined in T180-TrTyp),  or with reference to the transaction code.

In your PBO have a module that loops around the screen (LOOP AT Screen) and modify the field attributes according to either a transaction coede or a transaction type.

Regards

Rich

Read only

0 Likes
10,698

Hi Richard,

  Thanks for your replay. Ya i already tried it but empty space occurs while end user take drop down button.

Read only

Chintu6august
Contributor
0 Likes
10,698

hi,

In PAI of main screen...

use statement CALL SUBSCREEN <subscreen area> after the module where you are fetching data for name1 and land1..

the flow of the screen will be PAI(100)-->> PAI(101)--->PBO(100)--->PBO(101).

now it's up to you where you want to assign the values to screen field (before PAI of 101) and you can also change the properties of screen field using LOOP AT SCREEN based on whether field is blank or not.

thanks!!

Read only

0 Likes
10,698

Hi chintu,

  Thanks for your replay. No i already tried it.. at that time also it raise error fill mandatory fields.

Read only

VenkatRamesh_V
Active Contributor
0 Likes
10,698

HI Srinivas,

Try,

Make the screen fields required to possible.

if sy-ucomm = 'Change' AND land1 is initial.

message ' ' type 'E'.

endif.

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
10,698

No if i change the fields required to change while customer want to save a customer then he may choose drop down(for help) at that time the empty field occurs then my client ask i dont want that empty field. For that i choose required...

Read only

Former Member
0 Likes
10,698

Above is the sample screen.

Read only

0 Likes
10,698

Hi,

are you passing this mandatory field to any select query??


Read only

0 Likes
10,698

HI

yes, while customer click on DISPLAY data fetch from kna1 and fill on screen for this i write.

in pai.

if sy-ucomm = 'DISP'.

  select single * from kna1 into corresponding fields of w_kna1 where kunnr = w_kna1-kunnr.

elseif sy-ucomm = 'save'.

   data should be saved in kna1 table.

endif.

Read only

0 Likes
10,698

what's the use of making LAND1 field mandatory when you are not passing it to any select query, make it recommended and put validation according to field values, it will resolve all your issues.

Read only

0 Likes
10,698

Thanks but if i make as recommended while he take drop down option( i dint show that. I forgot to add in the screen) Empty space will come. If i make as required only data will appear with out space. Actually my scenario is different for analyze purpose i post small scenario.

Read only

0 Likes
10,698

hi,

check the screen shot.. in my select query.. give customer number does not contain name which I am passing to mandatory field (after putting validation not actual mandatory), if it is initial it will give error message.

and then I manually enter data to it..

it give an information message that field is not initial.

make your logic like this by putting validation on LAND1 field after USER-commands

thanks!!

Read only

0 Likes
10,698

my actual image.

output screen.

Read only

0 Likes
10,698

first write statement CALL SUBSCREEN <subarea> after USER-COMMAND module, so your user command's get execute first then in PAI of sub-screen validate LAND1 field simple.

thanks!!

Read only

0 Likes
10,698

no not working chintu.

PROCESS BEFORE OUTPUT.
CALL SUBSCREEN SUB1 INCLUDING SY-REPID '0300'.
MODULE STATUS_0210.



PROCESS AFTER INPUT.
  MODULE USER_COMMAND_0210.
  CALL SUBSCREEN SUB1.
 
  MODULE EXIT AT EXIT-COMMAND.

Read only

Former Member
0 Likes
10,698

Hi Srinivas,

By default make land1 file non-editable and after pressing 'DISPLAY' button use loop at screen in PBO event and set  screen-input and screen-required equal to 1.

LOOP AT SCREEN.

     IF kunnr is not initial.

       IF screen-name = 'LAND1'.

         screen-input = '1'.

         screen-required = '1'.

         MODIFY SCREEN.

       ENDIF.

     ENDIF.

   ENDLOOP.


Thanks and Regards,

Pavan Kumar

Read only

0 Likes
10,698

Thanks,

If i make non editable suppose my client want to save the data at that time he need to enter land1 data also. So your ans not working for my requirement.

Read only

0 Likes
10,698

As soon as client enter kunnr and press display button i will become editable with mandatory.

Read only

0 Likes
10,698

Hi,

in PBO.. write the following code..

LOOP AT SCREEN.

     if flag = X and land1 is initial.

       IF screen-name = 'LAND1'.

         screen-required = '1'.

         MODIFY SCREEN.

       ENDIF.

     ENDIF.

   ENDLOOP.

in PAI

and set flag = 'X' after successful select query on KNA1 or if land1 have value.

it will work for sure

thanks!!

Read only

0 Likes
10,698

No No No my requirement is We dont know client may use this screen for display or save. If he click on display the data should be populated on screen based on kunnr or if the end user want to create he is able to enter all data and click on save.

your description is good for display but not save pupose.

Read only

0 Likes
10,698

Could you please elaborate the answer.

Read only

0 Likes
10,698

yes..

first PAI will trigger.. whether its SAVE or DISPLAY..

then do validation on LAND1 field and name1 field and set the FLAG after getting the values from select query or manual entry.

most simplest value is to validate land1 field in PAI.

as per your requirement.. if user hit display.. value should appear in the land1 field if there is value database table.

if there is no value in land1 field user should enter it before saving.. isn't it??

then simply put validation on SAVE command,

if land1 or whatever field you want mandatory is not initial.

  code for save.

else.

message 'fill the mandatory field' type 'S' display like 'E'.

leave list processing.

endif.

thanks!!

Read only

0 Likes
10,698

HI CHINTU

IN THE BELOW CODE

LOOP AT SCREEN.

     if flag = X and land1 is initial.

       IF screen-name = 'LAND1'.

         screen-required = '1'.

         MODIFY SCREEN.

       ENDIF.

     ENDIF.

   ENDLOOP.


LAND1 IS ALWAYS INITIAL FIRST TIME. EVEN IF YOU CLICK ON DISPLAY IT RAISE SAME ERROR. AND HOW TO DECLARE FLAG.

Read only

0 Likes
10,698

if there is no value in land1 field user should enter it before saving.. isn't it??

MY ANSWER IS NO.. VALUE EXITS OR NOT THATS NOT A PROBLEM. IF THE DATA AVAILABLE IN DB DATA SHOULD BE DISPLAY OR IF THE USER GIVES ALL DATA AND CLICK ON SAVE THE DATA SAVE ON DB. IF HE TAKE DROP DOWN FROM LAND1 LAST RECORD SHOULD NOT BE EMPTY.

Read only

VenkatRamesh_V
Active Contributor
0 Likes
10,699

Hi Srinivas,

Try,

Created two push buttons  one with exit command(dispay). make the fields mandatory using the code for  change push button.

process before output.

module status_0100.

process after input.

module icon_100 at exit-command.

module status_0100 output.

  set pf-status 'STATUS'.

*  SET TITLEBAR 'xxx'.

if sy-ucomm = 'CHANGE'.

loop at screen.

check screen-name = 'VBAP-VBELN'.

screen-required = '1'.

modify screen.

endloop.

else.

endif.

endmodule.                 " STATUS_0100  OUTPUT

module icon_100 input.

case sy-ucomm.

when 'BACK'.

leave program.

when 'DISP'.

loop at screen.

check screen-name = 'VBAP-VBELN'.

screen-required = '0'.

modify screen.

endloop.

endcase.

endmodule.                 " ICON_100  INPUT

Hope it helpful,

Regards,

Venkat.

Read only

Former Member
0 Likes
10,698

I dint get any answers so i closed this thread.