SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Падение на большом select-options



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
stefan
Участник
Участник



Joined: 14 Feb 2008
Posts: 19

PostPosted: Mon Sep 01, 2008 11:01 am    Post subject: Падение на большом select-options Reply with quote

Здравствуйте!

Пользователь заполняет на селекционном экране поле материалы. Когда количество материалов больше 2 тыс, происходит падение в дамп. Если бы в select-options заполнялись только единичные коды материала, можно было бы разбить один длинный селект на несколько селектов. Но названия материалов могут быть заданы как интервалы, и что самое плохое, как исключающие интервалы. В последнем случае просто разбивка на несколько запросов будет работать неправильно. Потому что в первый селект может попасть материал, который должен быть исключен в последующих селектах. Как быть?
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 150
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Mon Sep 01, 2008 2:39 pm    Post subject: Reply with quote

Разбивайте на несколько селектов как обычно. К итоговой внутренней таблице примените исходный select-options. Он удалит exclude.

DELETE it_mara WHERE NOT matnr IN s_matnr.

Примерчик накидал.

Code:
TABLES: mara.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
DATA: it_mara TYPE TABLE OF mara WITH HEADER LINE.

CONSTANTS:
      c_max_size TYPE i VALUE 1000.
DATA: l_max_line TYPE i,
      l_mod      TYPE i,
      l_tabix    TYPE sy-tabix.
RANGES:
  lr_matnr FOR mara-matnr.

INITIALIZATION.
  s_matnr-sign   = 'I'.
  s_matnr-option = 'CP'.
  s_matnr-low    = '*'.
  APPEND s_matnr.

  SELECT matnr INTO mara-matnr FROM mara UP TO c_max_size ROWS.
    s_matnr-sign   = 'I'.
    s_matnr-option = 'EQ'.
    s_matnr-low    = mara-matnr.
    APPEND s_matnr.
  ENDSELECT.

  s_matnr-sign   = 'E'.
  s_matnr-option = 'CP'.
  s_matnr-low    = '*'.
  APPEND s_matnr.

START-OF-SELECTION.

  DESCRIBE TABLE s_matnr LINES l_max_line.
  REFRESH lr_matnr.

  DO.
    l_tabix = sy-index.
    READ TABLE s_matnr INDEX sy-index.
    IF sy-subrc IS INITIAL.
      lr_matnr = s_matnr.
      COLLECT lr_matnr.
    ENDIF.
    l_mod = l_tabix MOD c_max_size.
    IF l_mod EQ 0 OR l_tabix EQ l_max_line.
      SELECT * APPENDING TABLE it_mara
        FROM mara
        WHERE matnr IN lr_matnr.
      REFRESH lr_matnr.
    ENDIF.
    IF l_tabix EQ l_max_line.
      EXIT.
    ENDIF.
  ENDDO.

  DESCRIBE TABLE it_mara LINES l_max_line.
  WRITE: / 'Lines before delete', l_max_line.

  DELETE it_mara WHERE NOT matnr IN s_matnr.

  DESCRIBE TABLE it_mara LINES l_max_line.
  WRITE: / 'Lines after delete', l_max_line.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.