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

Retrieve multiple data for the same material from one table

former_member797394
Participant
0 Likes
1,075

HI ALL!

I struggling at the moment with the following issue.

There is one material that has two different data on a line. TABLE wlk1. It is easier to explain with screenshots.

If you can see in Screenshot 1, one material 1000001 (WLK1-ARTNR) has three different data in Module column (WLK1-URSAC). I need to show all of the Module codes in my report. So, I wrote the following code:

SELECT SINGLE ursac INTO <fs_output>-ursac FROM wlk1 WHERE ( quell EQ 3 AND sstat EQ ' ' AND artnr EQ <fs_output>-artnr ).

With this code, I am only getting the same module code for all 1000001 material entry. However, I need all three data. See Screenshot 2, to see my report result.

If any other information or part of the code is needed, I will provide it to you.

THANX IN ADVANCE!

2 REPLIES 2
Read only

FredericGirod
Active Contributor
964
SELECT SINGLE ursac INTO <fs_output>-ursac FROM wlk1 WHERE ( quell EQ 3 AND sstat EQ ' ' AND artnr EQ <fs_output>-artnr ).

SINGLE means: I only want one result.

SELECT ursac
       INTO table  @data(my_results) 
       FROM wlk1                   
       WHERE quell EQ 3
       AND sstat EQ ' ' 
       AND artnr EQ  @<fs_output>-artnr .
Read only

Dominik_Tylczynski
SAP Champion
SAP Champion
964

Hello khasanyusupkhujaev

You are using SELECT SINGLE statement, that by definition returns only one record. Get rid of SINGLE and the SELECT will return all suitable records.

In my opinion SELECT SINGLE must not be used unless you specify the full key in the WERE clause. Otherwise if you need just one record use SELECT UP TO 1 ROWS.

Best regards

Dominik Tylczynski