‎2007 Feb 02 1:24 PM
Dear friends,
i have a parameter A and b, i need to validate parameter A with the database table wheather parameter A is exist or not and paramter shpuld be validated against internal table.
pls provide code for the above
thanks in advance
karthik
‎2007 Feb 02 1:27 PM
Hi karthik,
1. We can do like this.
START-OF-SELECTION.
select * from dbtable
where field1 = A.
if sy-subrc <> 0.
message 'A Not found' type 'I'.
leave list-processing.
endif.
read table ITAB with key field1 = B.
if sy-subrc <> 0.
message 'B Not found' type 'I'.
leave list-processing.
endif.
regards,
amit m.
‎2007 Feb 02 1:27 PM
karthik,
I'm sure this is available on help.sap.com
AT selection-screen on a.
select count( * ) from <database> where <field> = a.
if sy-subrc <> 0.
message Ennn with a 'does not exist'.
endif.
Regards,
Clemens
‎2007 Feb 02 1:28 PM
at selection-screen for a.
select single * from <the master table for parameter A) where <field> = a.
if sy-subrc <> 0.
message e001(zz) with 'Invalid value'.
endif.
at selection-screen for b.
Iassume that you have the internal table to validate against ready.
read table itab with key field = b.
if sy-subrc <> 0.
message e001(zz) with 'Invalid value for B'.
endif.
Regards,
Ravi
‎2007 Feb 02 1:34 PM
Hi,
If you want to do the validation at selection screen then you can validate one variable at selection screen whicn you need to validate with databse. Or you can validate both the values at start of selection.
Use AT SELECTION-SCREEN event.
Select single field from dbtable
where field1 = A.
if sy-subrc <> 0.
Error message.
endif.
For internal table do the validation at Start-of-selection screen event.
Read table ITAB with key field1 = B.
If sy-subrc <> 0.
Error message.
endif.
Ashvender
‎2007 Feb 02 1:37 PM
parameter :p_werks like marc-werks.
parameter :p_matnr like mara-matnr.
You can do this in at selection screen .
at selection screen.
select single werks into v_werks from t001w where werks = p_werks.
if sy-subrc eq 0.
write:/ 'plant exits '
else.
message e001 (zxx) with 'Plant dosent exist'.
endif.
same
select single matnr into v_matnr from mara where matnr = p_matnr.
;;;
//parameter A is exist or not and paramter shpuld be validated against internal table.
Now if im doing the validation here then it is enough .
cause error is thrown here cause start of selection is not yet triggered.
now if i do a select internal table will contain only valid entries of Db so y do i need to do the validation unless im making some criteria .
Ex material 'raw ' is defined in plants 1001 2001 3001 then i can do a validation whether it exists for plant or not.
select single matnr into v_matnr from marc where
matnr = p_matnr and werks = p_werks .
with same effect
regards,
vijay
‎2007 Feb 02 1:49 PM
Dear Vijay,
I have a field A with the values in the internal table, i need to check those values exits in the table B.
pls send code for the above
thanks
karthik
‎2007 Feb 02 2:23 PM
‎2007 Feb 02 2:25 PM
‎2007 Feb 02 2:33 PM
execute the code ..
data : begin of itab occurs 0,
f1(4) type c,
f2(4) type c,
end of itab.
data : begin of jtab occurs 0,
f1(4) type c,
f2(4) type c,
end of jtab.
*table a
itab-f1 = '0001'.
itab-f2 = 'pppp'.
append itab.
itab-f1 = '0002'.
itab-f2 = 'pppp'.
append itab.
**table b
jtab-f1 = '0007'.
jtab-f2 = 'abcd'.
append jtab.
jtab-f1 = '0002'. "common entry of table a
jtab-f2 = 'efgh'.
append jtab.
sort itab by f1.
sort jtab by f1.
loop at itab.
read table jtab with key f1 = itab-f1.
if sy-subrc = 0.
write:/ 'Common in table A and B' , itab-f1.
endif .
endloop.regards,
vijay.