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

Better solution for filter data

Former Member
0 Likes
861

Dear All,

I'm working on a case to generate a report it works but very slow. I post part of the code about the data select part, could any one give me a hand make it better?

All datas selected in method get_ekko. In method get_ekko I need to select the ebeln that b~vstat NE 1, and In method get_nast I need select ebeln that vstat = 1. If these two ebeln is same then remove the record from at_ekko.

When I try run it in Q it takes very long time to run coz the get_nast go throw whole nast . Is there any better way to write the code to make it faster and more effective.

Many thanks in advance!

Regards,

Lynn

  METHOD get_nast.
    SELECT nast~objky nast~vstat  " obj key
    INTO CORRESPONDING FIELDS OF TABLE at_nast
    FROM nast
    WHERE  vstat EQ 1.
  ENDMETHOD.                    
  METHOD get_ekko.
    SELECT b~objky   " obj key
           b~vstat   " process status
           a~ebeln   " Purchase doc
           a~bukrs   " Company Code
           a~bsart   " document type
           a~ernam   " created by
           a~lifnr   " Vendor num
           c~loekz   " po deletion = x
           d~name1   " Vendor acc no
           a~aedat    " Create on
    INTO CORRESPONDING FIELDS OF TABLE at_ekko
    FROM ekko AS a
    INNER JOIN nast AS b
     ON  a~ebeln EQ b~objky  AND
         b~vstat NE 1
    INNER JOIN ekpo AS c
      ON a~ebeln = c~ebeln  AND
         c~loekz <> 'L'
    INNER JOIN lfa1 AS d
      ON a~lifnr = d~lifnr
    WHERE "a~bsart = 'UB' and
          a~aedat IN s_aedat AND
          a~bukrs IN s_bukrs.
    SORT at_ekko BY ebeln.
    DELETE ADJACENT DUPLICATES FROM at_ekko.  " Deleted duplicated value
  ENDMETHOD.                 


  METHOD get_data.
    FIELD-SYMBOLS: <fs_ekko> LIKE LINE OF at_ekko,
                   <fs_nast> LIKE LINE OF at_nast,
                   <fs_output> LIKE LINE OF at_output.
    DATA: lr_ebeln TYPE RANGE OF ebeln,
          ls_ebeln LIKE LINE OF lr_ebeln.
    MOVE: 'I' TO ls_ebeln-sign,
          'EQ' TO ls_ebeln-option.
    LOOP AT at_nast ASSIGNING <fs_nast>.
      MOVE <fs_nast>-objky TO ls_ebeln-low.
      APPEND ls_ebeln TO lr_ebeln.
    ENDLOOP.
    DELETE at_ekko WHERE ebeln IN lr_ebeln.


    LOOP AT at_ekko ASSIGNING <fs_ekko>.
    ENDLOOP.


  ENDMETHOD.                    "get_data

1 ACCEPTED SOLUTION
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
748

I would try it with subquery in get_ekko SELECT. Something like this:

WHERE NOT EXIST ( SELECT objky FROM nast
                    WHERE objky = a~ebeln AND
                          vstat = 1 )
-- Tomas --
2 REPLIES 2
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
749

I would try it with subquery in get_ekko SELECT. Something like this:

WHERE NOT EXIST ( SELECT objky FROM nast
                    WHERE objky = a~ebeln AND
                          vstat = 1 )
-- Tomas --
Read only

0 Likes
748

Thanks Tomas sorry about reply so late I was working in another team last month. Will try your idea hopefully it will work.

Cheers,

Lynn