Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select-option in ABAP objects

Former Member
0 Likes
2,285

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,109

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.

Read only

0 Likes
1,109

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.

Read only

Former Member
0 Likes
1,109

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

Read only

Former Member
0 Likes
1,109

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[] ).

Read only

Former Member
0 Likes
1,109

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