Класс для преобразования наборов (SET - транзакция gs01) в range

Выкладываю класс который позволяет преобразовать набор (SET создаваемый через транзакцию gs01) в range.

Пример использования:

  1. *** Определяем новый RANGE
  2. data:lr_bwasl type range of bwasl.
  3.  
  4. *** Метод для чтения набора в RANGE
  5. call method zcl_set_tools=>get_set_to_range
  6. exporting
  7. im_setname = 'SET_TS'
  8. changing
  9. ch_range = lr_bwasl.
  1. class ZCL_SET_TOOLS definition
  2. public
  3. final
  4. create public .
  5.  
  6. public section.
  7.  
  8. class-methods GET_SET_TO_RANGE
  9. importing
  10. !IM_SETNAME type C
  11. changing
  12. !CH_RANGE type TABLE .
  13. protected section.
  14. private section.
  15.  
  16.  
  17.  
  18. CLASS ZCL_SET_TOOLS IMPLEMENTATION.
  19.  
  20.  
  21. * <SIGNATURE>---------------------------------------------------------------------------------------+
  22. * | Static Public Method ZCL_SET_TOOLS=>GET_SET_TO_RANGE
  23. * +-------------------------------------------------------------------------------------------------+
  24. * | [--->] IM_SETNAME TYPE C
  25. * | [<-->] CH_RANGE TYPE TABLE
  26. * +--------------------------------------------------------------------------------------</SIGNATURE>
  27. method get_set_to_range.
  28.  
  29. data: l_new_setid type sethier-setid,
  30. lt_set_values type table of rgsb4,
  31. lr_ref type ref to data.
  32.  
  33. field-symbols: <l_set_values> type rgsb4,
  34. <l_range> type any,
  35. <l_sign> type any,
  36. <l_option> type any,
  37. <l_low> type any,
  38. <l_high> type any.
  39. *---------------------------------------------------------------------
  40.  
  41. create data lr_ref like line of ch_range.
  42. assign lr_ref->* to <l_range>.
  43. check sy-subrc = 0.
  44. assign component 'SIGN' of structure <l_range> to <l_sign>.
  45. check sy-subrc = 0.
  46. assign component 'OPTION' of structure <l_range> to <l_option>.
  47. check sy-subrc = 0.
  48. assign component 'LOW' of structure <l_range> to <l_low>.
  49. check sy-subrc = 0.
  50. assign component 'HIGH' of structure <l_range> to <l_high>.
  51. check sy-subrc = 0.
  52.  
  53. call function 'G_SET_GET_ID_FROM_NAME'
  54. exporting
  55. shortname = im_setname
  56. importing
  57. new_setid = l_new_setid
  58. exceptions
  59. no_set_found = 1
  60. no_set_picked_from_popup = 2
  61. wrong_class = 3
  62. wrong_subclass = 4
  63. table_field_not_found = 5
  64. fields_dont_match = 6
  65. set_is_empty = 7
  66. formula_in_set = 8
  67. set_is_dynamic = 9
  68. others = 10.
  69.  
  70. check sy-subrc eq 0.
  71.  
  72. call function 'G_SET_GET_ALL_VALUES'
  73. exporting
  74. setnr = l_new_setid
  75. set_values = lt_set_values
  76. exceptions
  77. set_not_found = 1
  78. others = 2.
  79.  
  80. check sy-subrc eq 0.
  81.  
  82. loop at lt_set_values assigning <l_set_values>.
  83. clear: <l_sign>, <l_low>, <l_option>, <l_high>.
  84. <l_sign> = 'I'.
  85. <l_low> = <l_set_values>-from.
  86. if <l_set_values>-from eq <l_set_values>-to.
  87. <l_option> = 'EQ'.
  88. <l_option> = 'BT'.
  89. <l_high> = <l_set_values>-to.
  90. read table ch_range with key table_line = <l_range> binary search transporting no fields.
  91. check sy-subrc <> 0.
  92. insert <l_range> into ch_range index sy-tabix.

Комментарии