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

Help: Read table structure

Former Member
0 Likes
2,255

Hi everyone

is it possible to read a table structure of a intern Table to check whether in this table some specific data field exists or not. for example ,to check table1 if matnr is a data field in it.

the best will be using a loop to check all data fields name and type.

anyone can solve this problem???

thanks !!!

6 REPLIES 6
Read only

Former Member
0 Likes
911

Hi yunfan Wang

WELCOME to SDN

Structure dont have data .So u can fetch the data from structure in into internal table.

Regards

Read only

0 Likes
911

first thanks for replying

but my question is,

i have an intern table

but i want to check whether matnr is a data field in this table or not, how to do that?

has nothing to do with structure.

Read only

0 Likes
911

Hi

Debug ur program and find tht matnr has data or not.

you can ask ur team mates for debugging if u a fresher

Regards

Read only

0 Likes
911

Hi Yuwang,

Please take the help of key word *DESCRIBE FIELD INTO *

there is an example tooo

using this example i can check the fields of structure in debug mode

Best Regards

Ramchander Rao.k

Edited by: ramchander krishnamraju on Dec 12, 2008 12:41 PM

Read only

0 Likes
911

Here is how you can do this.

Sample code.

DATA: BEGIN OF it OCCURS 0,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

END OF it.

FIELD-SYMBOLS: <field>.

ASSIGN COMPONENT 'MATNR' OF STRUCTURE it TO <field>.

sy-subrc = 0 --> Means there is Matnr in the structure

sy-subrc = 4 --> Means there is NO Matnr in the structure

In the above case return code should be 4.

MK.

Read only

Former Member
0 Likes
911

Hi Wang..

once you get the into your internal table..

just loop the table for searching..

and regarding the performance

you can follow the follow this steps:

1) first short the table with MATNR

2) pass all the varible to some another table.

or

just first pass the table to another table.

and delete all the records where matnr NE your MATNR.

it is all just for performance.. only

Thanks and Regards,

GSANA