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

Adding data in internal table using extracted data

Former Member
0 Likes
483

Hi Experts,

Good day!

I have a requirements in our historical data of material price which adding data that are not existing based on data extracted from standard tables such as A004 and KONP.

Now, i need to use the VALIDFROM (DATAB) value as basis for the latest price.

To make it more clear, see the example below:

Extracted data:

Material Number Valid From Valid to Price

100101 01/01/2008 02/01/2008 100.00

100101 02/02/2008 04/02/2008 100.00

100101 04/03/2008 08/01/2008 200.00

100101 08/02/2008 01/31/2009 300.00

100102 05/02/2008 07/01/2008 10.00

100102 07/02/2008 10/31/2008 15.00

100102 11/01/2008 01/31/2009 20.00

Output:

Material Number Calmonth Price

100101 01/2008 100.00

100101 02/2008 100.00

100101 03/2008 100.00

100101 04/2008 200.00

100101 05/2008 200.00

100101 06/2008 200.00

100101 07/2008 200.00

100101 08/2008 300.00

100101 09/2008 300.00

100101 10/2008 300.00

100101 11/2008 300.00

100101 12/2008 300.00

100101 01/2009 300.00

100102 05/2008 10.00

100102 06/2008 10.00

100102 07/2008 15.00

100102 08/2008 15.00

100102 09/2008 15.00

100102 10/2008 15.00

100102 11/2008 20.00

100102 12/2008 20.00

100102 01/2009 20.00

Text that are in bold are the added data. What is the best code to do with this?

How can i come up with this output? Help me please

Thanks and Godbless,

nips

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
461

Hi Nips,

Logic shud b sumthing on similar lines

lv_count = 1.

Loop at itab into watab.

if lv_count > 12.
lv_count = 1.
endif.

if watab-date+0(2) = lv_count.
append watab to gt_output.
continue.
else.
concatenate lv_count sy-datum+4(4) into watab-date.
append watab to gt_output.
endif.

endloop.

Best regards,

Prashant

2 REPLIES 2
Read only

Former Member
0 Likes
462

Hi Nips,

Logic shud b sumthing on similar lines

lv_count = 1.

Loop at itab into watab.

if lv_count > 12.
lv_count = 1.
endif.

if watab-date+0(2) = lv_count.
append watab to gt_output.
continue.
else.
concatenate lv_count sy-datum+4(4) into watab-date.
append watab to gt_output.
endif.

endloop.

Best regards,

Prashant

Read only

0 Likes
461

Thanks Prashant