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

Calling Method with Importing-Parameter "SelectOptions Range-Table" as TYPE any table???

Former Member
1,666

Hi at all,

i have a Dynpro with a Select-Options "S_VBELN" and "S_DATE" and iam trying to call a Method "CONVERT_RANGE" with Importing-Parameter IT_TABLE = S_VBELN and IT_SELOPT_DATE = S_DATE, but it doesnt work.

When iam calling the "dynamic Method" with "S_VBELN" than i got always a Error-Message from Syntax-Check: S_VBELN is not Type-compatible to "IT_TABLE"!!!

I hope anyone can help me with this dynamic Importing-Parameters!
Thanks in forward.

Kind Regards
ETN

---------------------------------------------REPORT--------------------------------------------------

DATA: lt_selopt TYPE RSDSSELOPT_T.

SELECT-OPTIONS: s_vbeln TYPE vbeln,
s_date TYPE sy-datum.

lt_selopt_vbeln = convert_range( it_table = s_vbeln ).

lt_selopt_date = convert_range( it_table = s_date ).

----------------------------------------------METHOD-------------------------------------------------
*// IT_TABLE TYPE ANY TABLE
*// RT_SELOPT TYPE RSDSSELOPT_T

*& data declaration
DATA: ls_selopt TYPE rsdsselopt,
lo_dynamic_line TYPE REF TO data,
lo_dynamic_table TYPE REF TO data,
lo_struct TYPE REF TO cl_abap_structdescr.

FIELD-SYMBOLS: <lt_table> TYPE table,
<ls_table> TYPE any,
<fs_comp> TYPE abap_compdescr,
<lv_value> TYPE any,
<lv_selopt> TYPE any.

CREATE DATA lo_dynamic_table LIKE it_table.
ASSIGN lo_dynamic_table->* TO <lt_table>.

CREATE DATA lo_dynamic_line LIKE LINE OF <lt_table>.
ASSIGN lo_dynamic_line->* TO <ls_table>.

APPEND LINES OF it_table TO <lt_table>.

* Populate the fields of wa_pc_model_data2
lo_struct ?= cl_abap_typedescr=>describe_by_data( <ls_table> ).

IF lo_struct IS BOUND AND lo_struct IS NOT INITIAL.
LOOP AT <lt_table> INTO <ls_table>.
CLEAR ls_selopt.

LOOP AT lo_struct->components INTO <fs_comp>
WHERE name EQ 'SIGN'
OR name EQ 'OPTION'
OR name EQ 'LOW'
OR name EQ 'HIGH'.

ASSIGN COMPONENT <fs_comp>-name OF STRUCTURE <ls_table> TO <lv_value>.
ASSIGN COMPONENT <fs_comp>-name OF STRUCTURE ls_selopt TO <lv_selopt>.
<lv_selopt> = <lv_value>.
ENDLOOP.

IF ls_selopt IS NOT INITIAL.
APPEND ls_selopt TO rt_selopt.
ENDIF.
ENDLOOP.
ENDIF.

1 ACCEPTED SOLUTION
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
1,361

Is it as simple as follows?

Selection tables have infamous header lines. You pass the header lines and not the table body. Append [] to the names and it should be fine!

4 REPLIES 4
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
1,362

Is it as simple as follows?

Selection tables have infamous header lines. You pass the header lines and not the table body. Append [] to the names and it should be fine!

Read only

matt
Active Contributor
1,361

It is as simple as that.

Read only

former_member210008
Active Participant
1,361

It's a bit offtopic but if I correctly understand your logic you can replace all your code with just one line of code:

lt_selopt_vbeln = corresponding #( s_vbeln[] ).

Read only

0 Likes
1,361

Hello Evgeniy,

thanks you too, your Answer is also correct.
My Solution is a bit offtopic, but the Problem was, that i forgot, that Select-Options has "Header-Lines"!!!

Kind Regards
ETN