‎2007 Aug 05 7:48 AM
Hi,
I am a functional consultant and am learning abap...
I want to select matnr, werks and art fields from qmat table. I have written the parameter options to select from user for these 3 fields. I want to give an error message if the corresponding art field doesn't exist for matnr and werks field. Can you please provide some sample coding.
thanks,
bin
‎2007 Aug 05 7:53 AM
‎2007 Aug 05 7:51 AM
Hi Bin,
For any validations on the selection-screen use AT SELECTION-SCREEN event and to raise error using MESSAGE statement.
<b>Check this code.</b>
PARAMETERS: P_MATNR TYPE QMAT-MATNR.
PARAMETERS: P_WERKS TYPE QMAT-WERKS.
PARAMETERS: P_ART TYPE QMAT-ART.
AT SELECTION-SCREEN.
DATA V_ART TYPE QMAT-ART.
SELECT SINGLE ART FROM QMAT INTO V_ART
WHERE MATNR = P_MATNR AND WERKS = P_WERKS.
IF V_ART IS INITIAL.
MESSAGE E000 WITH 'No art exists for matnr and werks'.
ENDIF.
Thanks,
Vinay
‎2007 Aug 05 7:53 AM
‎2007 Aug 05 7:59 AM
Can you please provide the full syntax for select statement.
thanks,
bin
‎2007 Aug 05 8:02 AM
Hi
See this code
Report ZQMAT.
tables: mara, t001w,qmat.
data: begin of itab occurs 0,
matnr like qmat-matnr,
werks like qmat-werks,
art like qmat-art,
end of itab.
parameters:
p_matnr like mara-matnr,
p_werks like t001w-werks.
start-of-selection.
select matnr werks art from qmat into table itab where
matnr = p_matnr and werks = p_werks.
if sy-subrc <> 0.
message e020 with ' No record found in QMAT table'.
endif.
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Aug 05 8:10 AM