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: 

Selection screen validation

Former Member
0 Kudos

Hi all,

I have a selection screen with 3 fields as vendor code, invoice number, status.

I have done the validation for vendor code. If the invoice number is selected and the selected invoice number is not valid there must be an error message and the cursor must be in the same field(invoice number).

In my case the cursor is automatically coming to the vendor code field.

Any input are appreciated.

Regards,

Rajkamal.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Sample Code:

AT SELECTION-SCREEN.

PERFORM f010_validate_customer.

FORM f010_validate_customer .

  • Validate Customer

SELECT kunnr

INTO w_kunnr

FROM kna1

UP TO 1 ROWS

WHERE kunnr IN s_kunnr.

ENDSELECT.

CHECK sy-subrc NE 0.

SET CURSOR FIELD 'S_KUNNR-LOW'.

MESSAGE e006. " Invalid Customer

ENDFORM. " F010_VALIDATE_CUSTOMER

Edited by: adarsh r on Jul 18, 2008 2:47 PM

11 REPLIES 11

Former Member
0 Kudos

Hi Raj,

Try to perform the validations in AT Selection-Screen on Field event.

This events validates only a single field. If the field value has error then, only that field remains input enabled and theother fields become input disabled.

For eg:

At selection-screen on matnr.

select single matnr

from mara

into w_matnr

where matnr in s_matnr

Hope this helps you.

Regards,

Chandra Sekhar

former_member705122
Active Contributor
0 Kudos

Hi,

Check this sample code:

AT SELECTION-SCREEN .
  IF s_carr is not initail.
    SELECT carrid
      INTO itab
      FROM sflight
      UP TO 1 ROWS
      WHERE carrid IN s_carr.
    ENDSELECT.

    CHECK sy-subrc NE 0.

    SET CURSOR FIELD 's_carr'.
    MESSAGE e001(zmsg).
  ENDIF.

Regards

Adil

Former Member
0 Kudos

Hi,

Do the validations in AT SELECTION-SCREEN ON <field>

event

Regards

Abhijeet

Former Member
0 Kudos

Hi

U should check if that invoice is assigned to the vendor by reading the header data (table RBKP):

AT SELECTION-SCREEN.
SELECT * FROM RBKP WHERE BELNR = P_BELNR.
ENDSELETC.
IF RBKP-LIFNR <> P_LIFNR.
  ERROR MESSAGE
ENDIF.

Max

Edited by: max bianchi on Jul 18, 2008 2:45 PM

vinod_vemuru2
Active Contributor
0 Kudos

Hi Raj,

Do ur validation unser below event. It will place the cursor in appropriate position.

AT SELECTION-SCREEN ON invoice number

(Here Replace invoice number with ur Parameter/select option name).

Now Do ur validation under this event and issue the error message.

Thanks,

Vinod.

Edited by: Vinod Reddy Vemuru on Jul 18, 2008 6:16 PM

Former Member
0 Kudos

Hi

Please try this sample code:

REPORT  z_test_15
        MESSAGE-ID zsd.
 
TABLES: t001.
 
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_bukrs TYPE t001-bukrs.
SELECTION-SCREEN END OF BLOCK b1.
 
AT SELECTION-SCREEN ON p_bukrs.
  SELECT SINGLE bukrs butxt
    FROM t001
    INTO (t001-bukrs, t001-butxt)
   WHERE bukrs = p_bukrs.
 
  IF sy-subrc = 0.
    MESSAGE s000 WITH 'You have selected company' t001-butxt.
  ELSE.
    MESSAGE e000 WITH p_bukrs 'is not defined as a company code'.
  ENDIF.

Regards

Nikunj Shah

Former Member
0 Kudos

Hi,

Sample Code:

AT SELECTION-SCREEN.

PERFORM f010_validate_customer.

FORM f010_validate_customer .

  • Validate Customer

SELECT kunnr

INTO w_kunnr

FROM kna1

UP TO 1 ROWS

WHERE kunnr IN s_kunnr.

ENDSELECT.

CHECK sy-subrc NE 0.

SET CURSOR FIELD 'S_KUNNR-LOW'.

MESSAGE e006. " Invalid Customer

ENDFORM. " F010_VALIDATE_CUSTOMER

Edited by: adarsh r on Jul 18, 2008 2:47 PM

Former Member
0 Kudos

Hi all,

Thanks for your valuable inputs.

But in my case i dont want to validate the invoice number but my requirement of cursor in that field.

Is it possible to do that? If yes, how?

Thanks.

0 Kudos

Hi Raj,

Yes it is possible. u can use SET CURSOR FIELD option. Just copy paste below code and see. U can change the message class. Enter po_1 = 2 and press enter. Cursor will be place in po_2.

Make sure that u r passing the field name in capital letters


PARAMETERS: po_1 TYPE c,
            po_2 TYPE c.

AT SELECTION-SCREEN.
IF po_1 EQ '2'.         " Do ur validation here
SET CURSOR FIELD 'PO_2'.
MESSAGE e000(zv).
ENDIF.

Thanks,

Vinod.

Edited by: Vinod Reddy Vemuru on Jul 18, 2008 7:14 PM

0 Kudos

Hi Vinod,

Thanks for the inputs.

The code which you gave me is, if the "If condition" is true the cursor is going to the second field.

In my code, I am giving the correct input for the first field and if i give the wrong input for the second field and execute, i need to get the error message as "Wrong input" and the cursor must be in the second field for doing the change.

Any inputs for this?

Thanks.

0 Kudos

Hi Raj,

Then u can simply use AT SELECTION-SCREEN ON fieldname event correct?

Check below code. Assume value 2 is wrong input for second field. Now check the code.


PARAMETERS: po_1 TYPE c,
            po_2 TYPE c.

AT SELECTION-SCREEN ON po_2.
IF po_2 EQ '2'.
MESSAGE e000(zv).
ENDIF.

Thanks,

Vinod.