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

Screen Validation

Former Member
0 Likes
2,159

Hello out there,

I am trying to do some validation within a customer exit:

e.g. IF wa_length <> 11.

MESSAGE e001(zpa0105).

ENDIF.

So if the length of a screen field is not equal to 11 characters the error message is displayed. Everying is

working fine except that I would expect the cursor to remain within the screen field containing the error.

What actually happens is that the screen field changes so that no input is allowed and the cursor is

placed on the first field at the top of the screen which is also highlighted in red.

Any ideas??

Any help much appreciated.

Andy

1 ACCEPTED SOLUTION
Read only

jayesh_gupta
Active Participant
0 Likes
1,909

You may close the thread.

Regards,

Jayesh

16 REPLIES 16
Read only

jayesh_gupta
Active Participant
0 Likes
1,909

Hi Andy,

Assuming that you are writing your code in PAI (Process after input), you may write it in a separate module under PAI as below:

Process after input.

FIELD <your screen fieldname> MODULE <module name>.

Inside the module, put the code for checking the lenth and displaying the message.

Regards,

Jayesh

Read only

0 Likes
1,909

Many thanks Jayesh.

I will have a go with your answer

Thanks again

Read only

JoffyJohn
Active Contributor
0 Likes
1,909

SET CURSOR FIELD <ur field name>.

to set the cursor on the field you want to edit.

Read only

jayesh_gupta
Active Participant
0 Likes
1,909

SET CURSOR FIELD will not work after displaying an error message. The display of error message aborts further processing.

Edited by: Jayesh Gupta on May 26, 2010 12:59 PM

Read only

jayesh_gupta
Active Participant
0 Likes
1,910

You may close the thread.

Regards,

Jayesh

Read only

0 Likes
1,909

Jayesh,

Can't get this to work.

It is in a function exit that I am trying to get this working

i.e. EXIT_SAPFP50M_002 and then the code I am entering is in the INCLUDE ZXPADU02.

Any ideas ?

Read only

MarcinPciak
Active Contributor
0 Likes
1,909

I think using


MESSAGE ... TYPE 'W'. 

will first raise the warning but eventually (after ENTER key pressed) will allow you correct the entry.

Also this might be an issue of some other (previous) field not receive the correct value. So when you invalidate the entry, the PAI starts again with checking all the fields listes in PROCESS AFTER INPUT in screen flow logic.

The first invalied met will stop you from further input on previous field. To avoid this you can use [CHAIN logic|http://help.sap.com/saphelp_bw/helpdata/en/9f/dbabbd35c111d1829f0000e829fbfe/frameset.htm] to keep all fields input enalbed once one of them invalidates.

PS: Please reopen the thread if not solved, otherwise people will most likely skip this thread seeing it as answered. Once you get the solution (or could not find one) then close it again.

Regards

Marcin

Read only

0 Likes
1,909

Many thanks Marcin

Read only

Former Member
0 Likes
1,909

Misunderstanding of question

Read only

0 Likes
1,909

Jayesh, Marcin,

I know what you mean now. But the FIELD command can only be used within

the FLOW-LOGIC of the screen.

I can't add/chnage this because it is SAP standard, that is why I have to use

the customer function exit.

Any other ideas? Or can this simply not be done?

Andy

Read only

0 Likes
1,909

I just checked that too. For me, simple warning message works fine (as described before)


MESSAGE ... TYPE 'W'. 

First the screen field (in PA30) is input disabled but once you press the ENTER you can correct your entry in that invalidated field.

Regards

Marcin

Read only

jayesh_gupta
Active Participant
0 Likes
1,909

Andy, your problem is resolved:

I examined function exit EXIT_SAPFP50M_002. This function module has an exception as ERROR_OCCURED(see function module in SE37).

Also, there is an emplemented example for this exit in Include LXPADF01.

According to this example, you need to raise the above exception with your message. I am copying the example include source code here

* data declaration in ZXPADTOP     "Global Data
  DATA: I0001 LIKE P0001,
        I0008 LIKE P0008.
* OR, if it is an infotype view:
  DATA: BEGIN OF I0008.
          INCLUDE P0008.
          INCLUDE PS0230.  "additional fields
  DATA: END OF I0008.

* default values in ZXPADU01

  CASE INNNN-INFTY.
    WHEN '0001'.
      MOVE INNNN TO I0001.
      MOVE 'XX'  TO I0001-VDSK1.
      MOVE I0001 TO INNNN.
    WHEN '0008'.
      MOVE INNNN TO I0008.
      MOVE 'YY'  TO I0008-TRFGR.
      MOVE I0008 TO INNNN.
  ENDCASE.


* additional checks in ZXPADU02
* example: wage type '1234' is not allowed for employee subgroup 'DE'
  CASE INNNN-INFTY.
    WHEN '0008'.
      MOVE INNNN TO I0008.
      IF P0008-LGA01 EQ '1234' AND IPSYST-PERSK EQ 'DE'.
        MESSAGE S016(RP) WITH 'wage type' I0008-LGA01 'not allowed'
                         RAISING ERROR_OCCURD.
*       S-Message for infotype 0008 (see psyst-msgtp).
      ENDIF.
  ENDCASE.

See the second CASE statement which is rasing a message.

Hope it works.

Regards,

Jayesh

Edited by: Jayesh Gupta on May 26, 2010 2:56 PM

Read only

jayesh_gupta
Active Participant
0 Likes
1,909

In case of warning messages, if you repeatedly press ENTER, the incorrect input values are accepted. Hence warning message should be avoided.

Jayesh

Read only

0 Likes
1,909

Jayesh,

I really appreciiate your time in answering my question.

I have now chanaged the include ZXPADU02 within the function module exit EXIT_SAPFP50M_002.

My code now says:

WHEN '0105'. " DV1K928778

*----------------------------------------------------------------------*
* Put Contents of screen fields to i0105
*----------------------------------------------------------------------*
*
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
      EXPORTING
        prelp = innnn
      IMPORTING
        pnnnn = innnn.

* Check the format of the work telephone numbers
*
*   Work Tel. No - Has to be 11 numeric characters
*   Work Mob. No - Has to be 8  numeric characters
*
*
    IF innnn-subty = '0020'    " Work Tel. No.
    OR innnn-subty = 'CELL'.   " Work Mob. No.

*     Check Work Tel. No.
      IF innnn-subty = '0020'.
        wa_length = STRLEN( i0105-usrid_long ).

        IF wa_length <> 11.
          MESSAGE e001(zpa0105) RAISING error_occured.
        ENDIF.
      ENDIF.


    ENDIF.

But still the same thing happens. The cursor is moved to the top of the screen and the

telephone number does not allow any input.

Andy

Read only

0 Likes
1,909

Andy, you have to use MESSAGE S001(zpa0105) RAISING error_occured.

Presently you are using MESSAGE e001(zpa0105) RAISING error_occured.

Regards,

Jayesh

Read only

0 Likes
1,909

Hi Jayesh,

Managed to solve this by useing LEAVE SCREEN.

Andy