This website is not affiliated with, sponsored by, or approved by SAP AG.

select-options database table structure

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

select-options database table structure

Postby sapmanie » Thu Mar 23, 2017 1:48 pm

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
sapmanie
 
Posts: 481
Joined: Fri Jan 23, 2004 10:39 am

Re: select-options database table structure

Postby Gothmog » Fri Mar 24, 2017 11:05 am

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
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: select-options database table structure

Postby sapmanie » Sun Mar 26, 2017 10:34 am

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
sapmanie
 
Posts: 481
Joined: Fri Jan 23, 2004 10:39 am

Re: select-options database table structure

Postby SBeirne » Wed Mar 29, 2017 9:34 am

You could just dump the contents to a cluster table (such as INDX) via EXPORT TO DATABASE.
SBeirne
 
Posts: 4
Joined: Fri Feb 04, 2005 7:33 am
Location: UK


Return to ABAP

Who is online

Users browsing this forum: No registered users and 6 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.