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

Problem with Table updation

Former Member
0 Likes
669

Hi,

I have the following requirement

I have a table with two columns “Amount” and “Quantity”

Amount Quantity

0 34

4 76

7 30

5 52

Here is the requirement—

When there is “0” in “Amount” column in FIRST record, then I have to update “Amount “ field by replacing index 1 value of Amount wthl index2 value of Amount

Index 2 value with Index 3 value etc…and fill index n value with 9.99. And“Quantity” should remain the same.

Output should look like this.

Amount Quantity

4 34

7 76

5 30

9.99 52

Can anyone help me on this. Thanks in advance.

-Padma

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
641

hi ,

please check this following coding ..

REPORT Z0322_UPGRATE.

data : begin of wa_sample,

amount type i,

quantity type i,

end of wa_sample.

data : s type i.

data : it_sample like table of wa_sample with header line,

it_sample1 like table of wa_sample with header line.

it_sample-amount = 0.

it_sample-quantity = 34.

append it_sample.

it_sample-amount = 4.

it_sample-quantity = 76.

append it_sample.

it_sample-amount = 7.

it_sample-quantity = 30.

append it_sample.

it_sample-amount = 5.

it_sample-quantity = 52.

append it_sample.

loop at it_sample.

write : / it_sample-amount , it_sample-quantity.

endloop.

write /: 'AFTER '.

loop at it_sample.

if sy-tabix <> 1.

it_sample1-amount = it_sample-amount.

it_sample1-quantity = s.

append it_sample1.

endif.

s = it_sample-quantity.

endloop.

loop at it_sample1.

write : / it_sample1-amount , it_sample1-quantity.

endloop.

send me if u get any error.

thanks,

baskaran.

4 REPLIES 4
Read only

Former Member
0 Likes
641

Columns are not displayed with right space justification.

Actual table:

Amount Field contains

0

4

7

5

Output for Amound field should be

4

7

5

9.99

Actual Quantity Field values: should remain the same in the output as well

34

76

30

52

Thanks,

Padma

Read only

0 Likes
641

if say itab contains fields-amt and quan and ur itab has the values which u said-

data: itab2 like itab..

data: gv_quan.

clear gv_quan.

loop at itab.

if gv_quan is not initial.

itab2-amt = itab-amt.

itab2-quan = gv_quan.

append itab2.

clear gv_quan.

endif.

if itab-amt eq 0.

gv_quan = itab-quan.

continue.

endif.

endloop.

now ur itab2 will have the format u required..

hope this helps

Read only

Former Member
0 Likes
642

hi ,

please check this following coding ..

REPORT Z0322_UPGRATE.

data : begin of wa_sample,

amount type i,

quantity type i,

end of wa_sample.

data : s type i.

data : it_sample like table of wa_sample with header line,

it_sample1 like table of wa_sample with header line.

it_sample-amount = 0.

it_sample-quantity = 34.

append it_sample.

it_sample-amount = 4.

it_sample-quantity = 76.

append it_sample.

it_sample-amount = 7.

it_sample-quantity = 30.

append it_sample.

it_sample-amount = 5.

it_sample-quantity = 52.

append it_sample.

loop at it_sample.

write : / it_sample-amount , it_sample-quantity.

endloop.

write /: 'AFTER '.

loop at it_sample.

if sy-tabix <> 1.

it_sample1-amount = it_sample-amount.

it_sample1-quantity = s.

append it_sample1.

endif.

s = it_sample-quantity.

endloop.

loop at it_sample1.

write : / it_sample1-amount , it_sample1-quantity.

endloop.

send me if u get any error.

thanks,

baskaran.

Read only

0 Likes
641

Thanks a lot Bhaskaran. It worked.