Application Development 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: 

Restructure internal table and populate into database table

Former Member
0 Kudos

Hi,

I have some

Account Entity Category period1value pd2value

10 A C 100 200

Now I need to populate it into database table having structure

Account Entity Category period Value

10 A C 1 100

10 A C 2 200

that means instead of having values of all the periods in the same row we insert a column period in the database table which means we denormalize the table and new rows are created for each entry.

Pleadse help

Ankit

3 REPLIES 3

Former Member
0 Kudos

Hello Ankit,

Perhaps you could try something like this:

(Please forgive the sytnax errors)

I am assuming that you will only produce 2 lines per each in the original table as per your example.

Account Entity Category period Value

10 A C 1 100

10 A C 2 200


data: itab1 type itab1type
        itab2 type itab2type.

loop at itab1 into wa1.
  wa2-acct = wa-acct. 
  wa2-entity = wa-entity
  wa2-category = wa-category
  wa2-period = 1.
  wa2-value = wa-period1value
  append wa2 to itab2.
  wa2-period = 2
  wa2-value = wa-period2value.
  append wa2 to itab2
endloop.

Regards

Greg Kern

0 Kudos

Hi Kern,

Thanks a lot for the help.

can you please tell me

data: itab1 type itab1type

itab2 type itab2type.

loop at itab1 into wa1.

wa2-acct = wa-acct.

wa2-entity = wa-entity

wa2-category = wa-category

wa2-period = 1.

wa2-value = wa-period1value

append wa2 to itab2.

wa2-period = 2

wa2-value = wa-period2value.

append wa2 to itab2

endloop.

what are u taking wa2 as?

Ankit

0 Kudos

Hello

wa2 will have the same structure as a line of itab2.

Regards

Greg Kern