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

Error Message For Correct Input.

Former Member
0 Likes
2,495

Hi,

Im generating Vendor Report I want to Dispaly the Error Message for Invalid Input.

If i give the Company Codes other than 1000,2000,3000, & 4000 it should give the Error

as Invalid Company code...But For Correct company code also it is giving Error...

I Created Error class 'YVENMSG'

and in my Program i called Erorr as follows

if sy-subrc IS INITIAL.

MESSAGE e000(YVENMSG) .

ENDIF.

I dont know wr im wrong...

Plz help me on this...

Regards

Smitha

19 REPLIES 19
Read only

Former Member
0 Likes
2,371

Hi

If you give sy-subrc as initial it will throw error when sy-subrc is 0.(success)

So change it as if sy-subrc NE 0.

This should work

Read only

0 Likes
2,371

Hi

I tried as sy-subrc ne 0

again im facing same Problem

Read only

0 Likes
2,371

Hi Smitha

You declare as below :

*---- SELECTION-SCREEN

SELECTION-SCREEN BEGIN OF BLOCK b1.

SELECT-OPTIONS : s_werks FOR vbap-werks . "Plant

SELECTION-SCREEN END OF BLOCK b1.

*Selection Screen validation

AT SELECTION-SCREEN .

IF s_werks-low IS NOT INITIAL.

SELECT SINGLE werks "Plant

FROM t001w

INTO s_werks-low

WHERE werks = s_werks-low

and werks in ( '2000','3000','4000' ).

IF sy-subrc NE 0.

MESSAGE e000 WITH text-t48.

ENDIF.

ENDIF.

if its a parameter just replace s_werks as p_werks

Edited by: Martina Floriette on Feb 21, 2009 6:01 AM

Read only

Former Member
0 Likes
2,371
if co NE '1000' and co NE '2000' and co ne '3000'. " co is compnay code
  MESSAGE 'wrong' type 'I'." Here give ur own message
endif.
Read only

0 Likes
2,371

Hi

I tried this it wil give the error as no vendor specified then it displays Invalid Comapny code...

Any one error it should display....

Read only

0 Likes
2,371

please check the following code.

REPORT ztn_test.
PARAMETERS: co type i.

AT SELECTION-SCREEN.
if co NE '1000' and co NE '2000' and co ne '3000' and co ne '4000'.
  MESSAGE 'wrong' type 'I'.
endif.

Read only

Former Member
0 Likes
2,371

SELECTION-SCREEN BEGIN OF BLOCK b1.

SELECT-OPTIONS : s_werks FOR vbap-werks OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

*Selection Screen validation

AT SELECTION-SCREEN .

SELECT SINGLE werks FROM t001w

INTO s_werks-low

WHERE werks = s_werks-low

and werks in ( '1000','2000','3000','4000' ).

IF sy-subrc NE 0.

MESSAGE e000(ZXXX).

ENDIF.

Read only

0 Likes
2,371

Thank you....

My query Resolved....

Read only

Former Member
0 Likes
2,371

if ur referring Z-table give check table to that field then it will check automatically

other wise

at selections scren write select single for t001w table

iten if sy-subrc ne 0.

then give error.

Read only

0 Likes
2,371

Hi

Im facing one more Problem,,,

For 1000 Company code it is giving Correct OutPut...

But for 2000,3000,4000 comapny code When i execute first it gives the Message as

'No VENDOR Specified' Then it Gives the correct Out Put...

How to Resolve This?

Read only

0 Likes
2,371

For Error Message what logic u are using now?

if u have used OR operaot in it then replace it with AND.

Are u giving Company Code through PARAMETER?

Read only

0 Likes
2,371

IF P_BUKRS IS NOT INITIAL.

SELECT SINGLE BUKRS

FROM LFB1

INTO P_BUKRS

WHERE BUKRS = P_BUKRS.

AND BUKRS IN ('1000','2000','3000','4000').

IF SY-SUBRC NE 0.

MESSAGE E000(YVENMSG).

ENDIF.

ENDIF.

This is my code...

Im using the Parameter only....

Read only

0 Likes
2,371

if u want vendor to be inputted always,then provide OBLIGATORY to the select-options as given in my code above..then ur problem will be resolved

or if u dont want to provide dat...do like dis...

IF P_BUKRS IS NOT INITIAL.

SELECT SINGLE BUKRS

FROM T001

INTO P_BUKRS

WHERE BUKRS = P_BUKRS

AND BUKRS IN ('1000','2000','3000','4000').

IF SY-SUBRC NE 0.

MESSAGE E000(YVENMSG).

ENDIF.

ELSE.

MESSAGE E001(YVENMSG). "No company code specified

ENDIF.

Edited by: TT on Feb 21, 2009 11:15 AM

Read only

0 Likes
2,371

I have Declared as Obligatory Only....

Read only

0 Likes
2,371
tables: vbap.
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS : s_werks FOR vbap-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
data: BEGIN OF itab OCCURS 10,
      burks like lfb1-bukrs,
     end of itab.

*Selection Screen validation
AT SELECTION-SCREEN .

if s_werks-low NE '1000' and s_werks-low NE '2000' and s_werks-low ne '3000' and s_werks-low ne '4000'.
  MESSAGE 'wrong' type 'I'. " Here use ur own message class to display error
else.
  SELECT SINGLE BUKRS
FROM LFB1
INTO itab
WHERE BUKRS = s_werks
AND BUKRS = s_werks-low." Only given compnay code in select option data will be selected. "('1000','2000','3000','4000').
endif.
Read only

0 Likes
2,371
tables: vbap.
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS : s_werks FOR vbap-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
data: BEGIN OF itab OCCURS 10,
      burks like lfb1-bukrs,
     end of itab.

*Selection Screen validation
AT SELECTION-SCREEN .

if s_werks-low NE '1000' and s_werks-low NE '2000' and s_werks-low ne '3000' and s_werks-low ne '4000'.
  MESSAGE 'wrong' type 'I'.
else.
  SELECT SINGLE BUKRS
FROM LFB1
INTO itab
WHERE BUKRS = s_werks
AND BUKRS = s_werks-low." Only given compnay code in select option data will be selected. "('1000','2000','3000','4000').
endif.
Read only

0 Likes
2,371

Hi

Thank you

IT golt it Resolved....

i forgot to delete the Error Message which is declared in Text Elements...

Read only

0 Likes
2,371

Jus copy paste this . It works perfectly .

IF P_BUKRS IS NOT INITIAL.

SELECT SINGLE BUKRS

FROM T001

INTO P_BUKRS

WHERE BUKRS = P_BUKRS

AND ( BUKRS = 'HK01' or BUKRS = 'HU01' or BUKRS = 'ID01' or BUKRS = 'IE01').

IF SY-SUBRC NE 0.

MESSAGE e000 WITH text-t07.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
2,371

Error