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

Store Variable

Former Member
0 Likes
505

HI all

i've one internal table in that table one field like vendor name,

for example

Begin of ittab_ven,

venname like lif1-lifnr,

end of ittab_ven.

in that table've 10 or 15 fields based one my queries,

i want to store each vendor in each variable

for example

loop at ittab_ven

vendor1 (variable1) = ittab_ven

vendor2 (variable1) = ittab_ven

endloop.

how can i do that

anybody help pls

3 REPLIES 3
Read only

aris_hidalgo
Contributor
0 Likes
462

Hi Muthu,

You can do it this way:

data: lv_tabix type sy-tabix,

lv_vendor1 type lfa1-lifnr,

lv_vendor2 type lfa1-lifnr,

lv_vendor3 type lfa1-lifnr,

lv_vendor4 type lfa1-lifnr,

lv_vendor5 type lfa1-lifnr,

lv_vendor6 type lfa1-lifnr,

lv_vendor7 type lfa1-lifnr,

lv_vendor8 type lfa1-lifnr,

lv_vendor9 type lfa1-lifnr,

lv_vendor10 type lfa1-lifnr.

loop at ittab_ven,

lv_tabix = sy-tabix.

case lv_tabix.

when 1.

move ittab_ven-vendor to lv_vendor1.

when 2.

move ittab_ven-vendor to lv_vendor2.

when 3.

move ittab_ven-vendor to lv_vendor3.

when 4.

move ittab_ven-vendor to lv_vendor4.

when 5.

move ittab_ven-vendor to lv_vendor5.

when 6.

move ittab_ven-vendor to lv_vendor6.

when 7.

move ittab_ven-vendor to lv_vendor7.

when 8.

move ittab_ven-vendor to lv_vendor8.

when 9.

move ittab_ven-vendor to lv_vendor9.

when 10.

move ittab_ven-vendor to lv_vendor10.

endcase.

endloop.

Hope this helps...

P.S. Please award points if found useful.

Read only

0 Likes
462

You can probably use a field-symbol.

I do not have a system available, so I am guessing at the syntax.

field-symbols: <f1>.
data: lv_num(2)     type n,
      lv_field(20)  type c.

loop at ittab_ven.
  lv_num = sy-tabix.
  clear lv_field.
  concatenate lv_field lv_num into lv_field.
  condense lv_field no-gaps.
  assign lv_field to <f1>.
  <f1> = ittab_ven-lifnr.
endloop.

Read only

0 Likes
462

I think Norman's idea is the best way. I think this syntax is correct but it's still Norman's solution (and Viraylab's data definitions).

field-symbols: <f1>.

data: lv_num(2) type n,

lv_field(20) type c.

data:

lv_vendor1 type lfa1-lifnr,

lv_vendor2 type lfa1-lifnr,

lv_vendor3 type lfa1-lifnr,

lv_vendor4 type lfa1-lifnr,

lv_vendor5 type lfa1-lifnr,

lv_vendor6 type lfa1-lifnr,

lv_vendor7 type lfa1-lifnr,

lv_vendor8 type lfa1-lifnr,

lv_vendor9 type lfa1-lifnr,

lv_vendor10 type lfa1-lifnr.

loop at ittab_ven.

lv_num = sy-tabix.

clear lv_field.

concatenate 'LV_VENDOR' lv_num into lv_field.

condense lv_field no-gaps.

assign (lv_field) to <f1>.

<f1> = ittab_ven-lifnr.

endloop.

ps, it will cause problems if there are more entries in the table than defined lv_vendor fields.