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

getting data into internal table as per our format

Former Member
0 Likes
1,052

Hi friends plz go through my requirement and provide me a solution for it.

data :

wa_t343j type t343j.

start-of-selection.

select single *

into wa_t343j

from t343j

WHERE lgnum = 'XYZ' and

lgtyp = 'ABC'.

In the work area wa_t343j iam getting the following values

lgnum lgtyp ste01 ste02 ste03 st304 ste05 ste06 ste07 ste08

XYZ ABC 5 3 1 2 4

now my requiremnt is i want this value in a sepearte internal table in the below format.

data :

begin of it_temp,

index type i,

field type ltap-vlpla,

value type ltap-vlpla,

end of it_temp.

Internal table it_temp

Index field value

1 LGNUM XYZ

2 LGTYP ABC

3 STE01 5

4 STE02

9 STE07 4

10 STE08

i need those values in this format.

Thanks in advance,

Regards,

Kumar.

Edited by: satish abap on Aug 12, 2008 8:59 PM

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,004

Do something like this..

Types : begin of tt_temp,
        index type i,
        field type char30,
        value type char30,
        end of tt_temp.

data: it_temp type table of tt_temp.
data: wa_temp like line of it_temp.

data: it_fieldlist type table of rstrucinfo.
data: wa_fieldlist like line of it_fieldlist.

data: lv_repid type sy-repid.

FIELD-SYMBOLS: <fs> type any.

lv_repid = sy-repid.

call function 'GET_COMPONENT_LIST'
     exporting
          program    = lv_repid
          fieldname  = 'wa_t343j'
     tables
          components = it_fieldlist.

Loop at it_fieldlist into wa_fieldlist.
  clear wa_temp.
    wa_temp-index = sy-tabix.
    wa_temp-field = wa_fieldlist-compname.
    assign COMPONENT wa_temp-field  of STRUCTURE wa_t343j to <fs>.
    wa_temp-value = <fs>.
    append wa_temp to it_temp.
endloop.

Regards,

Rich Heilman

7 REPLIES 7
Read only

Former Member
0 Likes
1,004

Have you tried reading directly into the new internal table with the INTO CORRESPONDING FIELDS OF TABLE statement?

Read only

Former Member
0 Likes
1,004

try out...

read table (workarea) itab1

it1-field1 = 1.

it1-field2 = 'lgnum'.

it1-field3 = itab1-lgnum.

append it1.

do this for all fields....

Read only

Former Member
0 Likes
1,004

Hi,

try this...

in your work area you have the data.

take the first field

count = count + 1.

MOVE count to it_temp-index.

MOVe 'LGNUM' to it_temp-field.

MOVe wa_t343j-lgnum to it_temp-value.

append it_temp.

clear: it_temp.

do the same thing for all the fields.

Regards,

Venkatesh.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,005

Do something like this..

Types : begin of tt_temp,
        index type i,
        field type char30,
        value type char30,
        end of tt_temp.

data: it_temp type table of tt_temp.
data: wa_temp like line of it_temp.

data: it_fieldlist type table of rstrucinfo.
data: wa_fieldlist like line of it_fieldlist.

data: lv_repid type sy-repid.

FIELD-SYMBOLS: <fs> type any.

lv_repid = sy-repid.

call function 'GET_COMPONENT_LIST'
     exporting
          program    = lv_repid
          fieldname  = 'wa_t343j'
     tables
          components = it_fieldlist.

Loop at it_fieldlist into wa_fieldlist.
  clear wa_temp.
    wa_temp-index = sy-tabix.
    wa_temp-field = wa_fieldlist-compname.
    assign COMPONENT wa_temp-field  of STRUCTURE wa_t343j to <fs>.
    wa_temp-value = <fs>.
    append wa_temp to it_temp.
endloop.

Regards,

Rich Heilman

Read only

0 Likes
1,004

Thanks

Rich Heilman .

with your valuable code iam able to move forward in solving my clients requirement.

Regards,

Satish.

Read only

0 Likes
1,004

Very good. Please make sure to mark this thread as answered/solved. Thanks!!

Regards,

Rich Heilman

Read only

0 Likes
1,004

ok sure Rich.

I have just posted one more question regardind looping T_QMAT internal table of LT03 transcation.

Just go through it and plz provide a solution for it Rich.