cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning Total value to a text view in WDY ABAP

Former Member
0 Kudos

Hai All,

I have calculated total amount in an alv table and I want to assign that total value to an attribute in context.

lv_aggr_rule will hold the total amount is of below type..

lv_aggr_rule type ref to cl_salv_wd_aggr_rule

Claimed amount is my attribute of type PAD_AMT7S..

I have to set this value lv_aggr_rule to the attribute Claimed amount using set attribute.

Is it possible??? Am getting type conflict error

lv_aggr_rule can be converted into the respective data type.

How can i convet this data type????

Pls help.

Thanks in Advance,

Nalla.B

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

declare another variable in type of PAD_AMT7S,

data : lv_variablename type pad_amt7s.

and write query like move v_aggr_rule to lv_variablename.

and pass lv_variable name in set attribute pass

Regards,

Srinivasan.R

Former Member
0 Kudos

Hai,

I did that one already its not working...

Am getting error

The type of "LV_AGGR_RULE" cannot be converted to the type of "LV_TOTALAMOUNT".

LV_TOTALAMOUNT of type PAD_AMT7S.

Its not working. Pls give some suggestions..

Thanks in advance,

Nalla.B

former_member199125
Active Contributor
0 Kudos

try this once

make lv_totalamout as string data type and let me know.

Regards

Srinivas

Former Member
0 Kudos

Hai,

I tried with string and field symbols am getting the same error.

Is it possible to set that total value to some other attribute???

How that type conversion can be solved

Thanks in Advance,

Nalla.B

Former Member
0 Kudos

Hi,

It is not possible to set a class reference to any attribute which is of amount type.

lv_aggr_rule is refering to a class cl_salv_wd_aggr_rule.

All you can get from this class is the aggregation type by using its methods.

Maybe you can let us know the code you have written to get the total amount and also the details of the data type PAD_AMT7S.

Regards

Dolly

Former Member
0 Kudos

Hai Dolly,

I have used this coding to calculate the total value in ALV table.

" Total calculation

data: lr_comp_alv type ref to if_wd_component_usage,

lr_comp_if_alv type ref to iwci_salv_wd_table,

lr_config type ref to cl_salv_wd_config_table.

data: lv_totalamount type PAD_AMT7S.

"data lr_config type ref to cl_salv_wd_config_table.

"data: lr_column_settings type ref to if_salv_wd_column_settings,

" data: lr_column type ref to cl_salv_wd_column.

data: lr_column_header type ref to cl_salv_wd_column_header.

data : lt_column type salv_wd_t_column_ref,

ls_column type salv_wd_s_column_ref.

data: lr_field_amnt type ref to cl_salv_wd_field.

data: lv_aggr_rule type ref to cl_salv_wd_aggr_rule.

data: wv_aggr_rule type p decimals 2.

"PAD_AMT7S

data: lr_sort_rule type ref to cl_salv_wd_sort_rule.

data fs_bill_detail like line of lt_bill_detail.

*... ALV Component Usage

lr_comp_alv = wd_this->wd_cpuse_alv( ).

if lr_comp_alv->has_active_component( ) is initial.

lr_comp_alv->create_component( ).

endif.

lr_comp_if_alv = wd_this->wd_cpifc_alv( ).

*... Configure ALV

lr_config = lr_comp_if_alv->get_model( ).

call method lr_config->if_salv_wd_table_settings~set_selection_mode

exporting

value = cl_wd_table=>e_selection_mode-multi_no_lead.

      • To get the dropdowns displayed you need to set the table to editable by using below statement

lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).

  • "display columns in correct order

lr_column_settings ?= lr_config.

lt_column = lr_column_settings->get_columns( ).

loop at lt_column into ls_column.

case ls_column-id.

when 'AMOUNT'.

  • aggregate field

call method lr_config->if_salv_wd_field_settings~get_field

exporting

fieldname = 'AMOUNT'

receiving

value = lr_field_amnt .

  • create aggregate rule as total

call method lr_field_amnt->if_salv_wd_aggr~create_aggr_rule

exporting

aggregation_type = if_salv_wd_c_aggregation=>aggrtype_total

receiving

value = lv_aggr_rule.

endcase.

endloop.

This is what i did to assign that vale to my context attribute.

lo_el_context->set_attribute(

name = `CLAIMED_AMNT` " attribute name in context

value = lv_aggr_rule).

I also tried with some assigning this lv_aggr_rule to some other variable. and assigned this to the value in set attribute.

Pls give some suggestions...

Thanks in Advance,

Nalla.B

Former Member
0 Kudos

Hi Nalla ,

Why dont u loop your internal table on the column "Amount" and make a sum for that particular column, u will get the required sum Amount..

Thanks

Aisurya

Former Member
0 Kudos

Hi ,

I tried working on it.As per my finding, aggregations are for the summary lines.You cannot assign the aggregated value to some other field.

lv_aggr_rule is refering to a class cl_salv_wd_aggr_rule and there are no methods in the class cl_salv_wd_aggr_rule by which we can get the desired value.

And above all, you cannot copy a class reference into any variable of type amount.

A class reference can be copied to a variable of the type reference only.

Regards,

Dolly

Former Member
0 Kudos

Hi ,

There is class " CL_SALV_WD_AGGREGATION " i remember some how and there is a method "EXECUTE" and a parameter "t_measure" in it , and in that itab there is a field like " NODE_SUM_F " , aggregation value is stored in that..

Try it...

Cheers

Aisurya