Application Development 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: 

SAP Input Screen Validation

Former Member
0 Kudos

Hi All

I have designed a screen in Module Pool Program in which I want to validate certain input fields. Based on the input given to a filed I want to enable or disable the next field or populate the next field with some value.

I want to do everything on the client side, not in the PAI event of that screen.

Please suggest the possible ways.

Thanks in adavnce.

Raghu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try like this at PBO


 loop at screen.
 if screen-name = 'p_field2'.
  if  p_field1 is initial.
   screen-input = 0.
  modify screen.
endif.
endif.
endloop.

THe above code is checking if there is value in p_field1 and if there is no value it it is deactivating p_field2.Similarly you can use your own logic also.

Regards,

Himanshu Verma

9 REPLIES 9

P561888
Active Contributor
0 Kudos

Hi,

Try this once,

loop at screen.

write the screen fields that are enable or disable

endloop.

Regards,

Bharani

Former Member
0 Kudos

Hi,

Write the select statement for validating the data that is entered into your field.

In PBO

Select statement .....

IF Sy-subrc <> 0.

IF ZFORM-CISWK = 'NO'. "

LOOP AT SCREEN.

IF SCREEN-NAME = 'ZFORM-YISWK'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

endif

PAI

IF ZFORM-CISWK = 'YES'.

LOOP AT SCREEN.

IF SCREEN-NAME = 'ZFORM-YISWK'. "field which has to

SCREEN-INPUT = 1.

SCREEN-ACTIVE = 1.

SCREEN-OUTPUT = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

endif.

So according top your select statement the screen fields witll be validated.

Hope my answer helps you.

Cheers!!

Former Member
0 Kudos

Hi,

Try like this at PBO


 loop at screen.
 if screen-name = 'p_field2'.
  if  p_field1 is initial.
   screen-input = 0.
  modify screen.
endif.
endif.
endloop.

THe above code is checking if there is value in p_field1 and if there is no value it it is deactivating p_field2.Similarly you can use your own logic also.

Regards,

Himanshu Verma

0 Kudos

Thank you all for your suggestions.

As per all your tips, I need to code the loop statement in the PBO or PAI events.

But I was searching something like a client side scripting validations, as it is done through Javascript in web pages, not server side code.

The validations that I need, are to be done by SAP system without any kind of event triggering.

E.g : Mandatory fields validation.(This check is made before the control is transferred to PAI event from the screen, we can check this by placing a break point in the first line of the first module in the PAI event)

0 Kudos

Hi Raghu,

You can try by declaring some fixed values for the field at the domain level.

Regards,

Himanshu Verma

0 Kudos

you can try with Javascript in ABAP, i never tried in ABAP, i used in BSP.

In ABAPDOCU you can see some Demo programs try out.

and aslo check the DEMOJAVASCRIPT* programs

0 Kudos

I had gone through the abapdocu examples but nowhere I cudnt find an example how to call a javascript fucntion with respect to a control(textbox) in a screen(like onchange event)

Canyone suggest how to bind a javascript function to a screen element and validate it and where to place the code(not in a module in PAI block)

0 Kudos

Hi All

Thank you very much for all your support & help.

I got the solution for my problem.

I can enable or disable a field by mentioning a Function Code against it, in its properties, with a function type or 'E' or 'H'.

The function code has to be trapped in the PAI event if the Function type as 'E'(Exit-Command) in

MODULE returnexit AT EXIT-COMMAND

or

in the Process On Value Request event by mentioning the Function type as 'H'(Help Function).

We can also transfer the control to another transaction by the Function type 'T'.

We can assign such Function codes only for Pushbuttons or Input/Output fields with the "Dropdown box" attribute, not to any other controls.

Thanks & regards,

Raghu

Former Member
0 Kudos

Hi All

Thank you very much for all your support & help.

I got the solution for my problem.

I can enable or disable a field by mentioning a Function Code against it, in its properties, with a function type or 'E' or 'H'.

The function code has to be trapped in the PAI event if the Function type as 'E'(Exit-Command) in

MODULE returnexit AT EXIT-COMMAND

or

in the Process On Value Request event if the Function type is 'H'(Help Function).

We can also transfer the control to another transaction by the Function type 'T'.

We can assign such Function codes only for Pushbuttons or Input/Output fields with the "Dropdown box" attribute, not to any other controls.

Thanks & regards,

Raghu