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: 

calculations of Two Column and result in Other column in ALV grid

Former Member
0 Kudos
937

hi Gurus,

I have one ALV grid i need the multiplication of two column and result in one column can any one plz tell me how to achive this below is my ALV grid Filed catalog plz suggest me by see the below code ,

APPEND ls_fcat TO fieldcat.  CLEAR: ls_fcat.
   ls_fcat-reptext    = 'WC'.
  ls_fcat-fieldname  = 'INSUL'.
  ls_fcat-ref_table  = 'I_ALV2'.
  ls_fcat-outputlen  = '04'.
  ls_fcat-col_pos    = '7'.
  APPEND ls_fcat TO fieldcat.  CLEAR: ls_fcat.
  ls_fcat-reptext    = '  LV  '.
  ls_fcat-fieldname  = 'LMNGA'.
  ls_fcat-ref_table  = 'I_ALV2'.
  ls_fcat-outputlen  = '08'.
  ls_fcat-col_pos    = '8'.
  ls_fcat-DO_SUM = 'X'.
  APPEND ls_fcat TO fieldcat.  CLEAR: ls_fcat.
  ls_fcat-reptext    = '  qnty  '.
  ls_fcat-fieldname  = 'LMNGA' .             " here i need the multilpication with 100  Like Qnty is  10 then result shold be 10*100
  ls_fcat-ref_table  = 'I_ALV2'.
  ls_fcat-outputlen  = '08'.
  ls_fcat-col_pos    = '8'.
  ls_fcat-DO_SUM = 'X'.
  APPEND ls_fcat TO fieldcat.  CLEAR: ls_fcat.

5 REPLIES 5

venkateswaran_k
Active Contributor
0 Kudos
407

Hi

The quick way is to do as follows;

1. You add a column in the type I_ALV2 itself.

2. Before you call display Alv Grid, update your internal table I_ALV2 for the column you required.

3. Put that in the Catalog

Regards,

Venkat

0 Kudos
407

Hi,

Thanks for replay, Nut still i didnt got soln WIll you plz specify your answer in detail ,thanks its really apericate.

Thanks,

0 Kudos
407

hi ,

simply declare one more variable in the final internal table and in that field store the multiplication result .

eg :

data : lsmw1 type c .

lsmw1 = quant * 100 .

regards

ranjan

0 Kudos
407

could you plz exmplain with sort of code

Thanks for replay.

0 Kudos
407

"After fetching all data, loop through the internal table updating the required value
LOOP AT itab INTO wa.
  wa-lmnga = wa-insul * wa-lmnga.                  " Multiply
  MODIFY itab FROM wa INDEX sy-tabix TRANSPORTING lmnga.  " Update value
ENDLOOP.