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

Передача range как параметра в Perform


Goto page Previous  1, 2
 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Mania4e11o
Участник
Участник


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Sat Feb 11, 2012 2:26 am    Post subject: Reply with quote

Сергей wrote:
Мне нужно любой range нужно передать, потому что в качестве второго параметра нужно передать имя set, а он может быть любым.


Вот сделал. Резвитесь Smile Smile

Code:
REPORT  z_convert_set_to_range.

*----------------------------------------------------------------------*
*       CLASS cl_convert DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_convert_set_to_range DEFINITION ABSTRACT.
  PUBLIC SECTION.
    CLASS-METHODS convert
    IMPORTING
      value(set) TYPE char30
    EXPORTING
      it_range TYPE INDEX TABLE.
ENDCLASS.                    "cl_convert DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_convert IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_convert_set_to_range IMPLEMENTATION .
  METHOD convert.
    DATA: gt_set_values TYPE TABLE OF rgsb4,
          range_temp TYPE RANGE OF char24,
          ls_range_main LIKE LINE OF range_temp.

    FIELD-SYMBOLS <ls_rgsb4>        TYPE rgsb4.
    FIELD-SYMBOLS <ls_range>        TYPE ANY .
    FIELD-SYMBOLS <ls_range_low>    TYPE ANY.
    FIELD-SYMBOLS <ls_range_high>   TYPE ANY.
    FIELD-SYMBOLS <ls_range_option> TYPE ANY.
    FIELD-SYMBOLS <ls_range_sign>   TYPE ANY.

    CALL FUNCTION 'G_SET_GET_ALL_VALUES'
      EXPORTING
        setnr      = set
        class      = '0000'
      TABLES
        set_values = gt_set_values.

    LOOP AT gt_set_values ASSIGNING <ls_rgsb4>.
      APPEND INITIAL LINE TO it_range ASSIGNING <ls_range>.
      ASSIGN COMPONENT 'LOW'    OF STRUCTURE <ls_range>  TO <ls_range_low>.
      ASSIGN COMPONENT 'HIGH'   OF STRUCTURE <ls_range>  TO <ls_range_high>.
      ASSIGN COMPONENT 'OPTION' OF STRUCTURE <ls_range>  TO <ls_range_option>.
      ASSIGN COMPONENT 'SIGN'   OF STRUCTURE <ls_range>  TO <ls_range_sign>.

      <ls_range_sign> = 'I'.
      IF <ls_rgsb4>-from = <ls_rgsb4>-to.
        <ls_range_option> = 'EQ'.
        FIND '*' IN  <ls_rgsb4>-from.
        IF sy-subrc = 0.
          <ls_range_option> = 'CP'.
        ENDIF.
        FIND '+' IN  <ls_rgsb4>-from.
        IF sy-subrc = 0.
          <ls_range_option> = 'CP'.
        ENDIF.
        <ls_range_low> = <ls_rgsb4>-from.
      ELSE.
        <ls_range_option> = 'BT'.
        <ls_range_low> = <ls_rgsb4>-from .
        <ls_range_high> = <ls_rgsb4>-to.
      ENDIF.
    ENDLOOP.
  ENDMETHOD.                    "convert

ENDCLASS.                    "cl_convert IMPLEMENTATION

INITIALIZATION.
  DATA ranger TYPE RANGE OF marc-matnr.
  cl_convert_set_to_range=>convert( EXPORTING  set = 'Z_ABAPER2_SET1'  IMPORTING  it_range = ranger ).


Создай себе класс в словаре такой и радуйся))
Back to top
View user's profile Send private message Blog
Удав
Гуру
Гуру


Age: 48
Joined: 25 Jan 2008
Posts: 580
Location: Москва

PostPosted: Mon Feb 13, 2012 11:08 am    Post subject: Reply with quote

Так народ резвился 4 года назад Laughing
И it_range TYPE INDEX TABLE как то с APPEND не очень сочетается Wink

_________________
С уважением,
Удав.
Back to top
View user's profile Send private message
Mania4e11o
Участник
Участник


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Mon Feb 13, 2012 11:27 am    Post subject: Reply with quote

Удав wrote:
Так народ резвился 4 года назад Laughing
И it_range TYPE INDEX TABLE как то с APPEND не очень сочетается Wink


Что-то я не поссмотрел на дату Very Happy Very Happy

на счет append, там все легально Wink проверенно "MANIA4E11O" Very Happy
Back to top
View user's profile Send private message Blog
Удав
Гуру
Гуру


Age: 48
Joined: 25 Jan 2008
Posts: 580
Location: Москва

PostPosted: Mon Feb 13, 2012 11:58 am    Post subject: Reply with quote

Mania4e11o wrote:
на счет append, там все легально Wink проверенно "MANIA4E11O" Very Happy

Ну использовать то можно, об этом и help.sap.com пишет:
Quote:
If a generic table type with the index table access type is used as the parameter of a function module, you can pass either a sorted table or a standard table in the call.

Просто зачем писать "INDEX TABLE", если можно написать "TABLE"? Wink

_________________
С уважением,
Удав.
Back to top
View user's profile Send private message
Mania4e11o
Участник
Участник


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Mon Feb 13, 2012 8:15 pm    Post subject: Reply with quote

Удав wrote:

Просто зачем писать "INDEX TABLE", если можно написать "TABLE"? Wink


ну я это писал просто для наглядности Smile И хотелось как-то более универсально) И вообще я месяц как только начал изучать,мне можно))Но теперь я учту это))
Back to top
View user's profile Send private message Blog
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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.