SAP Direct database update within an ABAP report

The following code can be used as a template to produce an ABAP which updates a particular database table field. Also see updating a SAP database table using the ABAP Modify command


*&---------------------------------------------------------------------*
*& Report  ZUPDATE_PRPS                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&  Quick report to Update PRPS-FAKKZ database field                   *
*&---------------------------------------------------------------------*
Report  ZUPDATE_PRPS.
tables: prps.
parameter: p_wbs like prps-pspnr,
           p_value like prps-fakkz default 'X'.
data: wa_fakkz type prps-fakkz.
************************************************************************
*START-OF_SELECTION
start-of-selection.
call function 'CONVERSION_EXIT_ABPSP_INPUT'
     exporting
         input     = p_wbs
    importing
         output    = p_wbs
    exceptions
         not_found = 1
         others    = 2.
select single fakkz
  into wa_fakkz
  from prps
 where pspnr eq p_wbs.
if sy-subrc eq 0.
   update prps set fakkz = p_value where PSPNR eq p_wbs.
   if p_value is initial.
     message i999(za) with 'Billing element field has been unchecked'.
   else.
     message i999(za) with 'Billing element field has been checked'.
   endif.
else.
  message i999(za) with 'WBS element not found'.
endif.

Related Articles

SAP ABAP BDC creation - Example code and information on call transaction and batch input session
SAP BDC ABAP report using Call Transaction to automate data input
ABAP SAP BDC Call Transaction report Source Code and documentation
ABAP Source Code for SAP BDC report using Call Transaction
Enhanced ABAP source code for SAP BDC Call Transaction program
SAP Date format for BDC entry
Create SAP BDC transaction recording so you can automate data input
bdc session development
Generate ABAP program from SHDB SAP transaction recording made in any client
Updating SAP databases - Example ABAP code and information on database update techniques