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

Dynamic ftech values

Former Member
0 Likes
842

HI,

I have a variable,program dynmically stores the database table name in that variable,

i want to fetch key fields of variable and also i need to fetch key fiedl values from the same variable.

and finally move into main internal table.

2. is there any select syntax to fetch only key fields of any table without mention seperately fields in select query.

1 ACCEPTED SOLUTION
Read only

former_member222860
Active Contributor
0 Likes
811

Hi,

yes, it is possibel to pick up the key-fields of the table, see the below query.

data: begin of keytab occurs 0,
        fieldname like dd03l-fieldname,
       end of keytab.

parameters: table like dd03l-tabname.


 select fieldname into table keytab
                  from dd03l
                  where tabname = table
                  and keyflag = 'X'.


loop at keytab.
write:/ keytab-fieldname.
endloop.

thanks\

Mahesh

6 REPLIES 6
Read only

former_member222860
Active Contributor
0 Likes
812

Hi,

yes, it is possibel to pick up the key-fields of the table, see the below query.

data: begin of keytab occurs 0,
        fieldname like dd03l-fieldname,
       end of keytab.

parameters: table like dd03l-tabname.


 select fieldname into table keytab
                  from dd03l
                  where tabname = table
                  and keyflag = 'X'.


loop at keytab.
write:/ keytab-fieldname.
endloop.

thanks\

Mahesh

Read only

0 Likes
811

Mahesh,Thanks for ur suggestion,

as per ur logic,now in that internal table all the key fields are there.

My requirement is i need to fetch values of those key fields from the same variable(acts as table).

Read only

Former Member
0 Likes
811

Hi Satya,

Now you have your fields in the int table key tab.

SELECT (keytab) 
FROM (tab_name) INTO TABLE itab WHERE...

here tab_name contains data base table name.

Regards,

Manoj Kumar P

Edited by: Manoj Kumar on Jan 16, 2009 1:15 PM

Read only

former_member222860
Active Contributor
0 Likes
811

Hi satya,

yes, we can do that too, execute this.

tables: dd03l.

*data: begin of keytab occurs 0,
*        fieldname like dd03l-fieldname,
*       end of keytab.

parameters: table like dd03l-tabname.

select single fieldname into (dd03l-fieldname)
        from dd03l
        where tabname = table
        and  keyflag = 'X'.


select (dd03l-fieldname) into (dd03l-fieldname) from (table).
write: dd03l-fieldname.
endselect.

thanks\

Mahesh

Read only

0 Likes
811

Hi Manoj/Mahesh,

As per ur code,select query throws syntax check,.

select (key_tab) into itab from (table-name)

where = .

error is key_tab is not an internal table.system reads as internal table.

what to do.

Read only

former_member222860
Active Contributor
0 Likes
811

Satya,

My query returns data for the single key-filed of the selected table.

And I think u can't get the data for all the key-fields of the table at a time as structure of the 'itab' can't be defined at the run-time.

If u want to execute query like this

select (keytab) into table itab from (table).

u've to build the dynamic internal table for the selected key-fields.

And for more info, search with 'dynamic internal table' in the forums

hope u got me.

regards\

Mahesh