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 values compatibility issue

former_member295881
Contributor
0 Likes
3,953

Select Option values compatibility issue

I'm new to object oriented program in ABAP and having some compatibility issues. I’m getting some values from user via selection screen as Select-Option. But when I try to pass these select-option variables to my class constructor then I get the following error.

“S_INV” is not type-compatible with formal parameter “IM_INV”.

My understand is that Select-Option is a range table, therefore I declared a range table in my class but still keep getting the same error. Can somebody please point out what mistake I’m making and how to rectify it?

Here is my code.

TABLES: vbrk, vbrl, vbak, vbap, konv.

INCLUDE ZAD_INV_TEST_CL.

DATA: gcl_main      TYPE REF TO main.

SELECTION-SCREEN: BEGIN OF BLOCK BK2 WITH FRAME TITLE TEXT-002.
   SELECT-OPTIONS: s_inv    FOR vbrk-vbeln,
                   s_cust   FOR vbrk-kunrg,
                   s_date   FOR vbrk-erdat.
SELECTION-SCREEN: END OF BLOCK BK2.

  START-OF-SELECTION.

  CREATE OBJECT gcl_main
   EXPORTING
       im_inv  = s_inv
       im_cust = s_cust
       im_date = s_date.

*---------------- Class Starts

CLASS main DEFINITION.
   PUBLIC SECTION.
     TYPES: BEGIN OF t_range_inv,
             sign    TYPE char1,
             option  TYPE char2,
             dt_low  TYPE vbrk-vbeln,
             dt_high TYPE vbrk-vbeln,
            END OF t_range_inv,
            BEGIN OF  t_range_cust,
             sign    TYPE char1,
             option  TYPE char2,
             dt_low  TYPE kunrg,
             dt_high TYPE kunrg,
            END OF t_range_cust,
            BEGIN OF t_range_date,
             sign    TYPE char1,
             option  TYPE char2,
             dt_low  TYPE erdat,
             dt_high TYPE erdat,
            END OF t_range_date,

            tt_inv     TYPE TABLE OF t_range_inv  INITIAL SIZE 0,
            tt_cust    TYPE TABLE OF t_range_cust INITIAL SIZE 0,
            tt_date    TYPE TABLE OF t_range_date INITIAL SIZE 0.

     DATA: "variables to hold constructor values
           gv_inv    TYPE TABLE OF t_range_inv,
           gv_cust   TYPE TABLE OF t_range_cust,
           gv_date   TYPE TABLE OF t_range_date.


     METHODS: constructor IMPORTING im_inv   TYPE tt_inv
                                    im_cust  TYPE tt_cust
                                    im_date  TYPE tt_date.

ENDCLASS.


CLASS main IMPLEMENTATION.

METHOD constructor.
   gv_inv  = im_inv.
   gv_cust = im_cust.
   gv_date = im_date.

     IF gv_inv  IS NOT INITIAL
    AND gv_cust IS NOT INITIAL
    AND gv_date IS NOT INITIAL.
       MESSAGE 'It works.' TYPE 'S'.
     ELSE.
       MESSAGE 'Please provide Invoice Information to process.' TYPE 'I'.
     ENDIF.
ENDMETHOD.
ENDCLASS.

*---------------- Class Ends

Many thanks in advance.

1 ACCEPTED SOLUTION
Read only

guilherme_frisoni
Contributor
0 Likes
3,147

Hi,

Maybe the problem is with SO header line.

Try to use [] like this:

CREATE OBJECT gcl_main

   EXPORTING

       im_inv  = s_inv[]

       im_cust = s_cust[]

       im_date = s_date[].

Regards,

Guilherme Frisoni

2 REPLIES 2
Read only

guilherme_frisoni
Contributor
0 Likes
3,148

Hi,

Maybe the problem is with SO header line.

Try to use [] like this:

CREATE OBJECT gcl_main

   EXPORTING

       im_inv  = s_inv[]

       im_cust = s_cust[]

       im_date = s_date[].

Regards,

Guilherme Frisoni

Read only

0 Likes
3,147

Many thanks Guilherme indeed that was the problem.