11-28-2003 2:22 PM
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.
11-28-2003 5: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[].
11-28-2003 7:02 PM
Thanks Dirk!
Meanwhile I got a similar answer on SAPFANS ( http://www.sapfans.com/forums/viewtopic.php?t=79918 ).
Incho
Ps: In ABAP Objects 'OCCURS' is not allowed for internal table definition.
12-01-2003 12:02 PM
Hello Incho,
you are right, but I work with an old version (3.1I) and it is the only way to create an internal table in this antique system.
Dirk
12-01-2003 2:20 PM
Thanks Dirk for clarifying this!
After reading some news about ABAP in WAS 6.40 I have the impression that I work with an old system...and my ABAP knowledge is not really up-to-date...it's R/3 46C system....so working with version 3.1I is probable quite "painful";-(((
Incho
12-02-2003 5:14 PM
If you want to create an internal table without a header line in a method use the following code:
DATA: i_tab TYPE STANDARD TABLE OF bukrs.
TYPE can be: STANDARD, SORTED OR HASHED
Also: UNIQUE, NON-UNIQUE
KEY can have , default key or, table_line
ie DATA: I_TAB TYPE STANDARD TABLE OF BUKRS
WITH UNIQUE KEY TABLE_LINE.
Hope this helps.
12-03-2003 11:06 AM
12-01-2003 7: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.
12-02-2003 5:07 PM
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.
....