08-29-2014 2:58 PM
Good Morning Gurus.
1-I have the tables of price in internal table ( t_a530 , T_a951 ... etc ).
2- I need filter data by field datbi and datab.
3-Can I create a perform to pass a table and after pass other table with other format to taht same perform ?
4-It abap dynamic.
5-II do not want to create several performs because I can make only one (with my logic to all tables)
Can you help me?
Thanks.
08-29-2014 3:06 PM
Hi
Yes you can but it can't create WHERE conditions dynamically, it can do it for SELECT statament not for a LOOP.
So you could have problem for the performance, because you should use a CHECK statament into the loop instead of WHERE
Max
08-29-2014 3:06 PM
Hi
Yes you can but it can't create WHERE conditions dynamically, it can do it for SELECT statament not for a LOOP.
So you could have problem for the performance, because you should use a CHECK statament into the loop instead of WHERE
Max
08-29-2014 3:38 PM
Hi Max.
Thanks for the reply.
How could I use the select statament to select the datbi most current?
Thanks for help.
08-29-2014 4:08 PM
Hi
If I understand you need to do a check of table of condition record and then if it's valid get the value,
now the values are in KONP table and you need to get the condition record KNUMH
As you've written the field DATBI and DATAB are in all tables you need to check
So if you don't need to use other fields for your selection, you can do something like this:
types: begin of ty_cond_key,
knumh type konp-knumh,
end of ty_cond_key.
types: ty_t_cond_key type table of ty_cond_key.
data: t_konp type standard table of konp with header line.
perform read_konp using 'A901'.
describe table t_konp lines sy-tabix.
write: 'A901', sy-tabix.
perform read_konp using 'A904'.
describe table t_konp lines sy-tabix.
write: / 'A904', sy-tabix.
perform read_konp using 'A906'.
describe table t_konp lines sy-tabix.
write: / 'A906', sy-tabix.
perform read_konp using 'A907'.
describe table t_konp lines sy-tabix.
write: / 'A907', sy-tabix.
Where the form is:
form read_konp using seq_tab.
data: t_cond_key type ty_t_cond_key.
free t_konp.
select knumh into table t_cond_key
from (seq_tab)
where DATBI => sy-datum
and DATAB <= sy-datum.
check sy-subrc = 0.
select * into table t_konp
from konp
for all entries in t_cond_key
where knumh = t_cond_key-knumh.
endform. "READ_KONP
As I said before the solution is based on the fields DATBI, DATAB and KNUMH exist in all tables I need to read
Max
08-29-2014 4:27 PM
The program is already doing this except:
where DATBI => sy-datum
and DATAB <= sy-datum.
in my program is:
where DATBI => sy-datum
if I change it then dont select duplicate matnrs?
because today my problem is it:
He slects all before sy-datum then if the material has 3 entries he show all.
And I need the most current only.
08-29-2014 4:46 PM
Hi
n my program is:
where DATBI => sy-datum
That depends on which period you need to select, if you want to get the condition valid today (or current day) the query should consider DATAB (from data) too.
if I change it then dont select duplicate matnrs?
No because the key is only the condition record KNUMH and it's unique
He slects all before sy-datum then if the material has 3 entries he show all.
And I need the most current only.
That means:
- or the material has 3 different prices, because perhaps there are several price lists
- or you've selected invalid price, if you don't consider DATAB you could select price no longer valid
Max
08-29-2014 3:41 PM
You can crate the perform with changing parameter of type any table, maybe also send a using parameter of type any in which you send the work area of the table (does not need to be filled).
In the perform you can then check which fields are in the structure with:
cl_abap_structdescr.
08-29-2014 3:47 PM
Hi Peter Jonker .
Thanks i created a logic to that perform.
But i wll study that cl_abap_structdescr. thanks.
But i was speaking with Max about filter the most current datbi in select statament.
Its possible ?, if yes I dont need create that perform with logic for it.
Thanks for help.
08-29-2014 3:53 PM
Yes offcourse it is possible. You can use in your where statement something like
where datbi > sy-datum and datab <= sy-datum.
08-29-2014 4:08 PM
ok
datbi is the end of validy
datab is the begin of validity
where datbi > 29.08.2014 and datab <= 29.08.2014
But , if the last date that register price was 01.07.2014 to 20.07.2014.
where datbi (20.07.2014 ) > 29.08.2014 and datab( 01.07.2014 ) <= 29.08.2014
ok datab is <= sy-datum but datbi don´t .
Do you Understand?
Thanks.
08-29-2014 4:11 PM
Probably you need only a semi-dynamic selection, because the table with data (princes) is KONP
Max
08-30-2014 9:46 AM
In that case you need to select all entries(maybe except for those entries that have datab > sy-datum) and sort them by key and date then delete adjacent duplicates.
To find the key you can use the descriptive classes in ABAP see:
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=42965