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 IMPORT FROM DATABASE

Former Member
0 Likes
2,025

Hi all,

I'm trying to build a generic routine to import the content of cluster tables like STXL, I have tried the statement IMPORT FROM DATABASE with variables for table name and area but ABAP does not seems to be supporting the use of variables for this statement.

Does anybody have an idea on how to achieve this?

Thanks.

9 REPLIES 9
Read only

Former Member
0 Likes
1,534

Anyone please?

Read only

0 Likes
1,534

Hi,

Correct me if I'm wrong, are you trying to store/retrieve your data by using SAP memory with IMPORT/EXPORT statement? Or you simply just want to retrieve the data from database table and store into your internal table?

Regards,

Xavier

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,534

As the IMPORT FROM DATABASE medium part doesn't seem to allow a dynamic syntax, you may have to generate a subroutine and then perform the generated subroutine. Or you could select the data from the INDX type file to an internal table and use an IMPORT FROM INTERNAL TABLE

Regards,

Raymond

Read only

Former Member
0 Likes
1,534

Hi guys,

Thank you for your replies, I'm trying to do an import from database not from memory, I'm trying to read tables like STXL in a generic way.

Thanks

Read only

0 Likes
1,534

hello,

what do you mean by generic way ?

best regards,

swanand

Read only

0 Likes
1,534

Hi,

I mean having statements like these:

IMPORT object to tmp_var from database dbtable(ar) id st_key.


where dbtable is a variable and ar is a variable too, this way we can use the same statement for tables like stxl and mdtc.

Thanks.

Read only

0 Likes
1,534

Hi,

Try this for dynamic import. It works fine for me in case of VARID table

  

          lwa_dyn_tab-clustername = <fwa_selctab>-name. " name of cluster field in cluster table

          lwa_dyn_tab-programname = '<F_FIELD5>'. "field symbol of type any

          APPEND lwa_dyn_tab TO gt_dyn_tab.

          IMPORT (gt_dyn_tab)

          FROM DATABASE vari(va) CLIENT g_mandt ID t_key. " Import dynamic.imported value will                                                                                           "come in <f_filed_5>

          IF <f_field5> IS ASSIGNED.

            wa_excl_data-field5 = <f_field5>.

          ENDIF.

       Hope this helps

Rgds,

Sandeep katoch

Read only

0 Likes
1,534

Hi,

Thank you Sandeep for your input but I would like to use the same statement for other tables than VARID.

Regards

Read only

0 Likes
1,534

HI,

You can do it in similar way.

As far as I know STXL table stores the text lines from SAP Script.

So you need only to build the dynamic internal table linked to field symbol with the text ID and text name and other possible keys.

Approach will be similar.

I will check If I can write some code for STXL table also.

Rgds,

Sandeep Katoch