2008 Nov 25 2:51 AM
Hi,
I have a scenario wherein i ge the table name from a select query in a variable and then i have to do another select query on this new table. But because this table name is stored in variable, i'm not gettign how to do a select query on it.
Regards
Aadil
Thanks for help!!!
2008 Nov 25 3:10 AM
You can do a dynamic selection .
Check out this link:
http://www.sapfans.com/forums/viewtopic.php?t=74847
Regards
Neha
Hi,
I have a scenario wherein i ge the table name from a select query in a variable and then i have to do another select query on this new table. But because this table name is stored in variable, i'm not gettign how to do a select query on it.
Regards
Aadil
Thanks for help!!!
2008 Nov 25 2:55 AM
2008 Nov 25 3:11 AM
Thanks solved the prob...u're right...i just needed to put a bracket in front of the variable name in select query...
Thanks
2008 Nov 25 3:10 AM
You can do a dynamic selection .
Check out this link:
http://www.sapfans.com/forums/viewtopic.php?t=74847
Regards
Neha
2008 Nov 25 3:12 AM
Can i define a data type also like that based on the table name which i just stored in variable...
Regards
2008 Nov 25 3:17 AM
Hi
Try this :
1-To assign a variable a type at runtime, use the ABAP statement ASSIGN with the option TYPE. For instance:
DATA: D_TYPE,
D_FIELD(35).
DATA: D_TEST TYPE P.
FIELD-SYMBOLS: <F>.
D_FIELD = 'D_TEST'.
D_TYPE = 'P'.
ASSIGN (D_FIELD) TO <F> TYPE D_TYPE.
Additionally you can use the option DECIMALS of the ASSIGN statement if your type is 'P'. You can even change the type at runtime of previously assigned field symbol like
ASSIGN <F> TO <F> TYPE 'C'.
One more thing for dynamic programing. With the following coding you can access every DDIC table with the key you want:
SELECT SINGLE * FROM (DF_TNAME) INTO S_TMP WHERE (IF_KEY).
2-FIELD-SYMBOLS:
<fieldname> TYPE ANY, "Name of field
<line> TYPE ANY, "Line structure for table
<fieldvalue> TYPE ANY. "Value of field
DATA: l_shorttext LIKE dd03m-ddtext.
DATA: wa_dd03l LIKE dd03l.
SELECT * FROM dd03l INTO wa_dd03l
WHERE tabname = 'ZHR_INTER_PA1_DL'.
Assign name of field
ASSIGN COMPONENT 2 OF STRUCTURE wa_dd03l TO <fieldname>.
Assign structure for internal table
ASSIGN wa_pa1_delta TO <line>.
Assign field value from structure
ASSIGN COMPONENT <fieldname> OF STRUCTURE <line> TO <fieldvalue>.
Find DD text for field
SELECT SINGLE ddtext
FROM dd03m
INTO l_shorttext
WHERE tabname = 'ZHR_INTER_PA1_DL' AND
fieldname = <fieldname> AND
ddlanguage = 'EN'.
WRITE: / <fieldname>, l_shorttext, ' : ', <fieldvalue>.
ENDSELECT.
Regards
Neha
2008 Nov 25 3:23 AM
Hey Neha,
Thanks alot for help!!! Actually I'm in BI and just playing around with diff concepts of ABAP to make my life easier in BI...
Thanks once again...