Application Development 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: 

Doubt about abap dynamic with performs.

ronaldo_aparecido
Contributor
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

11 REPLIES 11

Former Member
0 Kudos

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

0 Kudos

Hi Max.

Thanks for the reply.

How could I use the select statament to select the datbi most current?

Thanks for help.

0 Kudos

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

0 Kudos

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.

0 Kudos

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

PeterJonker
Active Contributor
0 Kudos

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.

0 Kudos

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.

0 Kudos

Yes offcourse it is possible. You can use in your where statement something like

where datbi > sy-datum and datab <= sy-datum.

0 Kudos

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.

0 Kudos

Probably you need only a semi-dynamic selection, because the table with data (princes) is KONP

Max

0 Kudos

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