INSERT / UPDATE / DELETE Database Entry Template

Nützliche Abap Codes und Code Fragmente

INSERT / UPDATE / DELETE Database Entry Template

Postby Tron » Mon Jul 18, 2022 10:49 am

Hi.
Update Sflight.png
Update Sflight.png (47.38 KiB) Viewed 117 times

Update Sflight2.png
Update Sflight2.png (19.97 KiB) Viewed 117 times

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. function z_update_sflight.
  2. *"----------------------------------------------------------------------
  3. *"*"Update Function Module:
  4. *"
  5. *"*"Local Interface:
  6. *"  IMPORTING
  7. *"     VALUE(IM_STATUS) TYPE  SFLIGHT
  8. *"     VALUE(IM_PROCESSING_MODE) TYPE  UPDKZ_D DEFAULT 'I'
  9. *"----------------------------------------------------------------------
  10.   data ls_sflight type sflight.
  11.   data lv_processing_mode type updkz_d.
  12.  
  13.   lv_processing_mode = im_processing_mode.
  14.  
  15.   clear ls_sflight.
  16.   select single * from sflight into ls_sflight
  17.   where carrid = im_status-carrid and
  18.     connid eq im_status-connid and
  19.     fldate eq im_status-fldate.
  20.  
  21.   if sy-subrc = 0.
  22.     if lv_processing_mode = 'I'.
  23.       lv_processing_mode = 'U'.
  24.     endif.
  25. *    EXIT.
  26.   endif.
  27.  
  28.   ls_sflight-carrid = im_status-carrid.
  29.   ls_sflight-connid = im_status-connid.
  30.   ls_sflight-fldate = im_status-fldate.
  31.   ls_sflight-price = im_status-price.
  32.   ls_sflight-currency = im_status-currency.
  33.   ls_sflight-planetype = im_status-planetype.
  34.   ls_sflight-seatsmax = im_status-seatsmax.
  35.   ls_sflight-seatsocc = im_status-seatsocc.
  36.   ls_sflight-paymentsum = im_status-paymentsum.
  37.   ls_sflight-seatsmax_b = im_status-seatsmax_b.
  38.   ls_sflight-seatsocc_b = im_status-seatsocc_b.
  39.   ls_sflight-seatsmax_f = im_status-seatsmax_f.
  40.   ls_sflight-seatsocc_f = im_status-seatsocc_f.
  41.  
  42.   case lv_processing_mode.
  43.  
  44. * modify / update_table
  45.     when 'M'.
  46.       try.
  47.           modify sflight from ls_sflight.
  48.         catch cx_sy_dynamic_osql_error.
  49. *          MESSAGE i061.
  50.       endtry.
  51.  
  52.     when 'U'.
  53.       try.
  54.           update sflight from ls_sflight.
  55.         catch cx_sy_dynamic_osql_error.
  56. *          MESSAGE i061.
  57.       endtry.
  58.  
  59. * insert into table
  60.     when 'I'.
  61.       try.
  62.           insert sflight from ls_sflight.
  63.         catch cx_sy_dynamic_osql_error.
  64.           "MESSAGE I061.
  65.       endtry.
  66.  
  67. * delete table
  68.     when 'D'.
  69.       try.
  70.           delete sflight from ls_sflight.
  71.         catch cx_sy_dynamic_osql_error.
  72.           "MESSAGE I061.
  73.       endtry.
  74.  
  75.  
  76.     when others.
  77.       "RAISE wrong_action_code.
  78.  
GeSHi ©
Tron
.....
.....
 
Posts: 1112
Joined: Sat Aug 04, 2007 10:21 pm

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest

cron