Page 1 of 1

select-options database table structure

PostPosted: Thu Mar 23, 2017 1:48 pm
by sapmanie
Hi,
I would like to save a select-options structure (Sign-Option-Low-High) into a database (not internal) table. Is this possible? It's possible when using structures, because table types are allowed but with DDICs, I think not, but hoping there was some trick I've missed!

So ideally something like this:

<code>select-options: ss_mats for mara-matnr.
wa_mats-matnr = ss_mats[]. "< I want to record the values entered on the selection screen (not actually run the SELECT on it at this stage)
insert zmats from wa_mats.</code>

zmats ddic:
mandt type sy-mandt
matnr type zmats_tt

And zmats_tt would be like a ranges table on matnr.

Thanks,
sapmanie

Re: select-options database table structure

PostPosted: Fri Mar 24, 2017 11:05 am
by Gothmog
I'm afraid you'll have to do something like in table TVARVC: save the lines of the ranges and a counter.

You could use serialization/deserialization with simple transformation ID to store the table as an xml string, though.
Here is some sample code:
Code: Select all
DATA: r_mstae_from TYPE RANGE OF mara-mstae,
      r_mstae_to   TYPE RANGE OF mara-mstae,
      xml_xstring TYPE xstring.

SELECT sign opti low high FROM tvarvc INTO TABLE r_mstae_from
  WHERE name = 'MY_STATUS_LIST' AND type = 'S'.

CALL TRANSFORMATION id SOURCE r_mstae = r_mstae_from
                       RESULT XML xml_xstring.
"here you have an xml string that you can store in your table

CALL TRANSFORMATION id SOURCE XML xml_xstring
                       RESULT r_mstae = r_mstae_to.
"and you can read it in the DB table and trnasform it back to a range

Re: select-options database table structure

PostPosted: Sun Mar 26, 2017 10:34 am
by sapmanie
That's brilliant Gothmog, thanks, its put me on the right track. Thanks!
Gothmog wrote:I'm afraid you'll have to do something like in table TVARVC: save the lines of the ranges and a counter.

You could use serialization/deserialization with simple transformation ID to store the table as an xml string, though.
Here is some sample code:
Code: Select all
DATA: r_mstae_from TYPE RANGE OF mara-mstae,
      r_mstae_to   TYPE RANGE OF mara-mstae,
      xml_xstring TYPE xstring.

SELECT sign opti low high FROM tvarvc INTO TABLE r_mstae_from
  WHERE name = 'MY_STATUS_LIST' AND type = 'S'.

CALL TRANSFORMATION id SOURCE r_mstae = r_mstae_from
                       RESULT XML xml_xstring.
"here you have an xml string that you can store in your table

CALL TRANSFORMATION id SOURCE XML xml_xstring
                       RESULT r_mstae = r_mstae_to.
"and you can read it in the DB table and trnasform it back to a range

Re: select-options database table structure

PostPosted: Wed Mar 29, 2017 9:34 am
by SBeirne
You could just dump the contents to a cluster table (such as INDX) via EXPORT TO DATABASE.