‎2008 May 23 2:19 PM
Hi,
I have some data in an internal table which is structured as :
Account Entity Category value period1 value pd2
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 1 100
i.e. if there are 12 periods they should correspond to 12 columns in database table.
How do I do this
Thanks
Ankit
‎2008 May 23 2:29 PM
pseudo code for 12 periods:
loop at internal table.
do 12 times varying var_value from value_period1 next value_period2.
fill account, entity, category, period (from sy-index) and value (from var_value).
insert new db table entry.
enddo.
endloop.
Greetings
Thomas
‎2008 May 23 2:33 PM
You need to be more clear, I cant really see a logic in the internal table.
Why does the period gets repeated in the database table? Do you see you are using repeated entries, and violating one of the principles of relational databases?
I guees you meant
10 A C 1 100
10 A C 2 200
‎2008 May 23 2:36 PM
write as :
loop at itab.
do 12 times <-- corresponds to 12 columns in internal table.
varying val_period FROM itab-period1
NEXT itab-period2.
Insert into your table ..
if not val_period is initial.
move-corresponding itab to <table>.
<table>-period Value = val_period.
insert <table>.
endif.
enddo.
endloop.
‎2008 May 23 2:45 PM
‎2008 May 23 3:12 PM
Hi ramiro,
I am a BW consultant and need to poulate this data in the format which is suitable for upload to BW.Thats why the repeated entries.
Hi Mr A,
Account Entity Category value period1 value pd2
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.
Thanks 4 the help.
Ankit