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

Selecting values from a table using Field value= value*

Former Member
0 Likes
1,328

Hi ,

I want to retrieve values from STXH table based on TDNAME = vbeln*.

means i am first getting the vbeln values from VBAK table.

Thenks adding a '*' to vbeln values and appending it to another internal table (T_VBAK2).

Means if i am getting '0012345678' as vbeln from VBAK then T_VBAK2-VBELN will contain '0012345678*' as the value.

Then finaly writing the query:

SELECT * FROM STXH

INTO TABLE LT_STXH

FOR ALL ENTRIES IN T_VBAK2

WHERE TDNAME = T_VBAK2-VBELN.

But this query is failing.

But Same thing if we do after going to SE11 we are getting values as obvious.

Please suggest the solution.

Thanks in Advance.

Mayank

8 REPLIES 8
Read only

Former Member
0 Likes
1,163

Hello

1. Add '%' instead of '*'. You will have '0012345678%' as the value.

2. In select do:


SELECT * FROM STXH
INTO TABLE LT_STXH
FOR ALL ENTRIES IN T_VBAK2
WHERE TDNAME LIKE T_VBAK2-VBELN. " <- LIKE instead of '='

Read only

0 Likes
1,163

Hi,

On replacing '=' with LIKE i am getting error message:

"The addition 'For All Entries in Itab ' cannot be used in the where condition BETWEEN ,LIKE and IN."

Please look into this.

Read only

0 Likes
1,163

Hi

U need to insert the select in a LOOP, it can't use FOR ALL ENTRIES:

DATA V_TDNAME TYPE STXH-TDNAME.

LOOP AT T_VBAK2.
   
   V_TDNAME = T_VBAK2-VBELN.
   V_TDNAME+10(1) = '%'.
   
   SELECT * FROM STXH
       APPENDING TABLE LT_STXH
                  WHERE TDNAME LIKE V_TDNAME.

ENDLOOP.

Max

Read only

0 Likes
1,163

Hello

Then loop/endloop instead of 'For All Entries'.

Read only

0 Likes
1,163

Hi,

I cant use loop endloop here....

As already VBAK table will have hundreds of records and again STXHhave around 550000 records.

So for each record fetching the data from database will be a performance issue.

Please provide some alternative.

Edited by: Mayank Verma on Feb 1, 2010 3:47 PM

Read only

0 Likes
1,163

Hi

It depends on what u need to do, give us more information: why u need to read STXH table?

Max

Read only

0 Likes
1,163

Actually,

By fetching data from STXH table :

I am passing:

STXH-TDID

STXH-TDNAME

STXH-TDOBJ

STXH-TDSPRAS to FM READ_TEXT to fetch TLINE text value.

means after fetching records from STXH table ...i am looping that internal table each time to call FM Read_Text......to get TLINE value.

Finally i want to have TLINE value for each of my sales order number.

This is my requirement.

Edited by: Mayank Verma on Feb 1, 2010 4:08 PM

Read only

0 Likes
1,163

I believe u've not many solution, u can try to manage the texts of a single sales order:

LOOP AT T_VBAK2.
   
   V_TDNAME = T_VBAK2-VBELN.
   V_TDNAME+10(1) = '%'.
   
   SELECT * FROM STXH
       INTO TABLE LT_STXH
                  WHERE  ( TDOBJECT = 'VBBK' OR TDOBJECT = 'VBBP' ) 
                        AND TDNAME LIKE V_TDNAME.

    LOOP AT LT_STXH.
    ENDLOOP.
 
ENDLOOP.

Else u need to calculate the right key for TDNAME if you don't want to use a LOOP

Max