09-10-2007 4:28 PM
Hello friends,
I am writing a code. My select-option is as follows:
SELECT-OPTIONS: P_LIFNR FOR LFA1-LIFNR
,P_BUKRS FOR LFB1-BUKRS .
Constructor definition ia as follows:
METHODS:
CONSTRUCTOR
IMPORTING VALUE(I_LIFNR) TYPE LFA1-LIFNR
VALUE(I_BUKRS) TYPE LFB1-BUKRS "Buchungskreis auslesen
Now as I creat my object.
data obj type ref to class
START-OF-SELECTION.
CREATE OBJECT OBJ EXPORTING I_LIFNR = P_LIFNR.
I_BUKRS = P_BUKRS.
END-OF-SELECTION.
I am having problem because of Range type.
Message is; I_LIFNR is not type compatable with P_LIFNR. I guess this is becuase of the Range (Select-option). Using parameters: .... Solves the problem but I dont want to use parameters for my input. So how do can I solve this problem.
Blacky
09-10-2007 9:05 PM
Hello Blacky
If you want to create an instance for each vendor within the select-option range then I would suggest the following approach:
1. Define a <b>static </b>CREATE method (e.g. of your vendor class) which takes the select-option itab as IMPORTING parameter and which return an itab with instances of your vendor class.
2. Within the CREATE method you select all vendors with your range and create all vendor instances that are collected and returned in an itab, e.g.:
METHOD create.
* define local data
DATA:
lo_vendor TYPE REF TO zcl_my_vendor_class,
ls_lfa1 TYPE lfa1,
lt_lfa1 TYPE STANDARD TABLE OF lfa1.
SELECT * FROM lfa1 INTO TABLE lt_lfa1
WHERE bukrs = id_bukrs " IMPORTING parameter
AND lifnr IN it_lifnr. " e.g. TYPE RANGE OF lifnr
LOOP AT lt_lfa1 INTO ls_lfa1.
CREATE OBJECT lo_vendor
EXPORTING
id_bukrs = ls_lfa1-bukrs
id_vendor = ls_lfa1-lifnr.
APPEND lo_vendor TO rt_instances. " table type of REF TO zcl_my_vendor_class
ENDLOOP.
" NOTE: rt_instances is returned from method CREATE
ENDMETHOD.
Regards
Uwe
09-10-2007 4:37 PM
I advice you to split your Select-option ( low/sign/option/high ) if u want to exploit it.
Use something like this :
CREATE OBJECT OBJ EXPORTING I_LIFNR-<b>LOW</b> = P_LIFNR.
Hope this helps,
Erwan
09-10-2007 4:49 PM
hI LE,
PLEASE help me with the spliting too, so that I can use the whole range.
09-10-2007 9:05 PM
Hello Blacky
If you want to create an instance for each vendor within the select-option range then I would suggest the following approach:
1. Define a <b>static </b>CREATE method (e.g. of your vendor class) which takes the select-option itab as IMPORTING parameter and which return an itab with instances of your vendor class.
2. Within the CREATE method you select all vendors with your range and create all vendor instances that are collected and returned in an itab, e.g.:
METHOD create.
* define local data
DATA:
lo_vendor TYPE REF TO zcl_my_vendor_class,
ls_lfa1 TYPE lfa1,
lt_lfa1 TYPE STANDARD TABLE OF lfa1.
SELECT * FROM lfa1 INTO TABLE lt_lfa1
WHERE bukrs = id_bukrs " IMPORTING parameter
AND lifnr IN it_lifnr. " e.g. TYPE RANGE OF lifnr
LOOP AT lt_lfa1 INTO ls_lfa1.
CREATE OBJECT lo_vendor
EXPORTING
id_bukrs = ls_lfa1-bukrs
id_vendor = ls_lfa1-lifnr.
APPEND lo_vendor TO rt_instances. " table type of REF TO zcl_my_vendor_class
ENDLOOP.
" NOTE: rt_instances is returned from method CREATE
ENDMETHOD.
Regards
Uwe
09-11-2007 4:43 AM
Hello ,
Even if you create a dynpro by yourself, the <b>SELECT-OPTIONS / PARAMETERS</b> are key words that will work only on a SELECTION SCREEN of a report program or declare the screen as a selection screen.
You can indirectly bind select-options and parameters to a method. Please have a look at the CONSTRUCTOR method of class <b>CL_DBSEL_CATS</b>. The method has a parameter<b> IM_CALLING_PROGRAM</b> which represents a "normal" report with selection screen. If this parameter is filled then the instance will read the selection criteria using function module <b>RS_REFRESH_FROM_SELECTOPTIONS</b>.
This is a very elegant approach to import selection criteria into class methods.
Reward Points if it is usefull ....
Girish
09-11-2007 8:36 AM
Hi,
we pass if required the select options tables to our method as TYPE STANDARD TABLE.
SELECT * FROM vbak INTO TABLE itab
WHERE vbeln IN i_vbeln_so.
The importing parameter i_vbeln_so is defined with the type STANDARD TABLE.
Regards,
Gianpietro