‎2008 May 16 3:37 PM
Hi Guys,
I need a small help from you. I want to know how to populate the value from select-option to abap object. Please help me, it is very important
‎2008 May 16 3:52 PM
Can you please elaborate a bit when you say you want to pass value to ABAP object ?
Is it that you want to pass the value to some attibutes or method of the ABAP object or what exactly you want to achive.
regards,
Advait.
‎2008 May 16 4:07 PM
Hello.
What kind of ABAP object? I'll show 2 ways to populate into a generic variable VAR.
Remember s_option is an internal table with structure:
SIGN
OPTION
LOW
HIGH
SELECT-OPTIONS: s_option FOR dbtab-matnr.
READ TABLE s_option INDEX 1.
VAR = s_option-low.
LOOP AT s_option.
VAR = s_option-low.
ENDLOOP.
Best regards.
Valter Oliveira.
‎2008 May 16 4:04 PM
Hi,
in for select-option , one structure will be created with the name of Select-Option field.
In that structure, you hav 2 fields:
LOW and HIGH.
so, when you are creation the object,
Pass these to fields to the CONSTRUCTOR.
I hope, you understood.
Regards
Sandeep Reddy
‎2008 May 16 11:38 PM
Hi Justin
Analyse the code below. After end of method save_kunnr_range the select-option from selection screen will be in object public variable kunnr_range. Note that table creted by statment SELECT-OPTION have a header line and note, that OO-ABAP don't use tables with header line.
JS
*&---------------------------------------------------------------------*
*& Report Z_KUNN_RANGE
*&
*&---------------------------------------------------------------------*
REPORT Z_KUNN_RANGE.
*---------------------------------------------------------------------*
* CLASS cl_kunnr DEFINITION
*---------------------------------------------------------------------*
CLASS cl_kunnr DEFINITION.
public section.
data:
kunnr_range type trgr_kunnr.
methods:
save_kunnr_range importing kunnr_rg type trgr_kunnr.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS cl_kunnr IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS cl_kunnr IMPLEMENTATION.
method save_kunnr_range.
kunnr_range[] = kunnr_rg[].
endmethod.
ENDCLASS.
*---------------------------------------------------------------------*
* selection screen
*---------------------------------------------------------------------*
data:
a_kunnr type kunnr,
customers type ref to cl_kunnr.
selection-screen begin of block bl01 with frame title text-001.
select-options i_kunnr for a_kunnr.
selection-screen end of block bl01.
start-of-selection.
create object customers.
customers->save_kunnr_range( i_kunnr[] ).
‎2008 May 17 5:14 AM
check this code
REPORT ZSELOPT_TO_CLASS .
TABLES: VBRK.
SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN.
DATA: IT_VBELN TYPE RSELOPTION.
DATA: X_VBELN TYPE RSDSSELOPT.
CLASS C1 DEFINITION.
PUBLIC SECTION.
DATA: IT_VBRP TYPE VBRP_TAB,
X_VBRP LIKE LINE OF IT_VBRP.
METHODS: GET_DATA IMPORTING S_VBELN TYPE RSELOPTION.
METHODS: DISP_DATA.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD GET_DATA.
*SELECT * FROM VBRP*
INTO TABLE IT_VBRP
WHERE VBELN IN S_VBELN.
ENDMETHOD.
METHOD DISP_DATA.
LOOP AT IT_VBRP INTO X_VBRP.
WRITE:/ X_VBRP-VBELN,
X_VBRP-POSNR.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA OBJ TYPE REF TO ZCL_SELOPT.
CREATE OBJECT OBJ.
LOOP AT S_VBELN.
MOVE S_VBELN-LOW TO X_VBELN-LOW.
MOVE S_VBELN-HIGH TO X_VBELN-HIGH.
MOVE S_VBELN-SIGN TO X_VBELN-SIGN.
MOVE S_VBELN-OPTION TO X_VBELN-OPTION.
APPEND X_VBELN TO IT_VBELN.
ENDLOOP.
CALL METHOD OBJ->GET_DATA
EXPORTING
S_VBELN = IT_VBELN.
CALL METHOD OBJ->DISP_DATA.
Edited by: moazam hai on May 17, 2008 6:17 AM
Edited by: moazam hai on May 17, 2008 6:19 AM