Skip to Content

Using select-options table as method parameter

How it is possible to use a select-options table as a method parameter?

Select-options table is an internal table with header line, but defining parameter with header line is not possible.

Is there a way to implement this?

Thanks in advance,

Incho

My code:

...

SELECT-OPTIONS:

so_vbeln FOR wa_vbakp-vbeln MEMORY ID aun

MATCHCODE OBJECT vmva,

so_kunnr FOR wa_vbakp-kunnr MEMORY ID vag

MATCHCODE OBJECT debi,

so_matnr FOR wa_vbakp-matnr MEMORY ID mat,

so_auart FOR wa_vbakp-auart MEMORY ID aat.

...

CLASS-METHODS:

fill_it_vbakp

IMPORTING

i_vbeln LIKE so_vbeln

i_kunnr LIKE so_kunnr

i_matnr LIKE so_matnr

i_auart LIKE so_auart

i_erdat LIKE so_erdat

i_bstdk LIKE so_bstdk

i_vkorg LIKE so_vkorg

i_vtweg LIKE so_vtweg

i_spart LIKE so_spart

RETURNING

value(r_it_vbakp) TYPE ty_t_vbakp.

....

METHOD fill_it_vbakp.

DATA: r_wa_vbakp TYPE ty_s_vbakp.

SELECT kvbeln kkunnr kerdat kbstdk k~bstnk

kvkorg kvtweg k~spart

pposnr pmatnr p~arktx

pnetwr pwaerk pkwmeng pvrkme

FROM vbak AS k INNER JOIN vbap AS p

ON kvbeln = pvbeln

INTO CORRESPONDING FIELDS OF TABLE r_it_vbakp

WHERE k~vbeln IN so_vbeln

AND k~kunnr IN so_kunnr

AND k~auart IN so_auart

AND k~erdat IN so_erdat

AND k~bstdk IN so_bstdk

AND k~vkorg IN so_vkorg

AND k~vtweg IN so_vtweg

AND k~spart IN so_spart

AND p~matnr IN so_matnr.

.......

So in the method I use so_* which are globals, so they are available within the method, but I would like to use i_* parameters somehow.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Nov 28, 2003 at 05:22 PM

    Hi Peter,

    create an internal table like the select-options table without headerline. Then move the values in your new table whitout headerline e. g.:

    tables: bkpf.

    select-options so_bukrs for bkpf-bukrs.

    data: it_bukrs like so_bukrs occurs 0.

    it_bukrs[] = so_bukrs[].

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 01, 2003 at 07:28 PM

    You can still create ranges in the OO context. Just use the following syntax:

    DATA rangetab TYPE|LIKE RANGE OF ...

    I usually create a table type with sign, option, low and high for my importing paramater. I then copy the importing parameter into an OO Range using l_param[] = i_param[] and use the local OO Range in my select statement.

    Add a comment
    10|10000 characters needed characters exceeded

    • Thanks Thomas!

      I got the same answer in SAP fans. It worked fine, but I had to transfer the data from the select-options to the ranges.

      After another tip from SAPFans I just defined the import parameters reference to the body of the select-option. Now I don't have to transfer the values, and it can be implemented with less coding.

      It works fine now......

      So, my code is the following now:

      *----


      *

      * CLASS lcl_vbakp DEFINITION

      *----


      *

      CLASS lcl_vbakp DEFINITION.

      PUBLIC SECTION.

      CLASS-METHODS:

      fill_it_vbakp

      IMPORTING

      i_vbeln LIKE so_vbeln[]

      i_kunnr LIKE so_kunnr[]

      i_matnr LIKE so_matnr[]

      i_auart LIKE so_auart[]

      i_erdat LIKE so_erdat[]

      i_bstdk LIKE so_bstdk[]

      i_vkorg LIKE so_vkorg[]

      i_vtweg LIKE so_vtweg[]

      i_spart LIKE so_spart[]

      RETURNING

      value(r_it_vbakp) TYPE ty_t_vbakp.

      ENDCLASS.

      *----


      *

      * CLASS lcl_vbakp IMPLEMENTATION

      *----


      *

      CLASS lcl_vbakp IMPLEMENTATION.

      METHOD fill_it_vbakp.

      DATA: r_wa_vbakp TYPE ty_s_vbakp.

      SELECT kvbeln kkunnr kerdat kbstdk k~bstnk

      kvkorg kvtweg kspart kauart

      pposnr pmatnr p~arktx

      pnetwr pwaerk pkwmeng pvrkme

      FROM vbak AS k INNER JOIN vbap AS p

      ON kvbeln = pvbeln

      INTO CORRESPONDING FIELDS OF TABLE r_it_vbakp

      WHERE k~vbeln IN i_vbeln

      AND k~kunnr IN i_kunnr

      AND k~auart IN i_auart

      AND k~erdat IN i_erdat

      AND k~bstdk IN i_bstdk

      AND k~vkorg IN i_vkorg

      AND k~vtweg IN i_vtweg

      AND k~spart IN i_spart

      AND p~matnr IN i_matnr

      AND ( kvbtyp = 'C' OR kvbtyp = 'I' ). "SD document category

      ....

      ENDMETHOD.

      ENDCLASS.

      ....

      *eject

      *&----

      -


      *& Event START-OF-SELECTION

      *&----

      -


      START-OF-SELECTION.

      CALL METHOD lcl_vbakp=>fill_it_vbakp

      EXPORTING

      i_vbeln = so_vbeln[]

      i_kunnr = so_kunnr[]

      i_matnr = so_matnr[]

      i_auart = so_auart[]

      i_erdat = so_erdat[]

      i_bstdk = so_bstdk[]

      i_vkorg = so_vkorg[]

      i_vtweg = so_vtweg[]

      i_spart = so_spart[]

      RECEIVING

      r_it_vbakp = it_vbakp.

      ....

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.