08-20-2010 1:50 PM
Hi Experts,
We have fields like TKG001, TKG002, TKG003 etc in COST table...
My requirement is that we want the value present in the field TKG0** where ** is the month of system data.
Do we have any method to extract the field dynamically from the table.
Please suggest me how can i achieve the requirement.
Thank you,
Regards,
Kavya
08-20-2010 2:00 PM
Hello
You can use dynamic field specification
Check this :
REPORT x.
DATA :
BEGIN OF lw_field,
field(20),
END OF lw_field,
lt_field LIKE STANDARD TABLE OF lw_field.
START-OF-SELECTION.
lw_field-field = 'BUKRS'.
APPEND lw_field TO lt_field.
lw_field-field = 'GJAHR'.
APPEND lw_field TO lt_field.
SELECT (lt_field) "<-- Internal table contains your dynamically specified in parenthesis
FROM bkpf
INTO TABLE itab.
BREAK-POINT.
08-20-2010 1:57 PM
Dear Kavya,
Could you please elaborate your query ? If you want to extract data through any programme you can always define some variable according to the no. of a particular month.
Anyway, please elaborate on your requirement.
Regards
08-20-2010 2:00 PM
Hello
You can use dynamic field specification
Check this :
REPORT x.
DATA :
BEGIN OF lw_field,
field(20),
END OF lw_field,
lt_field LIKE STANDARD TABLE OF lw_field.
START-OF-SELECTION.
lw_field-field = 'BUKRS'.
APPEND lw_field TO lt_field.
lw_field-field = 'GJAHR'.
APPEND lw_field TO lt_field.
SELECT (lt_field) "<-- Internal table contains your dynamically specified in parenthesis
FROM bkpf
INTO TABLE itab.
BREAK-POINT.
08-20-2010 2:02 PM
Yes [SELECT|http://help.sap.com/abapdocu_70/en/ABAPSELECT.htm] statement allow a dynamic [SELECT - columns|http://help.sap.com/abapdocu_70/en/ABAPSELECT_CLAUSE_COLS.htm#&ABAP_ALTERNATIVE_3@3@] syntax - Check the sample at the bottom of the last link.
Regards,
Raymond
08-24-2010 1:37 PM
08-20-2010 2:52 PM
A simpler way would be to select the twelve fields and then decide which one to use while processing the internal table.