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

problem with select

Former Member
0 Likes
803

Hi, I have part of code:

TYPES: BEGIN OF eket_obj,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge TYPE i,

wemng TYPE i,

objednane TYPE i,

END OF eket_obj.

DATA: l_eket_obj TYPE eket_obj OCCURS 0 WITH HEADER LINE.

SELECT werks ekpomatnr eketmenge eket~wemng

FROM ekko

JOIN ekpo ON ekkoebeln = ekpoebeln

JOIN eket ON ekkoebeln = eketebeln

AND ekpoebelp = eketebelp

JOIN mara ON maramatnr = ekpomatnr

INTO l_eket_obj

WHERE ekkoloekz = '' AND ekpoloekz = ''

AND eketmenge > eketwemng

AND werks between 1000 and 1003

AND mara~mtart = 'HAWA'

GROUP by werks ekpomatnr eketmenge eket~wemng.

l_eket_obj-objednane = l_eket_obj-menge - l_eket_obj-wemng.

endselect.

write l_eket_obj.

How change this code that table l_eket_obj keeps all lines taken from table ekko not only the last one?

Thanks,

Joanna

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
776

Hi,

Modify ur code as follows

TYPES: BEGIN OF eket_obj,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge TYPE i,

wemng TYPE i,

objednane TYPE i,

END OF eket_obj.

DATA: l_eket_obj TYPE eket_obj OCCURS 0 WITH HEADER LINE.

SELECT werks ekpomatnr eketmenge eket~wemng

FROM ekko

JOIN ekpo ON ekkoebeln = ekpoebeln

JOIN eket ON ekkoebeln = eketebeln

AND ekpoebelp = eketebelp

JOIN mara ON maramatnr = ekpomatnr

INTO l_eket_obj

WHERE ekkoloekz = '' AND ekpoloekz = ''

AND eketmenge > eketwemng

AND werks between 1000 and 1003

AND mara~mtart = 'HAWA'

GROUP by werks ekpomatnr eketmenge eket~wemng.

l_eket_obj-objednane = l_eket_obj-menge - l_eket_obj-wemng.

<b>Append l_eket_obj.</b>

endselect.

<b>Loop at l_eket_obj.</b>

write l_eket_obj.

<b>endloop.</b>

<b>Changes are in Bold.</b>

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

8 REPLIES 8
Read only

Former Member
0 Likes
776

Hi,

keep the write statement before ENDSELECT statement.

Regards,

Satya

Read only

0 Likes
776

yes, I know this, but it only makes that single line will be printed every time that select takes data but i don't need to print all this data (the write sentences is only to check content of table) i need that all lines will be kept in table.

Read only

Former Member
0 Likes
776

Hi,

The cause is the way you are using internal table l_eket_obj. In your code you are only filling the header of the table, not the body (no APPEND Statement).

Better is to do SELECT INTO TABLE

SELECT werks ekpomatnr eketmenge eket~wemng

FROM ekko

JOIN ekpo ON ekkoebeln = ekpoebeln

JOIN eket ON ekkoebeln = eketebeln

AND ekpoebelp = eketebelp

JOIN mara ON maramatnr = ekpomatnr

INTO <i>TABLE</i> l_eket_obj

WHERE ekkoloekz = '' AND ekpoloekz = ''

AND eketmenge > eketwemng

AND werks between 1000 and 1003

AND mara~mtart = 'HAWA'.

  • GROUP by werks ekpomatnr eketmenge eket~wemng. "Not sure if you need this

*

  • Update the field in the internal table

*

LOOP AT l_eket_obj.

l_eket_obj-objednane = l_eket_obj-menge - l_eket_obj-wemng.

MODIFY l_eket_obj.

ENDLOOP.

Read only

0 Likes
776

Hi, after changing on INTO TABLE it still shows only one line. Could I change it in the other way yet?

Regards,

Joanna

Read only

0 Likes
776

You need to put your WRITE statement inside a LOOP, and write out each field separately.

LOOP AT <Table>.

WRITE:/ <Table>-xxx,

<Table>-yyy,

<Table>-zzz.

ENDLOOP.

Read only

0 Likes
776

THAKS u all for hepl now it works.

Read only

Former Member
0 Likes
776

Hi,

I think u need to loop at the table and then give the write statement.

This will help u.

Regards;

Sapna

Read only

Former Member
0 Likes
777

Hi,

Modify ur code as follows

TYPES: BEGIN OF eket_obj,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge TYPE i,

wemng TYPE i,

objednane TYPE i,

END OF eket_obj.

DATA: l_eket_obj TYPE eket_obj OCCURS 0 WITH HEADER LINE.

SELECT werks ekpomatnr eketmenge eket~wemng

FROM ekko

JOIN ekpo ON ekkoebeln = ekpoebeln

JOIN eket ON ekkoebeln = eketebeln

AND ekpoebelp = eketebelp

JOIN mara ON maramatnr = ekpomatnr

INTO l_eket_obj

WHERE ekkoloekz = '' AND ekpoloekz = ''

AND eketmenge > eketwemng

AND werks between 1000 and 1003

AND mara~mtart = 'HAWA'

GROUP by werks ekpomatnr eketmenge eket~wemng.

l_eket_obj-objednane = l_eket_obj-menge - l_eket_obj-wemng.

<b>Append l_eket_obj.</b>

endselect.

<b>Loop at l_eket_obj.</b>

write l_eket_obj.

<b>endloop.</b>

<b>Changes are in Bold.</b>

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>