cancel
Showing results for 
Search instead for 
Did you mean: 

how to multiply fields in inside alv

ananth_anni
Participant
0 Kudos

hi frnds,

I am Created one table having sales order input and ALV table for out put having 5 fields, material , mat description, quantity , price , amount , currency are my fields.

NOw quantity and price are editable in alv table -


SO when i am changed the quantity and price i need to change the amount that is multiplication ,, im have save button to data base .record saving is working but i need the multi plication code.

after the multiplication i need to save in customize table.

SAVE THE DATA TO CUSTOMISE TABLE

DATA: node_node_flighttab TYPE REF TO if_wd_context_node,

elem_node_flighttab TYPE REF TO if_wd_context_element,

itab TYPE if_FIRST_VIEW=>elements_SALE_OUTPUT.

*itab type standard table of sflight,

*wa_itab1 type sflight.

  • save data only if no error has occured

CHECK r_param->t_error_cells IS INITIAL.

  • navigate from <CONTEXT> to <NODE_FLIGHTTAB> via lead selection

node_node_flighttab

= wd_context->get_child_node( name = `SALE_OUTPUT` ).

  • get data from context node <NODE_FLIGHTTAB>

node_node_flighttab->get_static_attributes_table(

IMPORTING table = itab ).

DATA: BEGIN OF itab1,

salesorder TYPE zcustomer_order1-salesorder,

customernum TYPE zcustomer_order1-customernum,

purchaseorder TYPE zcustomer_order1-purchaseorder,

matnr TYPE zcustomer_order1-matnr,

matnrdes TYPE zcustomer_order1-matnrdes,

qty TYPE zcustomer_order1-qty,

zprice TYPE zcustomer_order1-zprice,

amt TYPE zcustomer_order1-amt,

currency TYPE zcustomer_order1-currency,

END OF itab1.

data : itab2 like standard table of itab1,

wa_itab like itab1.

data : sales type zcustomer_order1-salesorder,

customer type zcustomer_order1-customernum,

purchase type zcustomer_order1-purchaseorder.

data : qty type standard table of zcustomer_order1,

zprice type standard table of zcustomer_order1,

amt type standard table of zcustomer_order1.

data : begin of wa_itab1,

  • customernum TYPE zcustomer_order1-customernum,

  • purchaseorder TYPE zcustomer_order1-purchaseorder,

matnr TYPE zcustomer_order1-matnr,

matnrdes TYPE zcustomer_order1-matnrdes,

qty TYPE zcustomer_order1-qty,

zprice TYPE zcustomer_order1-zprice,

amt TYPE zcustomer_order1-amt,

currency TYPE zcustomer_order1-currency,

end of wa_itab1.

loop at itab into wa_itab1.

move-corresponding wa_itab1 to wa_itab.

wa_itab-salesorder = sales.

wa_itab-customernum = customer.

wa_itab-purchaseorder = purchase.

  • insert into zcustomer_order1 values wa_itab.

modify zcustomer_order1 from wa_itab.

endloop.

Accepted Solutions (0)

Answers (2)

Answers (2)

ananth_anni
Participant
0 Kudos

ANS

Former Member
0 Kudos

Dear Ananth,

Write your code for multiplication in Modify View.

Loop at <IT_TAB> assigning <LF_WA>.

<LF_WA>-amount = <LF_WA>-quantity * <LF_WA>-price.

ENDLOOP.

If you have large data then due to performance issues it is not advisable to modify all rows in the table.

In case of large data make your Node changes trace ON and loop for only on the data which has change data flag as X.

Regards,

Nidhi Sharma.

ananth_anni
Participant
0 Kudos

thanks,

i am having nly 4 record nly but u said to write the code in modify view, but i am having the save button to save the edited fields,

My question after i am editing the quantity and price than after clik the save button amount should change as iam edited , save held on my customize table ,

IN SAVE BUTTON THE CODE IS<

DATA: node_node_flighttab TYPE REF TO if_wd_context_node,

elem_node_flighttab TYPE REF TO if_wd_context_element,

itab TYPE if_FIRST_VIEW=>elements_SALE_OUTPUT.

*itab type standard table of sflight,

*wa_itab1 type sflight.

  • save data only if no error has occured

CHECK r_param->t_error_cells IS INITIAL.

  • navigate from <CONTEXT> to <NODE_FLIGHTTAB> via lead selection

node_node_flighttab

= wd_context->get_child_node( name = `SALE_OUTPUT` ).

  • get data from context node <NODE_FLIGHTTAB>

node_node_flighttab->get_static_attributes_table(

IMPORTING table = itab ).

DATA: BEGIN OF itab1,

salesorder TYPE zcustomer_order1-salesorder,

customernum TYPE zcustomer_order1-customernum,

purchaseorder TYPE zcustomer_order1-purchaseorder,

matnr TYPE zcustomer_order1-matnr,

matnrdes TYPE zcustomer_order1-matnrdes,

qty TYPE zcustomer_order1-qty,

zprice TYPE zcustomer_order1-zprice,

amt TYPE zcustomer_order1-amt,

currency TYPE zcustomer_order1-currency,

END OF itab1.

data : itab2 like standard table of itab1,

wa_itab like itab1.

data : sales type zcustomer_order1-salesorder,

customer type zcustomer_order1-customernum,

purchase type zcustomer_order1-purchaseorder.

data : qty type standard table of zcustomer_order1,

zprice type standard table of zcustomer_order1,

amt type standard table of zcustomer_order1.

data : begin of wa_itab1,

  • customernum TYPE zcustomer_order1-customernum,

  • purchaseorder TYPE zcustomer_order1-purchaseorder,

matnr TYPE zcustomer_order1-matnr,

matnrdes TYPE zcustomer_order1-matnrdes,

qty TYPE zcustomer_order1-qty,

zprice TYPE zcustomer_order1-zprice,

amt TYPE zcustomer_order1-amt,

currency TYPE zcustomer_order1-currency,

end of wa_itab1.

loop at itab into wa_itab1.

move-corresponding wa_itab1 to wa_itab.

wa_itab-salesorder = sales.

wa_itab-customernum = customer.

wa_itab-purchaseorder = purchase.

  • insert into zcustomer_order1 values wa_itab.

modify zcustomer_order1 from wa_itab.

iF I NEED TO PUT U R CODE IN mODIFY VIEW THAN I NEED TO DECLARE THE ITAB , WORK AREA AND ELSE NO , SO WHAT TO DO CAN TO TYPE THE CODE AS PER MY CODE.

Former Member
0 Kudos

Hi,

There is no need write the code in MODIFYVIEW as you have SAVE button, code it inside this button.

After Moving to other table

loop at itab into wa_itab1.
move-corresponding wa_itab1 to wa_itab.
wa_itab-salesorder = sales.
wa_itab-customernum = customer.
wa_itab-purchaseorder = purchase. 
*wa_itab-amt = wa_itab-qty *wa_itab-zprice.** insert into zcustomer_order1 values wa_itab.
modify zcustomer_order1 from wa_itab.

or

Before Moving to other table-

loop at itab into wa_itab1.
wa_itab1-amunt = wa_itab1-quantity *wa_itab1-price.*
move-corresponding wa_itab1 to wa_itab.
wa_itab-salesorder = sales.
wa_itab-customernum = customer.
wa_itab-purchaseorder = purchase. 
* insert into zcustomer_order1 values wa_itab.
modify zcustomer_order1 from wa_itab.

Check in Debugging wether you are able to see the values or not.Otherwise there is probelm with MOVE-CORRESPONDING statement. (Check if the column/field names are not same in both the work areas WA_ITAB and WA_ITAB1).May be the move corresponding statment is not working. Check in Deubgging....

Regards,

Lekha.

ananth_anni
Participant
0 Kudos

thanks lekha ,

my o/p got now , but one more problem is i have delete button at selection screen to delete the record

data lo_nd_flight type ref to if_wd_context_node.

data lo_el_flight type ref to if_wd_context_element.

data ls_flight type wd_this->element_flight_output.

data: it_tab type table of wd_this->element_flight_output.

    • navigate from <CONTEXT> to <KNA1> via lead selection*

lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight_output ).

    • get element via lead selection*

lo_el_flight = lo_nd_flight->get_element( ).

lo_el_flight->get_static_attributes(

importing

static_attributes = ls_flight ).

lo_nd_flight->get_static_attributes_table(

importing

table = it_tab ).

delete it_tab where fldate eq ls_flight-fldate.

lo_nd_flight->bind_table( it_tab[] ).

this is the code for delete.

after delete the delete the record i need to save the record to my db table

than wht the code to write in save button

Former Member
0 Kudos

Hi ,

Once you delete it from the itab and hence the screen , you should probably delete it from the DB table also.Somthing like this..

DELETE FROM sflight 
WHERE  fldate = ls_flight-fldate.

Followed by a COMMIT WORK..so that changes are saved.

thanks.,

Aditya.

ananth_anni
Participant
0 Kudos

thanks ,

In normal table ( NOT IN ALV ), how to perform filter , grouping , subtotal.

Can u please provide any tutorials regards to this topics.

Former Member
0 Kudos

Hi,

There are already so many threads on sort and filter functionality of Normal TABLE UI element.

Please search the forum.

Check the DEMO_TABLE component.

Regards,

Lekha.

Edited by: Lekha on Nov 16, 2010 3:26 PM

ananth_anni
Participant
0 Kudos

thanks lekha,

And i Know how to total and subtotal in alv tables but for the particular field in standard table need to total and subtotal can you plz provide any tutorials screen shot for this.

Former Member
0 Kudos

Hi,

I think there are already tutorials available on totals and subtotals.Please search SCN.

Regards,

Lekha.

ananth_anni
Participant
0 Kudos

THANKS FOR U LAST REPLAY ,

iam getting error for this code can u plz explan this.

Method ONACTIONSHOW_HIDE

*THIS IS CODE FOR SHOW AND HIDE THE INPUT FIED BUT GETTING ERROR IS

**set_attribute_property doesnot exit similar ly get_attribute_property and set attribute is there like that getting error for this code

. DATA lo_nd_radio_node1 TYPE REF TO if_wd_context_node.

DATA lo_el_radio_node1 TYPE REF TO if_wd_context_element.

DATA lw_index TYPE I.

DATA lo_el_radio_node1_1 TYPE ref to if_wd_context_element.

  • navigate from <CONTEXT> to <RADIO_NODE1> via lead selection

lo_nd_radio_node1 = wd_context->get_child_node( name = wd_this->wdctx_radio_node1 ).* call method get lead selection index to get index

CALL METHOD lo_nd_radio_node1->get_lead_selection_index

receiving

index = lw_index. lo_el_radio_node1_1 = wd_context->get_element( ). If lw_index = 1. * call method set attribute property and pass value as 'X' to show

call method lo_el_radio_node1_1->set_attribute_property

exporting

attribute_name = 'FIRST_NAME_1'

property = 1

value = 'X'.

  • call method set attribute property and pass value as 'X' to show

call method lo_el_radio_node1_1->set_attribute_property

exporting

attribute_name = 'LAST_NAME_1'

property = 1

value = 'X'. Else.* call method set attribute property and pass value as SPACE to HIDE

call method lo_el_radio_node1_1->set_attribute_property

exporting

attribute_name = 'FIRST_NAME_1'

property = 1

value = space.* call method set attribute property and pass value as SPACE to HIDE

call method lo_el_radio_node1_1->set_attribute_property

exporting

attribute_name = 'LAST_NAME_1'

property = 1

value = space. Endif

Former Member
0 Kudos

Hi,

Can you be more clear on your requirement. What is the purpose of this code. Do you want to show/hide the Input field dyamaically. In rpevious reply you have asked for totals..Now you have pasted some code...I dont find any relevance..And the error is also not highlighted...Please be clear.

Regards,

Lekha.

Edited by: Lekha on Nov 18, 2010 3:09 PM

ananth_anni
Participant
0 Kudos

Sorry the code is another prg,

actually they are two buttons one for show another for hide , in the show button the code u seen ,. but its error like

SET_ATRRIBUTE_PROPERTY IS NOT THERE SIMILARLY GET_ATTRIBUTE AND SET_ATTRIBUTE IS THERE Like that error getting .