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

ABAP 750 - optimizing code

SimoneMilesi
Active Contributor
0 Likes
1,081

Hi all

I have this little piece of code where I receive as input a table (WORKING_TAB) and I've to retrieve data from DB using as partial value the field KNUMA_AG of given table

This is how I managed to do it, but I totally dislike the loop - select appending part

 METHOD get_ips.
    TYPES: BEGIN OF ty_vakey,
             vakey TYPE /irm/ipbckcitm-vakey,
           END OF ty_vakey.
    TYPES: tty_vakey TYPE STANDARD TABLE OF ty_vakey WITH DEFAULT KEY.
    CLEAR ips.
    DATA(keys) = VALUE tty_vakey( FOR row IN working_tab
                                ( vakey = '%' && row-knuma_ag && '%' ) ).
    LOOP AT keys INTO DATA(key).
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE ips
                     FROM /irm/ipbckcitm
                     WHERE vakey LIKE key-vakey.
    ENDLOOP..
  ENDMETHOD.

Can you suggest a more elegant way to do it?

Thanks!

1 ACCEPTED SOLUTION
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
894

I think you can use range table for this.
Change tty_vakey to "range" structure (sign+option+low+high fields).
In VALUE fill:

sign = 'I'
option = 'CP'
low = '*' && row-knuma_ag && '*'
-- Tomas --
2 REPLIES 2
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
895

I think you can use range table for this.
Change tty_vakey to "range" structure (sign+option+low+high fields).
In VALUE fill:

sign = 'I'
option = 'CP'
low = '*' && row-knuma_ag && '*'
-- Tomas --
Read only

0 Likes
894

I'm a.... not so smart person >_<
I didn't tink about ranges!