‎2009 Feb 21 4:31 AM
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
‎2009 Feb 21 4:35 AM
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
‎2009 Feb 21 4:51 AM
‎2009 Feb 21 5:01 AM
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
‎2009 Feb 21 4:39 AM
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.
‎2009 Feb 21 4:51 AM
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....
‎2009 Feb 21 4:57 AM
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.
‎2009 Feb 21 5:11 AM
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.
‎2009 Feb 21 5:19 AM
‎2009 Feb 21 5:22 AM
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.
‎2009 Feb 21 5:34 AM
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?
‎2009 Feb 21 5:36 AM
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?
‎2009 Feb 21 5:41 AM
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....
‎2009 Feb 21 5:42 AM
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
‎2009 Feb 21 5:47 AM
‎2009 Feb 21 5:53 AM
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.
‎2009 Feb 21 5:53 AM
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.
‎2009 Feb 21 5:56 AM
Hi
Thank you
IT golt it Resolved....
i forgot to delete the Error Message which is declared in Text Elements...
‎2009 Feb 21 6:01 AM
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.
‎2009 Feb 21 5:41 AM