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

Restructure internal table and populate into database table

Former Member
0 Likes
654

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
Read only

Former Member
0 Likes
551

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

Read only

0 Likes
551

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

Read only

0 Likes
551

Hello

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

Regards

Greg Kern