Skip to Content
author's profile photo Former Member
Former Member

ranges and select-options at creating object (export value)

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 10, 2007 at 06:46 PM

    Try this.

    
    
    report zrich_0002 .
    
    
    tables: lfa1, lfb1.
    
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_app DEFINITION
    *---------------------------------------------------------------------*
    *       ........                                                      *
    *---------------------------------------------------------------------*
    class lcl_app definition.
    
      public section.
    
        types: t_lifnr type range of lfa1-lifnr.
        types: t_bukrs type range of lfb1-bukrs.
    
        methods:
             constructor
                   importing im_lifnr type t_lifnr
                             im_bukrs type t_bukrs.
    
    
    endclass.
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_app IMPLEMENTATION
    *---------------------------------------------------------------------*
    *       ........                                                      *
    *---------------------------------------------------------------------*
    class lcl_app implementation.
    
      method constructor.
    
        data: x_lifnr like line of im_lifnr,
              x_bukrs like line of im_bukrs.
    
        loop at im_lifnr into x_lifnr.
          write:/ x_lifnr-sign, x_lifnr-option, x_lifnr-low, x_lifnr-high.
        endloop.
    
        loop at im_bukrs into x_bukrs.
          write:/ x_bukrs-sign, x_bukrs-option, x_bukrs-low, x_bukrs-high.
        endloop.
    
      endmethod.
    
    endclass.
    
    
    select-options: s_lifnr for lfa1-lifnr,
                    s_bukrs for lfb1-bukrs .
    
    data: obj type ref to lcl_app.
    
    
    start-of-selection.
    
      create object obj exporting im_lifnr = s_lifnr[]
                                  im_bukrs = s_bukrs[].
    
    
    end-of-selection.
    
    

    Regards,

    RIch Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 10, 2007 at 07:56 PM

    Hello Blacky

    If you have just a <u>single </u>select-option you can define an IMPORTING parameter (e.g. IT_SELOPT) of table type <b>RSELOPTION</b>. This table type has RSDSSELOPT (<i>Structure of generic SELECT-OPTION for (dynamic selections)</i>) as line type.

    However, if you have <u>multiple </u>select-options (and parameters as well) then the easiest (and probably most elegant) way is to use function module RS_REFRESH_FROM_SELECTOPTIONS.

    In the CONSTRUCTOR method of your class you add an EXPORTING parameter IM_CALLING_PROGRAM.

    Within the CONSTRUCTOR method you call the function module with the value of the calling program (which is your selection report). The function module returns you all current selection criteria of the report. Within the constructor method you can do the mapping of <b>RSPARAMS </b>values to your actual select-options and parameters.

    Have a look at class <b>CL_DBSEL_CATS</b> for a SAP standard example.

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.