10-31-2012 7:41 AM
hi,
i am doing simple report using oops concept.
REPORT ztest.
TABLES:kna1.
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS: getdata IMPORTING kunnr type kna1-kunnr,
displaydata.
PROTECTED SECTION.
types:BEGIN OF ta_data,
kunnr type kunnr,
END OF ta_data.
data:it_data type STANDARD TABLE OF ta_data,
wa_data type ta_data.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD getdata.
select kunnr from kna1 into TABLE it_data WHERE kunnr eq kunnr.
endmethod.
METHOD displaydata.
loop at it_data into wa_data.
write😕 wa_data-kunnr.
ENDLOOP.
endmethod.
ENDCLASS.
data:o type REF TO c1.
START-OF-SELECTION.
BREAK-POINT.
PARAMETERS : kunnr type kunnr.
CREATE OBJECT o.
call METHOD o->getdata
EXPORTING
kunnr = kunnr .
o->displaydata( ).
my dought is how we can use SELECT-OPTION IN place of PARAMETERS,
thanks,
Mohan.
Moderator message: very basic -> question status removed.
Message was edited by: Thomas Zloch
10-31-2012 7:46 AM
Use....
Tables VTTK.
SELECT-OPTIONS: s_shtyp FOR vttk-shtyp NO-EXTENSION NO INTERVALS.
<removed by moderator>
Message was edited by: Thomas Zloch
10-31-2012 8:16 AM
Another Heads up for you is that.
In OO Context Tables with Header line is not possible.
So you can use like this.
Data : S_KUNNR Type Range Of KNA1-KUNNR. Work area you need to declare it seperately.
Hope this Helps...
10-31-2012 8:30 AM
Yes you can, but redefine the SELECT-OPTIONS to be allowed in class, code could look like
*----------------------------------------------------------------------*
* CLASS c1 DEFINITION
*----------------------------------------------------------------------*
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS: getdata IMPORTING so_kunnr TYPE range_kunnr_tab, " CHANGED
displaydata.
PROTECTED SECTION.
TYPES:BEGIN OF ta_data,
kunnr TYPE kunnr,
END OF ta_data.
DATA:it_data TYPE STANDARD TABLE OF ta_data,
wa_data TYPE ta_data.
ENDCLASS. "c1 DEFINITION
TABLES:kna1.
DATA:o TYPE REF TO c1.
*----------------------------------------------------------------------*
* CLASS c1 IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS c1 IMPLEMENTATION.
METHOD getdata.
SELECT kunnr FROM kna1 INTO TABLE it_data WHERE kunnr IN so_kunnr. " CHANGED
ENDMETHOD. "getdata
METHOD displaydata.
LOOP AT it_data INTO wa_data.
WRITE:/ wa_data-kunnr.
ENDLOOP.
ENDMETHOD. "displaydata
ENDCLASS. "c1 IMPLEMENTATION
SELECT-OPTIONS so_kunnr FOR kna1-kunnr. " CHANGED
START-OF-SELECTION.
BREAK-POINT.
CREATE OBJECT o.
CALL METHOD o->getdata
EXPORTING
so_kunnr = so_kunnr[]. " CHANGED
o->displaydata( ).
Regards,
Raymond
10-31-2012 9:12 AM
Thanx Raymond,
and one more thinng i am doing the same from vbrp table with vbeln field that time same not working and is there any change need to do and please tell how i can bcz i am new for oops concept.
METHODS: getdata IMPORTING so_vbeln TYPE range_vbeln_tab,
it showing error like 'range_vbeln_tab' is type is unknown
thanks,
Mohan.
10-31-2012 10:21 AM
Hiii,
just double click on RANGE_KUNNR_TAB you can find it is globally available in DD
For range_vbeln_tab you can also make your own in DD zrange_vbeln_tab or locally in program you can define it as -
ranges : range_vbeln_tab for vbak-vbeln.
or
types : begin of ty_range_vbeln_tab,
sign type ddsign,
option type ddoption,
low type vbeln,
high type vbeln,
end of ty_range_vbeln_tab.
data : range_vbeln_tab type standard table of ty_range_vbeln_tab.
methods :getdata_vbeln importing so_vbeln like range_vbeln_tab.
define implementation also
10-31-2012 10:29 AM
another option to create range table.
http://help.sap.com/saphelp_erp60_sp/helpdata/en/00/958fb7e42b11d295f700a0c929b3c3/content.htm
10-31-2012 10:40 AM
First look via SE11 where-used on data element for table type, try to identify a range table type.
When none is found, you could create your own, but many currently used fields have a table of range already defined. (NB: You should find one for EBELN)
Regards,
Raymond
10-31-2012 11:17 AM
Good now you are able to find sap online help before post ... see sap demo* examples , F1 , abapdocu and old thread