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

select statement with qmat table

Former Member
0 Likes
867

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
807

select matnr, werks

if sy-subrc 4.

message error.

stop.

endif.

5 REPLIES 5
Read only

Former Member
0 Likes
807

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

Read only

Former Member
0 Likes
808

select matnr, werks

if sy-subrc 4.

message error.

stop.

endif.

Read only

0 Likes
807

Can you please provide the full syntax for select statement.

thanks,

bin

Read only

Former Member
0 Likes
807

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

Read only

Former Member
0 Likes
807

thanks..