sapdev logo background
sapdev logo sapdev logo
Comments

Direct database update within an SAP 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.




comments powered by Disqus