2023 Nov 24 12:35 PM
Hi, gurus,
I have requirement where I have multiple KSCHL (condition types) in bset table.
I have written the select query with the required condition types as below.
You can see in the above image that multiple kschl we have used in select query.
You can see in the below we are using multiple read tables as below.
Now i have to READ it with each KSCHL which is taken alot of space. I want to get all the
values of ktosl in single read table.
I am expecting something like this.
READ TABLE lt_bset INTO ls_bset WITH KEY bukrs = ls_bseg-bukrs
belnr = ls_bseg-belnr
gjahr = ls_bseg-gjahr
kschl = 'JICR' and kschl = 'JISR 'and kschl = 'JICN'
txgrp = ls_bseg-txgrp.
is it possible ?
or let me know if there is any way so that I can use only one read table.
The following is the select query of bset table.
2023 Nov 24 1:26 PM
In programming theory, your request would lead to nothing found:
kschl = 'JICR' and kschl = 'JIsR' and kschl = 'JIcn'
You should ask:
kschl = 'JICR' or kschl = 'JIsR' or kschl = 'JIcn'
2023 Nov 24 1:28 PM
If your question is about performance (if I understand well "taken alot of space"), you should better say it and not asking how to do something that you think would solve the issue. See XY problem - Wikipedia.
2023 Nov 27 4:11 AM
Add all the condition types in a range table and use it in SELECT WHERE clause(KSCHL in lr_kschl).
Note: The range itab can not be used in READ but you can LOOP the itab and use it in WHERE clause.
LOOP it_bset into ls_bset WHERE ..."othet conditions
KSCHL in lr_kschl.
....calculations
ENDLOOP.
2023 Nov 27 3:25 PM
You can create a nested table.
First take all key fields and add an additional column as table of KSCHL.
t_kschl type table of ....
select ...
into table @data(lt_data)
loop at lt_data into wa_data.
read table lth_nested assigning field-symbol(<wa_nested>)
from corresponding #(wa_data).
if sy-subrc is not initial.
insert corresponding #(wa_data) into table lth_nested assigning <wa_nested>.
endif.
insert wa_data-kschl into table <wa_nested>-t_kschl.
endloop.
read table lth_nested assigning <wa_nested> with table key ...
check sy-subrc is initial.
loop at <wa_nested>-t_kschl into ....
endloop.