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 select statement in subroutine pool concept

former_member392866
Active Participant
0 Likes
894

Hi Experts,

SELECT (s_column_syntax)

       FROM (s_dbtab_syntax)

       INTO TABLE T_FINAL1

       WHERE (t_criteria).

In above statement i'm getting 450 records. but i'm passing those internal tables to as below

PERFORM pull_data IN PROGRAM  (w_xprog)

       TABLES S_COLUMN_SYNTAX S_DBTAB_SYNTAX T_CRITERIA.

APPEND  'FORM PULL_DATA TABLES COLUMN_SYNTAX DBTAB_SYNTAX CRITERIA.' TO int_src.

APPEND 'SELECT (COLUMN_SYNTAX)' TO INT_SRC.

      APPEND 'FROM (DBTAB_SYNTAX)' TO INT_SRC.

        APPEND 'INTO TABLE T_OUTREC' TO INT_SRC.

         APPEND 'WHERE (CRITERIA).' TO INT_SRC.

   APPEND 'ENDFORM.' TO int_src.

GENERATE SUBROUTINE POOL int_src

   NAME    w_xprog

   MESSAGE w_msg

   LINE    w_len


In above we can't get data to T_OUTREC.

Getting runtime error as

A dynamically specified FROM clause has an unexpected format.

Regards,

BALAJI.


1 ACCEPTED SOLUTION
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
805

I believe s_column_syntax and s_dbtab_syntax are variables and not internal tables. So, you should not be using TABLES in your subroutine call. Instead use USING.

5 REPLIES 5
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
806

I believe s_column_syntax and s_dbtab_syntax are variables and not internal tables. So, you should not be using TABLES in your subroutine call. Instead use USING.

Read only

0 Likes
805

Kumar,

s_column_syntax and s_dbtab_syntax and t_criteria all are same data types(abapsource).

those are tables only. Working t_criteria fine but not s_column_syntax and s_dbtab_syntax.

thanks,

BALAJI.

Read only

0 Likes
805

Kumar,

great job.

I used using instead tables, now it's working fine.

Thank you Kumar.

Regards,

BALAJI.

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
805

You are welcome!

Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
805

Hi balaji,

In the PERFORM You have tables parameters as

TABLES S_COLUMN_SYNTAX

             S_DBTAB_SYNTAX

             T_CRITERIA.

Now the below mentione parameters of different type what you have passed in the select statement.

I would suggest you a standard program for the same operation please have and look and do the same how they are done.

Check the below links which esxplains your problem

http://help.sap.com/saphelp_nw04/Helpdata/EN/9f/db999535c111d1829f0000e829fbfe/content.htm

http://scn.sap.com/message/610351

http://www.sapabapcodes.com/2011/12/demo-report-on-generate-subroutine-pool.html

Hope this helps.