1

Can somebody help me figure out if there is a way for the query below:

I have an internal table with one column with 69 records.

I want all these 69 records to be populated into a variant and get saved so that with this variant and the values saved in it I can run a particular program

How can I populate these values ?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • You don't need to ABAP for that, just create the variant via GUI and put values there. – Suncatcher Jun 01 '17 at 16:58
  • @sumegha mukherjee: Why do you want specifically the variant method? This data you are talking about is the values of a specific select-option? Why not setting dynamically at the start of the program? – szako Jun 02 '17 at 03:38
  • Just save your itab to file or to clipboard from debugger and do like knut said then. – Suncatcher Jul 18 '17 at 10:13

2 Answers2

3

Your question is a bit unclear for me.

  • Do you speak about two programs or one program?
  • What's the parameter you want to fill in the variant?

I'll just give you some hints - depending on your situation you must pick the correct parts.

I have an internal table with one column with 69 records.

How is the internal table filled?

I want all these 69 records to be populated into a variant and get saved so that with this variant and the values saved in it I can run a particular program

  • You have a program and you want to save a selection in a variant. So you need some parameters for the selection screen.
  • You want a table, so you need a SELECT-OPTION.
  • To define a SELECT-OPTION you need a DDIC-reference (you must say, what kind of field you want.). In the following example I use a material number (MARA-MATNR).

So you program contains something like:

TABLES mara.
SELECT-OPTIONS: s_matnr FOR mara-matnr.

With this you would get: enter image description here

You can define ranges (from-to) and list of values. As you want only single values, you need something like:

SELECT-OPTIONS: s_matnr FOR mara-matnr NO INTERVALS.

Now you get:

enter image description here

  • When you push (1) you can enter values.
  • With (2) you can load from an external file,
  • with (3) you can load values from clipboard.

So you can fill your values and store the selection in a variant.

When you execute your program, the data is stored in a ranges table: enter image description here

Now you can loop on this table and copy the S_MATNR-LOW value into your internal table for further processing.


If I misunderstood you question and you want to create a variant dynamically, then take a look on function module RS_VARIANT_ADD (or RS_VARIANT_COPY,RS_VARIANT_CHANGE...)

gkubed
  • 1,849
  • 3
  • 32
  • 45
knut
  • 27,320
  • 6
  • 84
  • 112
0

You could always put the values in TVARVC, either manually or via code. Then specify the TVARVC variable in the variant definition.

Bryan Cain
  • 1,736
  • 9
  • 17