‎2009 Apr 21 11:00 AM
how to find whether the fields of an internal table exists in a database table or not.
‎2009 Apr 24 12:00 PM
hi sugautam
data itab1 type table of <table name> with header line." your internal table with data
data itab2 type table of matnr with header line." itab for the database table
select matnr from mara into iatb2.
data flag type i value 0.
loop at itab1.
loop at itab2 where matnr = itab1-matnr.
endloop.
if sy-subrc = 0.
write: / 'material' , itab1-material, 'exists'.
endloop.
‎2009 Apr 21 11:17 AM
Hi,
Can you please give some more inputs on your query, so that i can able to give the answer
Regards
Ramakrishna Pathi
‎2009 Apr 21 11:45 AM
hi,
i have created a ztable which has a field Y_ITEM_NUM(Item Number).i have to find whether a item no. entered in this field exists in MARA-MATNR field?
‎2009 Apr 21 12:25 PM
Hi sugautam,
first of all get tall the records from Ztable to an internal table itab1.
then hit the table MARA using for all entries in the table itab1
and take the valid records into another internal table itab2.
select matnr
from mara
into table itab2
for all entries in itab1
where matnr EQ itab1-matnr.
if sy-subrc EQ 0.
you have all the matnrs existing in MARA in the new table itab2.
else.
not even 1 matnr is valid....
endif.
you can consider the matnrs in itab2 as valid matnrs....
I hope this will be helpful.
Let me know in case u require any furhter clarifications....
...Pavan.
‎2009 Apr 23 2:59 PM
just write the select query
select y_item_num from ztable into ztable where matnr = <field you passed in exit>
if sy-subrc = 0
then your entries is entered
else
no
endif.
cheers
s.janagar
‎2009 Apr 21 11:24 AM
hi,
u can manually check internal table field inside the data base table . if this is not what u want pls explain ur question more specifically.
thanks,
Aditya
‎2009 Apr 21 12:46 PM
Data:
w_lines type i,
w_index type i value.
describe table itab lines w_lines.
while w_index le w_lines.
read table itab into wa index w_index.
Select single field from dbtable into w_field where field eq wa-field1.
If sy-subrc ne 0.
write: " field does not exit in db table
endif.
w_index = w_index + 1.
endwhile.With luck,
Pritam.
‎2009 Apr 23 8:40 AM
Hi Sugautam,
try this piece of code it might provide the full solution to your query supposing you want to check the availability of matnr value in the database table
data itab1 type table of <table name> with header line." your internal table
data itab2 type table of <table name> with header line." itab for the database table
select matnr from <table name> into iatb2.
data flag type i value 0.
loop at itab1.
loop at itab2.
if itab1-matnr = itab2-matnr.
flag = 1.
endif.
endloop.
if flag = 1.
write : / itab1-matnr,' exists'.
flag = 0.
endif.
endloop.
Edited by: raveeshgupta on Apr 23, 2009 10:53 AM
‎2009 Apr 24 7:46 AM
Hi,
You can check whether a particular field of a table exists or not by firing a select on table DD03L.
Supply the Table name and the field name that you want to check to the table DD03L.
If sy-subrc is not zero, it is evident that , that field is not present in that particular table.
Thanks and Regards,
Sowmya Arni
‎2009 Apr 24 12:00 PM
hi sugautam
data itab1 type table of <table name> with header line." your internal table with data
data itab2 type table of matnr with header line." itab for the database table
select matnr from mara into iatb2.
data flag type i value 0.
loop at itab1.
loop at itab2 where matnr = itab1-matnr.
endloop.
if sy-subrc = 0.
write: / 'material' , itab1-material, 'exists'.
endloop.