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

Break the SELECT statement.

Former Member
0 Likes
1,468

Hi,

My requirement is to break the Select statement and get the fields in where clause in one internal table.

For eg: Select VBELN

POSNR

MATNR from VBAP into wa_vbap where VBELN = '0000000001'

and POSNR = '000010'.

Here i need to put fields VBELN, POSNR, MATNR in one internal table, table name VBAP in second internal table and where clause fields VBELN, POSNR in third internal table.

Please let me know if anyone has any solution for this.

Thanks in advance.

Sunanda.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,267

Hi,

Check this Fm S_DB_SQL_STATEMENT_ANALYSE

Edited by: Avinash Kodarapu on Jan 27, 2009 1:19 PM

11 REPLIES 11
Read only

Former Member
0 Likes
1,267

Hi,

Select VBELN
           POSNR
           MATNR 
from VBAP into table itab 
Where <Condition>.

SELECT *
  FROM VBAP
    FOR ALL ENTRIES IN ITAB
WHERE VBELN = ITAB-VBELN
   AND POSNR = ITAB-POSNR.

is this way you are looking for ?

Read only

Former Member
0 Likes
1,267

Hi Sunanda,

1. You have to create an internal table for data selection from table VBAP.

let's suppose it's IT_VBAP.

Select VBELN POSNR MATNR

from VBAP into table IT_VBAP

where VBELN = '0000000001'

and POSNR = '000010'.

2.Apply a loop at IT_VBAP and append the records/fields in the desired internal table.

Loop at IT_VBAP.

move all the required fields in other internal table.

Append the record.

Endloop.

I hope it should be helpful.

Regards,

Amit

Read only

Former Member
0 Likes
1,267

hi try this

put VBAP in a field symbol and pass that filed symbol in select query.

select VBELN, POSNR, MATNR

into (po_ebeln, po_eindt, po_vbeln)

from VBAP

where ebeln in third internal table.

Read only

Former Member
0 Likes
1,267

Hi,

I think my question is not understood properly.

See, i am writing a code to check the performance of a program.

I donno at runtime what source code i have and which select query i have..

I want to check (in the select query of the source code at runtime) if the occurence of where clause fields is according to the table ....if not i have to through error.

Hope my requirement is clear now.

Thanks,

Sunanda.

Read only

0 Likes
1,267

>

> See, i am writing a code to check the performance of a program.

Why are you not satisfied with the standard tools? I. e. SE30, Code Inspector, etc.

Read only

0 Likes
1,267

Through SE30 all the possibilities are not satisfied.

Just like the one I am doing now.

If i m not using the fields in where clause as per the occurence in the database table, do i get any kind of message through SE30?..No.

There are so many performance issues which we need to manually check and are not traced through the available tool, so that is the reason why we are going for a new tool.

Sunanda.

Read only

0 Likes
1,267

>

> If i m not using the fields in where clause as per the occurence in the database table, do i get any kind of message through SE30?..No.

As far as I remember the Code Inspector will let you know about that. But in SE30 you should see all times, so you will know if the SELECT causes problems or not.

Read only

Former Member
0 Likes
1,268

Hi,

Check this Fm S_DB_SQL_STATEMENT_ANALYSE

Edited by: Avinash Kodarapu on Jan 27, 2009 1:19 PM

Read only

Former Member
0 Likes
1,267

Hi

*&---------------------------------------------------------------------*
*& Report  YSELECT                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  YSELECT                                 .

*Select VBELN
*POSNR
*MATNR from VBAP into wa_vbap where VBELN = '0000000001'
*and POSNR = '000010'.
*
*Here i need to put fields VBELN, POSNR, MATNR in one internal table,
*table name VBAP in second internal table and where clause fields VBELN,
* POSNR in third internal table.

TABLES: VBAP.

TYPES: BEGIN OF STRUCT1,
      VBELN LIKE VBAP-VBELN,
      POSNR LIKE VBAP-POSNR,
      MATNR LIKE VBAP-MATNR,
       END OF STRUCT1.

TYPES: BEGIN OF STRUCT2,
        TBLNAME(10),
       END OF STRUCT2.

TYPES: BEGIN OF STRUCT3,
      VBELN LIKE VBAP-VBELN,
      POSNR LIKE VBAP-POSNR,
      END OF STRUCT3.

DATA: ITAB1 TYPE TABLE OF STRUCT1 WITH HEADER LINE,
      ITAB2 TYPE TABLE OF STRUCT2 WITH HEADER LINE,
      ITAB3 TYPE TABLE OF STRUCT3 WITH HEADER LINE,
      V_TBLNAME(10).

ITAB3-VBELN = '0000000001'.
ITAB3-POSNR = '000010'.

APPEND ITAB3.

LOOP AT ITAB3.
    SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB1 WHERE VBELN EQ
ITAB3-VBELN AND POSNR EQ ITAB3-POSNR.
      WRITE ITAB1-VBELN.
ENDLOOP.

WRITE: 'SUBRC=', SY-SUBRC.

I am unable to find out how to satisfy your second internal table requirement.

Hope this helps

Regards,

Jayanthi.K

Read only

Former Member
0 Likes
1,267

Hi,

Refer to these 3 demo programs (Source transaction ABAPDOCU ) :


demo_select_dynamic_columns
demo_select_dynamic_database 
demo_select_dynamic_conditions

Combine them and I think you will have what you need.

regards,

Advait

Read only

ThomasZloch
Active Contributor
0 Likes
1,267

You will probably need the (internal only) SCAN ABAP-SOURCE statement to parse ABAP code like you have in mind here. Check F1 help and play around with it a bit.

Like Eric I'm wondering why someone would re-invent code inspector (which can be enhanced by your own checks!), but I'm wondering a lot anyway

Thomas