cancel
Showing results for 
Search instead for 
Did you mean: 

Save Button

Former Member
0 Kudos

Hi Export,

I have created in WDP in this view have one save button, this button save various table. How will write code.

Accepted Solutions (0)

Answers (4)

Answers (4)

Pramanan
Active Participant
0 Kudos

Dear Prakasam,

In the OnClick Event of the save button create a method SAVE. In the SAVE method use code wizard (CTRL+F7) to access the attributes ( values to insert) . Then write the normal abap code to insert the values to table.

Former Member
0 Kudos

Hi,

I need some sample code.

yesrajkumar
Active Participant
0 Kudos

Hi,

Please find the sample code that will update our custom infotype after importing the values from the memory.

  • function module parameters

data return type bapireturn1.

data return_lock type bapireturn1.

data: i0471 type standard table of p0471,

wa_i0471 type p0471.

data: end_date type p9001-endda.

end_date = '99991231'.

  • memory parameters

data: begda type rebed,

endda type reend,

hdcap type flight_pref_hdcap,

hdcap_descr type flight_pref_hdcap_descr,

medic type flight_pref_medic,

medic_descr type flight_pref_medic_descr,

blind type flight_pref_blind,

asist type flight_pref_asist.

*import from memory

import begda to begda endda to endda

hdcap to hdcap hdcap_descr to hdcap_descr

medic to medic medic_descr to medic_descr

blind to blind asist to asist from memory id 'medic_ref' .

*move memory values to work area.

wa_i0471-pernr = wd_assist->gs_common_rfc_input-employee_number.

wa_i0471-begda = begda.

wa_i0471-endda = endda.

wa_i0471-hdcap = hdcap.

wa_i0471-hdcap_descr = hdcap_descr.

wa_i0471-medic = medic.

wa_i0471-medic_descr = medic_descr.

wa_i0471-blind = blind.

wa_i0471-asist = asist.

append wa_i0471 to i0471.

*function module to lock the employee

call function 'bapi_employee_enqueue'

exporting

number = wa_i0471-pernr

importing

return = return_lock.

if sy-subrc eq 0.

*function module to update the 0471 infotype

call function 'hr_infotype_operation'

exporting

infty = '0471'

number = wa_i0471-pernr "wd_assist->gs_common_rfc_input-employee_number

validityend = wa_i0471-endda "end_date

validitybegin = wa_i0471-begda "lv_datedep

record = wa_i0471

operation = 'ins'

importing

return = return.

elseif sy-subrc eq 4.

  • get message manager

data lo_api_controller type ref to if_wd_controller.

data lo_message_manager type ref to if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

call method lo_api_controller->get_message_manager

receiving

message_manager = lo_message_manager.

  • report message

call method lo_message_manager->report_error_message

exporting

message_text = return_lock-message.

endif.

*function module to unlock the employee number.

call function 'bapi_employee_dequeue'

exporting

number = wa_i0471-pernr.

Thanks,

Rajkumar.S

Edited by: Rajkumar S on Feb 3, 2009 7:03 AM

uday_gubbala2
Active Contributor
0 Kudos

Hi Prakasam,

1.) Create the component with the desired layout

2.) Next on the button click that updates the database - add an action.

3.) double click the action so that you are taken to the methods section of the view.

4.) next you need to add the code that is required the update the database

5.) compile and test the application

For the 4th part you should preferably be making use of a BAPI. (You can use the [service call feature|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9cb5d345-0801-0010-6a8e-fc57c23fd600] in WDA for achieving this.) If you however intend to just make a working test example then you can directly code an INSERT statement using the normal ABAP syntax.

Data: wa TYPE <tablename>.

INSERT INTO <tablename> VALUES WA.

Regards,

Uday

yesrajkumar
Active Participant
0 Kudos

Hi,

Place the Button UI element on your view. Define some action event for the same button(which will generate a method) and using that get the information from your context and hence you will be able to save the information.

Thanks,

Rajkumar.S