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

Passing range to Form, Function Module, Class



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Oct 06, 2007 1:36 am    Post subject: Passing range to Form, Function Module, Class Reply with quote

1.
Declare a global table and use it has reference in form
that is in top include or before include statement

git_matnr type ranges of matnr.
form send_data tables lit_tab like git_matnr.

Code:
*declared globally
lit_switchnum    TYPE RANGE OF eideswtdoc-switchnum.....
 
 PERFORM f4000_switchdoc_summary TABLES
*                                        lit_swtch_sum
                                         lit_swt_mprn_det
                                         lit_lt_act_date
                                         s_crdate
                                         s_swtdoc
 
FORM f4000_switchdoc_summary
                      TABLES
                             yt_swt_mprn_det STRUCTURE ls_swt_mprn_det
                             yt_lt_act_date  STRUCTURE ls_lt_act_date
                             xt_crdate       LIKE      lit_create_date
                             xt_swtdoc       LIKE      lit_switchnum


2.
types: tt_data type table of ty_data,
data: i_data type tt_data.
RANGES: r_data FOR vbap-matnr.
...
perform send_data using i_data
changing r_data.
...
...
form send_data using pi_data type tt_data
changing pr_data type ???????

3.
Code:
REPORT YRT_TEST4.

data: r_range type range of matnr.

perform test changing r_range.
*&---------------------------------------------------------------------*
*& Form test
*&---------------------------------------------------------------------*
form test changing p_r_range like r_range.

endform. " test


4.
1. we have to use TABLES (and not using)

2. like this.

...
...
form send_data
tables mytable structure i_data
using pi_data type tt_data

where i_data should be a data variable declared
3. eg.

report abc.
tables : mara.
ranges : myrange for mara-matnr.
PERFORM ABC TABLES MYRANGE.
FORM ABC TABLES RG STRUCTURE MYRANGE.
ENDFORM.

5.
1. If we pass using LIKE,

p_r_range like r_range

then the whole data of range
(range is nothing but an internal table)


WILL NOT BE PASSED
to the subroutine.

(syntax would be ok, no problem in that)

2. if we want to pass the FULL RANGE AND ITS DATA,
we should pass using TABLES only.

6.
Pass select-option value to the subroutine.
Code:
REPORT ZTESTRT .

tables: mara.
select-options s_matnr for mara-matnr no-display.

perform example1 tables s_matnr.
*&---------------------------------------------------------------------*
*& Form example1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_S_MATNR text
*----------------------------------------------------------------------*
FORM example1 TABLES P_S_MATNR STRUCTURE S_MATNR

ENDFORM. " example1


Как передать range параметром в метод класса?
7.
Code:
types: my_rtype type range of matnr
SELECT-OPTIONS p_matnr FOR matnr.
CALL METHOD myobj->my_method
EXPORTING
    matnr = p_matnr[]
matnr = p_matnr


8.
При создании глобального класса через SE24 используйте тип TABLE,
либо оставляйте поля typing и associated type пустыми.
Code:

CLASS myobj DEFINITION.
...
METHODS:
  my_method IMPORTING im_range TYPE ANY TABLE,
...
ENDCLASS.

CLASS myobj IMPLEMENTATION.

METHOD my_method.
...
  SELECT * FROM tab
           WHERE matnr in im_range.
...
ENDMETHOD.

ENDCLASS.

SELECT-OPTIONS p_matnr FOR matnr.
CALL METHOD myobj->my_method
     EXPORTING  matnr = p_matnr[].


9.
Создать дополнительный типа в словаре не как таблицу, а именно таблицу диапазона:
"Тип данных - Создать - Тип таблицы - Обработать - Определить как тип таблицы диапазонов"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования 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.