06-16-2006 1:06 PM
Hi,
Given any internal table i was wondering if i could get the refernce type of its components?
So far i could only get the internal types and lengths. I want to get the Data Dictionary references so i can dynamically assign column titles in creating my ALV field catalog.
Is this possible? My other option is to use a dynamic internal table managed by a type manager class but thats too tedious and using the dynamic internal table is a bit awkward.
thanks in advance!
06-16-2006 1:07 PM
Hi emir,
1. we can get the field list using
the FM GET_COMPONENT_LIST
2. just copy paste
3.
REPORT abc.
*----
DATA : BEGIN OF itab OCCURS 0,
lifnr LIKE lfa1-lifnr,
land1 LIKE lfa1-land1,
name1 LIKE lfa1-name1,
name2 LIKE lfa1-name2,
END OF itab.
DATA : allfields(300) TYPE c.
DATA : fld(100) TYPE c.
DATA : components LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.
*----
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'ITAB'
TABLES
components = components.
BREAK-POINT.
LOOP AT components.
CONCATENATE 'LFA1~' components-compname '' INTO fld.
CONCATENATE allfields fld INTO allfields SEPARATED BY space.
ENDLOOP.
*----
SELECT (allfields)
FROM lfa1
INTO TABLE itab.
*----
BREAK-POINT.
regards,
amit m.
06-16-2006 1:22 PM
Amit,
Thanks for the quick response.
However, I could already do this.
Based on your example, is it possible to get
lfa1-lifnr from the component itab-lifnr?
06-16-2006 1:22 PM
06-16-2006 1:26 PM
Hi again,
1. From ITAB-LIFNR,
u want LFA1-LIFNR,
2. If your purpose of getting this,
is for getting the FIELD DESCRIPTION,
then the FM for ALV FIELD CATALOGUE MERGE,
will automaticlly do it.
3. However,
we can get some TABLE-LIFNR
from DD03L table,
where we can pass the field name as LIFNR,
and we get all records,
(ie. all tables/structures)
which use this field.
regards,
amit m.
06-16-2006 1:26 PM
Hi again,
1. From ITAB-LIFNR,
u want LFA1-LIFNR,
2. If your purpose of getting this,
is for getting the FIELD DESCRIPTION,
then the FM for ALV FIELD CATALOGUE MERGE,
will automaticlly do it.
3. However,
we can get some TABLE-LIFNR
from DD03L table,
where we can pass the field name as LIFNR,
and we get all records,
(ie. all tables/structures)
which use this field.
regards,
amit m.
06-16-2006 1:26 PM
Hi again,
1. From ITAB-LIFNR,
u want LFA1-LIFNR,
2. If your purpose of getting this,
is for getting the FIELD DESCRIPTION,
then the FM for ALV FIELD CATALOGUE MERGE,
will automaticlly do it.
3. However,
we can get some TABLE-LIFNR
from DD03L table,
where we can pass the field name as LIFNR,
and we get all records,
(ie. all tables/structures)
which use this field.
regards,
amit m.
06-16-2006 1:26 PM
Hi again,
1. From ITAB-LIFNR,
u want LFA1-LIFNR,
2. If your purpose of getting this,
is for getting the FIELD DESCRIPTION,
then the FM for ALV FIELD CATALOGUE MERGE,
will automaticlly do it.
3. However,
we can get some TABLE-LIFNR
from DD03L table,
where we can pass the field name as LIFNR,
and we get all records,
(ie. all tables/structures)
which use this field.
regards,
amit m.
06-16-2006 1:22 PM
06-16-2006 1:27 PM
Hi again,
1. From ITAB-LIFNR,
u want LFA1-LIFNR,
2. If your purpose of getting this,
is for getting the FIELD DESCRIPTION,
then the FM for ALV FIELD CATALOGUE MERGE,
will automaticlly do it.
3. However,
we can get some TABLE-LIFNR
from DD03L table,
where we can pass the field name as LIFNR,
and we get all records,
(ie. all tables/structures)
which use this field.
regards,
amit m.
06-16-2006 2:06 PM
hi. cool stuff but it still doesnt fit my requirement.
ie.
DATA: BEGIN OF itab,
document LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
budat LIKE bkpf-budat,
line_item LIKE bseg-buzei,
END OF itab.
notice that my internal table could be anything. It is not defined by a specific DDIC structure or table. The components, however, are ALWAYS defined by a table-field.
Basically, I am trying NOT to hardcode the descriptions of my field catalog.