Select option in global class
Hi,
I want to add one data dictionary field as select option in a global class. I am trying to declare as table type. But i missed out something and it is not working. Could anybody help me out in this.
Regards,
Krishna.
Hello Krishna
You may have a look at table type RSELOPTION (line type RSDSSELOPT).
Alternatively, you can use a trick to "import" select-options for a selection screen into your class:
How to pass a select-options to a class method
Passing select-options value in method
Regards
Uwe
Similar Messages
-
SELECT-OPTIONS in global class definitions
I'd like to 'type' selection ranges inside a global class created with SE24.
For example:
The data element PRODH_D (Product hierarchy) has no range structure or range table in SE11.
Before I go to the trouble of defining the structure and table type in SE11, I'd like to define them in my global class and then use the 'type' for selection parameters.
For example:
types: begin of ty_kunnr_select,
sign(1) type c,
option(2) type c,
low type kunnr,
high type kunnr,
end of ty_kunnr_select.
data: st_kunnr_range type ty_kunnr_select.
data: ta_kunnr_range type standard table of ty_kunnr_select.
I've tried entering the code in multiple areas of the global class. I can get the code to compile just fine. But, when I try to use the type with a parameter definition of a method it won't compile.
Does anyone know how to do this?Hi,
Create a TYPE-POOL and store in it your global fields. At your "Properties" screen(SE24) add your type pool. Then you can use your types.
If you find the answers helpful, please assign reward points.
Svetlin
Message was edited by: Svetlin Rusev -
Best practice for selection-screen in global classes
Hello everyone,
I have build several selection screens (overall 150+ select options / parameters) some time ago and want to reuse some of them within a global class encapsulating a ALV grid. Is there an easy way to forward the values of a selection screen into my class?
I have thought of a function module (in the function group which contains the dynpros) to extract the values. Is this a state-of-the-art approach?
Thanks in advance,
AlejHi Uwe,
correct me if I'm wrong: I remember RS_REFRESH_FROM_SELECTOPTIONS not doing the job perfectly, what ever it was, maybe
'RS_REFRESH_FROM_SELECTOPTIONS' reads only the main selection screen of a report; it will not give you SELECTION-SCREEN BEGIN OF SCREEN ... contents.
At least it is good for extracting the names of all SELECT-OPTIONS and PARAMETERS. Then use a dynamic assign like
data:
lv_assign type string
field-symbols:
<selopt> type table.
CONCATENATE '('IM_CALLING_PROGRAM')' SELNAME INTO lv_assign.
assign (lv_assign) to <selopt>.
This not only enables you to use but also to modify the select-options on the screen as you want or need.
I know since 10 or more years SAP warns to use the dynamic ASSIGN. But it works perfectly and will probably never be changed.
Regards,
Clemens -
Passing select-options table to a class method
Hi,
I have to pass a table which contains a select-options to a class method as a param...
How I do this??
DATA s_mail TYPE z_mail_rng.
o_mail->add_receiver( ? ).
(add_receiver's formal param is TYPE ANY)
Plese give me help.
Thanks.Hi,
I send coding for how to use select-options in class.
May it is useful for u
tables:marc.
selection-screen begin of block b1 with frame title text-001.
select-options: s_matnr for marc-matnr.
selection-screen end of block b1.
class c3 definition.
public section.
types: begin of ty_marc,
matnr type marc-matnr,
werks type marc-werks,
end of ty_marc.
data: wa_itab type ty_marc.
data: itab type table of ty_marc .
data: wa_matnr type r_matnr.
methods: add.
private section.
*methods: sub.
endclass.
class c3 implementation.
method add .
select matnr
werks
from marc into table itab where matnr IN s_matnr.
write:/ 'material no', 20 'plant'.
loop at itab into wa_itab.
write:/ wa_itab-matnr,
wa_itab-werks.
endloop.
endmethod .
endclass.
start-of-selection.
data b1 type ref to c3.
create object b1 .
call method b1->add. -
[PERSISTENCE CLASS] SELECT OPTION in WHERE statement
Hi Gurus,
I would like to know how could I code the WHERE statement with a SELECT OPTION, in Persistence Class ?
Currenlty, I would like to code this kind of request :
DELETE FROM ziTab
WHERE zdate IN so_date.
Do you know, how could I code it ?
Many thx for helps.
Best regards.
Rachid.Sorry Glen,
Unfortunately, I am trying to find the correct syntax to use a SELECT OPTION in a Query Request of Persistence Class:
Something like that:
SELECT-OPTIONS so_date FOR sy-datum .
DATA lo_query_manager TYPE REF TO if_os_query_manager .
DATA lo_query TYPE REF TO if_os_query .
DATA lo_agent TYPE REF TO zca_persistence_zint_rsbankinv.
DATA lo_base TYPE REF TO zcb_persistence_zint_rsbankinv.
DATA lo_rsbankinv TYPE REF TO zcl_persistence_zint_rsbankinv.
DATA lo_table TYPE osreftab .
DATA ls_table TYPE REF TO zcl_persistence_zint_rsbankinv.
DATA ls_tmp TYPE REF TO object .
DATA lv_string TYPE string .
DATA lo_exception TYPE REF TO cx_root .
TRY .
lo_agent = zca_persistence_zint_rsbankinv=>agent.
* Create Query
lo_query_manager = cl_os_system=>get_query_manager( ).
lo_query = lo_query_manager->create_query( i_filter = 'ZEXDAT IN PAR1' ).
lo_table =
lo_agent->if_os_ca_persistency~get_persistent_by_query(
i_query = lo_query
i_par1 = so_date
LOOP AT lo_table INTO ls_tmp.
ls_table ?= ls_tmp .
lv_string = ls_table->zget_all_fields( ).
WRITE lv_string.
ENDLOOP.
CATCH cx_root INTO lo_exception.
lv_string = lo_exception->get_text( ).
WRITE lv_string.
ENDTRY.
But I have an error message :
Syntax error when parsing a query : Excepected symbol 'IN' (row: O, column: 7)
Any idea ? -
Hi Experts,
I've defined one parameter for company code(BUKRS) & one select option for valuation class (BWKEY) in my selection screen.
If I select any comp code in the parmeter, then in F4 help for valuation class should show only valuation class assigned to that comp code.
It can derived from table T001k .
Could anybody help in this issue?
Points for Sure.
Thanks,
Ponraj.s.Hi,
Check the below code.
tables: t001k.
For Identification Number
DATA: BEGIN OF it_bwkey OCCURS 0,
bwkey LIKE t001k-bwkey,
END OF it_bwkey.
data: v_bukrs(4).
For Run date
DATA: BEGIN OF it_bukrs OCCURS 0,
bukrs LIKE t001k-bukrs,
END OF it_bukrs.
DATA it_ret LIKE ddshretval OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN: BEGIN OF BLOCK main WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_bukrs(4) TYPE c.
SELECT-OPTIONS s_bwkey FOR t001k-bwkey NO INTERVALS.
SELECTION-SCREEN END OF BLOCK main.
Validation Section
INITIALIZATION.
SELECT DISTINCT bukrs FROM t001k INTO TABLE it_bukrs.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bukrs.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BUKRS'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_BUKRS'
value_org = 'S'
TABLES
value_tab = it_bukrs
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bwkey-low.
TABLES: t130r.
DATA: BEGIN OF dynpfields OCCURS 0. "Hilfsstruktur zum auslesen des
INCLUDE STRUCTURE dynpread. "Feldwertes vom Dynpro bei >F4<
DATA: END OF dynpfields.
DATA : sy_repid LIKE sy-repid,
sy_dynnr LIKE sy-dynnr.
CLEAR dynpfields.
REFRESH dynpfields.
dynpfields-fieldname = 'P_BUKRS'.
APPEND dynpfields.
Lesen des akt. Wertes von Dynpro
sy_repid = sy-repid.
sy_dynnr = sy-dynnr.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy_repid
dynumb = sy_dynnr
TABLES
dynpfields = dynpfields
EXCEPTIONS
OTHERS = 01.
IF sy-subrc = 0.
READ TABLE dynpfields WITH KEY fieldname = 'P_BUKRS'.
IF sy-subrc = 0.
v_bukrs = dynpfields-fieldvalue.
ENDIF.
ENDIF.
SELECT bwkey FROM t001k
INTO TABLE it_bwkey
WHERE bukrs = v_bukrs.
DELETE ADJACENT DUPLICATES FROM it_bwkey.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BWKEY'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_BWKEY'
value_org = 'S'
TABLES
value_tab = it_bwkey
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Message was edited by:
Velangini Showry Maria Kumar Bandanadham -
Passing select-options parameters type to the class
Hi All,
I am creating one class and I want to pass the select-options parameters directly to it like s_plant,s_mtart etc .
So while specifying these as paramters what type I should give them?
Rgds,
MadhuriWhatever you finally decide upon, you must have a Data Dictionary definition. So either create one for each type (bukrs, vkorg, etc.) or use a general one like RSELOPTION. However with the general one you have to put extra code in the class to convert back from a CHAR 45 field to your special field.
Anyway, using the Data Dictionary is fun! So go create as many new tables as you need. In the long term, the work you do in the Data Dictionary is never wasted and it may save you time in the future when you need that structure / table again for a different program.
Creating these structures and tables is easy if you use shortcuts. For example in local definitions in your program you can code...
data range1 type range of bukrs.
or
data wa_bukrs type bukrs.
ranges range1 for wa_bukrs.
either of these gives you the structure... no need to manually type sign, option, low, high...
What about Global (data dictionary) definitions? yes, there are also shortcuts...
start transaction SE11, enter range table name in the 'Data' field (e.g. ZMYRANGETAB), Hit Create, choose to create a Table Type... now you are on the blank new Maintain Table Type screen. enter a short text for your new table, then choose
Edit->Define as ranges table type
next enter your data element (e.g. BUKRS) under 'data element', hit Save and activate. You just created your range table without manually entering sign, option, low, high...
But wait there's more... on the same screen you can now (after saving the range table) also enter a structure name such as ZMYRANGE in the field 'structured row type'. Hit Create and you are taken to the Maintain Structure screen where the sign, option, low and high are already populated... add a short description and save and activate... you just created a workarea for your range table.
You just created a table type ZMYRANGETAB and a structure ZMYRANGE with minimal effort. -
Passing select-options to class methods
Hi,
I want to pass a select-option filled in the selection screen by the user to a method of my class. Since select-options are hold as an internal table with fields sign option low high, and passing internal tables to methods require typing, what should I write as the name of this internal table type?
For example;
select-options: so_carid for spfli-carrid.
I want to pass the contents of so_carid to my method defined in a classhI
Triggering and Handling events
At the moment of implementation, a class defines its:
Instance events (using the EVENTS statement)
Static events (using the CLASS-EVENTS statement)
Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods. Statement: METHODS
CLASS IC1_VEICHLE DEFINATION.
PUBLIC SECTION.
METHOD CONSTRUCTOR IMPORTING
EVENTS VEICHEL_CREATION.
ENDCLASS
CLASS LC1_VEICHLE IMPLIMENTATION.
METHOD CONSTRUCTOR
RAISE EVENT VEICHLE_CREATION.
REWARD IF USEFULL -
Problem in passing select-options to class meathods , type any table
<h1>how to pass type any table to class meathod</h1>
<h3>hi all
i'm trying to build class to validate the selection screen , like select-options and parameters
while writing meathod to validate the select-options
its throwing parameter mismath error</h3>
<h4>i tried like made import parameter in class meathod as 'TYPE ANY TABLE' and tried to pass select-options from my program it is saying type mismatch , how to overcome this problem </h4>
<h4>and i want to pass any select option , either of type lfa1-lifnr or mara-matnr or any other</h4>
Moderator message : Don't shout, use proper font size for explaining the question. This has been discussed in ABAP forums before. Search for available information. Thread locked.
Edited by: Vinod Kumar on Sep 14, 2011 11:20 AMhI
Triggering and Handling events
At the moment of implementation, a class defines its:
Instance events (using the EVENTS statement)
Static events (using the CLASS-EVENTS statement)
Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods. Statement: METHODS
CLASS IC1_VEICHLE DEFINATION.
PUBLIC SECTION.
METHOD CONSTRUCTOR IMPORTING
EVENTS VEICHEL_CREATION.
ENDCLASS
CLASS LC1_VEICHLE IMPLIMENTATION.
METHOD CONSTRUCTOR
RAISE EVENT VEICHLE_CREATION.
REWARD IF USEFULL -
Select options field is giving type conflict when calling a class.
hai guys,
i have a field SALESORD in subscreen as a SELECT-OPTIONS field for vbeln.
Now i created a class,with SALESDETAILS of type TABLE as a parameter of a method.
when i call the method(after creating an object) the SALESDETAILS parameter is supposed to take the SALESORD field.
but it gives me a type conflict error.
i wonder why..coz both fileds have same type..
how to resolve the issue..
helpful answers will be rewarded.
thank you.Hi Shravan,
Pass the select-options vbeln values into a temporary table and pass this table into the method.
<b>Reward for helpful answers</b>
Satish -
HOW TO PASS SELECT-OPTIONS AS IMPORT PARAMETER TO A CLASS
Hi experts,how to pass select options value as a export parameters to a zclass.
can give me some idea.
Thanks
saiAs Sachin already said, selection options are stored in an internal table. You can reconstruct the table type without the corresponding input fields using the type addition RANGE OF.
So - assuming you have the following in your program:
DATA: wa TYPE sflight.
SELECT-OPTIONS so_car FOR sflight-carrid.
you can create a publically-visible type in your class using direct type entry and the code
TYPES: my_selectoption TYPE RANGE OF sflight-carrid.
and use this to define the importing parameter of the method.
The only other thing you have to remember is that select-options generates an internal table with header line. Thereore, to pass the table to the method, you would use (in the above example) so_car[], and not just the name of the select-option.
Hope this helps.
Regards
Jon. -
Passing select-options to method of class
Hai friends,
Could u please tell me how to pass select-options as parameters to method of a class.Hi
You have to declare the select
options like
<b>DATA: l_kunnr TYPE STANDARD TABLE OF wselkunnr,</b>
see this example
*& Report ZCL_TEST_ANJI
REPORT zcl_test_anji.
TABLES kna1.
DATA: l_kunnr TYPE STANDARD TABLE OF wselkunnr,
l_kna1 TYPE STANDARD TABLE OF kna1,
l_sales TYPE STANDARD TABLE OF vbak,
l_cust TYPE kna1,
l_vbak TYPE vbak.
DATA: obj_cust TYPE REF TO zcl_test_anji.
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr.
Start of Selection
START-OF-SELECTION.
CREATE OBJECT obj_cust.
SET HANDLER obj_cust->event_handler_1 FOR obj_cust.
SET HANDLER obj_cust->event_handler_2 FOR obj_cust.
l_kunnr[] = s_kunnr[].
CALL METHOD obj_cust->zcust
EXPORTING
s_cust = l_kunnr
RECEIVING
it_kna1 = l_kna1.
IF NOT l_kna1[] IS INITIAL.
LOOP AT l_kna1 INTO l_cust.
WRITE: / l_cust-kunnr, 12 l_cust-name1,
48 l_cust-ort01, 85 l_cust-land1,
95 l_cust-pstlz.
HIDE l_cust-kunnr.
ENDLOOP.
ENDIF.
At line Selection
AT LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
CALL METHOD obj_cust->zso
EXPORTING
im_kunnr = l_cust-kunnr
RECEIVING
it_so = l_sales.
IF NOT l_sales[] IS INITIAL.
LOOP AT l_sales INTO l_vbak.
WRITE: / l_vbak-kunnr, 12 l_vbak-vbeln,
24 l_vbak-vkorg, 30 l_vbak-audat,
43 l_vbak-netwr.
ENDLOOP.
ENDIF.
ENDCASE.
<b>Reward points if useful</b>
Regards
Anji -
Select options range table to be passed to Assistance class
Hi Guru's,
I have an assistance class where I have to write all my select queries. I have a selection screen with multiple Select options (as input fields). Now I want to pass the select options range table to assistance class.
Please let me know if you have any sample code for this which may also include building range tables for select options.
Thanks,
PradeepHi Pardeep,
U can use following code: for field ERDAT
data: rt_ERDAT type ref to data,
R_ERDAT TYPE RANGE OF VIQMEL-ERDAT,
R_ERDAT_line LIKE LINE OF R_ERDAT,
field-symbols: <fs_ERDAT> type table.
Retrieve the data from the select option
rt_ERDAT = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'ERDAT' ).
Assign it to a field symbol
assign rt_ERDAT->* to <fs_ERDAT>.
copy field symbols to local variable
R_ERDAT = <fs_ERDAT>.
CALL METHOD WD_ASSIST->"METHOD_NAME"
R_ERDAT = R_ERDAT
where in class method:
R_ERDAT Importing Type ZU5QNM_ERDAT_T
ZU5QNM_ERDAT_T : is a table type of ZU5QNM_ERDAT_R
and ZU5QNM_ERDAT_R has following structure :
SIGN ACE_SIGN CHAR 1 0 Debit/Credit Sign (+/-)
OPTION ACE_OPTION CHAR 2 0 Option for Ranges Tables
LOW ERDAT DATS 8 0 Date on Which Record Was Created
HIGH ERDAT DATS 8 0 Date on Which Record Was Created
I hope this wiol solve ur problem.
Regards,
Vishal. -
Hi all,
How can I define select-options for a method in a global class.
And how can I pass these select-options from a report.
Thanks & Regards
EshwarHi all,
How can I define select-options for a method in a global class.
And how can I pass these select-options from a report.
Thanks & Regards
Eshwar -
How to give a value range in export parameter (global class)
hi all,
I have created a class-method called get_po_date. In this i had export parameter as qmfe-qmnum. If i give qmfe-qmnum in import parameter in class, i am able to give only one value at one time, but i need a range of values at a time. Instead of qmfe-qmnum in associated type, i have given 'LXHME_RANGE_C12' ( a range table for char 12 ). the thing is i wanted to select this range in select-options. but still iam getting <b>not type compatible syntax error</b>. can any body solve my problem,
feel free to ask if any confusion with my question.
Best Regards,
abhilash.Hello Abhilash
Instead of using a specific range (where field LOW and HIGH are of type QMNUM) you can use a <b>generic </b>select option (of type <b>RSDSSELOPT</b>). Have a look at the following sample report <b>ZUS_SDN_SELOPTIONS</b>.
*& Report ZUS_SDN_SELOPTIONS
REPORT zus_sdn_seloptions.
TABLES: qmfe.
DATA:
gt_data TYPE STANDARD TABLE OF qmfe,
gt_data_x TYPE STANDARD TABLE OF qmfe,
gt_selopt TYPE rseloption, " generic table type for selopts
gs_selopt TYPE rsdsselopt.
START-OF-SELECTION.
SELECT * FROM qmfe INTO TABLE gt_data
WHERE ( qmnum BETWEEN '000000000001' AND '000000000500' ).
gs_selopt-sign = 'I'.
gs_selopt-option = 'BT'.
gs_selopt-low = '000000000001'.
gs_selopt-high = '000000000500'.
APPEND gs_selopt TO gt_selopt.
SELECT * FROM qmfe INTO TABLE gt_data_x
WHERE ( qmnum IN gt_selopt ).
IF ( gt_data = gt_data_x ).
WRITE: 'Selected data are equal.'.
ELSE.
WRITE: 'Selected data are NOT equal.'.
ENDIF.
END-OF-SELECTION.
Since RSDSSELOPT and RSELOPTION are global DDIC objects they can be used in <i>public </i>methods.
Regards
Uwe
Maybe you are looking for
-
Hi, I have a new TLD domain name which does not contain the traditional /com extension. In fact my extension is just .media When attempting to put this into a form widget for example so that it links it appears that Adobe Muse does not recognise it a
-
Group Policy Management Console crashes when you click the target domain KB 2928427
I have the Problems described in KB 292827 with Riverbed Steelhead WAN Optimizer configured as Active Directory Integrated mode enabled, on a Windows Server 2012 R2. The Hotfix in KB 292827 is only for Windows 2012 and Windows 8. Is there a Hotfix f
-
Don't want downloaded photos opening at all
I know how to change the default app to open downloaded files. How do I NOT have them open at all? I'm trying to download a whole gallery of photos and it keeps interrupting to open the files in preview. I just want them saved to my downloads fold
-
I WAS USING I PHONE4 AND MY CAR KIT WAS WORKING PERFECT WITH IT VIA BLUETOOTH(RENAULT GRAND SCENIC 2011) BUT I BOUGHT THE NEW 4S AND EVENTHOUGH I CAN BE CONNECTED TO MY CAR KIT BY BLUETOOTH I CAN NOT HEAR IT ON MY CAR STREO.CAN ANYBODY HELP ME
-
ITunes 11 crashes when I open the store.
I have tried repairing, uninstalling the entire apple suite ( described in a different article on apple support website), reinstalling, opening in safe mode, changing users, changing the firewall and antivirus settings, clearing the itunes cache, upd