Simple BSP application to Create, Modify and Delete the database entries

...Previous

STEP 13: In the layout, add the following code;

      <%
   
else if fl_flag eq 1.
      
%>
            <
center>
      <
table bgcolor="ivory">
      <
tr>
      <
td>
      <htmlb:
label for       = "ip_emno"
                   labelType = 
"MEDIUM"
                   
text      = "Employee Number" />
      </
td>
            <
td>
      <htmlb:inputField 
id       = "ip_emno"
                        
value    = "<%= w_emno %>"
                        
disabled = "TRUE" />
      </
td></tr>
            <
tr>
      <
td>
      <htmlb:
label for       = "ip_dob"
                   labelType = 
"MEDIUM"
                   
text      = "Date of Birth" />
      </
td>
            <
td>
      <htmlb:inputField 
id    = "ip_dob"
                        
value = "<%= w_ext_dob %>" />
      </
td></tr>
                              <
tr>
      <
td>
      <htmlb:
label for       = "ip_doj"
                   labelType = 
"MEDIUM"
                   
text      = "Date of Joining" />
      </
td>
                              <
td>
      <htmlb:inputField 
id    = "ip_doj"
                        
value = "<%= w_ext_doj %>" />
      </
td></tr>
                              <
tr>
        <
td>
      <htmlb:
label for       = "ip_salary"
                   labelType = 
"MEDIUM"
                   
text      = "Salary" />
      </
td>
                              <
td>
      <htmlb:inputField 
id    = "ip_salary"
                        
value = "<%= w_salary %>" />
      </
td></tr>
                              <
tr><td>
                              <
center>
      <htmlb:
button id      = "save"
                    tooltip = 
"Modify the Content"
                    
text    = "MODIFY"
                    
onClick = "OnInputProcessing()" />
      <htmlb:
button id      = "delete"
                    tooltip = 
"Delete Selected Entry"
                    
text    = "DELETE"
                    
onClick = "OnInputProcessing()" />
      </
center>
            </
td></tr>
      </
table>
      
<%
  
endif.
      
%>

 

STEP 14: Now, when MODIFY button is clicked, the values changed should be stored in database without changing employee id, since that’s primary key.

 

ELSEIF w_eventid EQ 'save'.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_emno'
    RECEIVING
      
data    = w_object.

  w_in_field ?= w_object.
  w_in_value = w_in_field->
value.
  w_employee = w_in_value.

  
CLEAR: w_object,w_in_field,w_in_value.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_dob'
    RECEIVING
      
data    = w_object.
  w_in_field ?= w_object.

  
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    
EXPORTING
      date_external                  = w_in_field->
value
*     ACCEPT_INITIAL_DATE            =
   
IMPORTING
     date_internal                  = w_dofb
*   EXCEPTIONS
*     DATE_EXTERNAL_IS_INVALID       = 1
*     OTHERS                         = 2
            .
  
IF sy-subrc <> 0.
    
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  
ENDIF.

  
CLEAR: w_object,w_in_field,w_in_value.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_doj'
    RECEIVING
      
data    = w_object.

  w_in_field ?= w_object.

  
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    
EXPORTING
      date_external                  = w_in_field->
value
*     ACCEPT_INITIAL_DATE            =
   
IMPORTING
     date_internal                  = w_dofj
*   EXCEPTIONS
*     DATE_EXTERNAL_IS_INVALID       = 1
*     OTHERS                         = 2
            .
  
IF sy-subrc <> 0.
    
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  
ENDIF.

  
CLEAR: w_object,w_in_field,w_in_value.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_salary'
    RECEIVING
      
data    = w_object.

  w_in_field ?= w_object.
  w_in_value = w_in_field->
value.
  w_esalary = w_in_value.

  
UPDATE zart_programmer SET emno   = w_employee
                             dob    = w_dofb
                             doj    = w_dofj
                             salary = w_esalary
                         
WHERE emno = w_employee. 

STEP 15: Deleting an entry from database is quite simple, since it doesn’t require any conditions except index.

We give the same code as above, except for the query at the bottom.

 ELSEIF w_eventid EQ 'delete'.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_emno'
    RECEIVING
      
data    = w_object.

  w_in_field ?= w_object.
  w_in_value = w_in_field->
value.
  w_employee = w_in_value.

  
CLEAR: w_object,w_in_field,w_in_value.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_dob'
    RECEIVING
      
data    = w_object.
  w_in_field ?= w_object.

  
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    
EXPORTING
      date_external                  = w_in_field->
value
*     ACCEPT_INITIAL_DATE            =
   
IMPORTING
     date_internal                  = w_dofb
*   EXCEPTIONS
*     DATE_EXTERNAL_IS_INVALID       = 1
*     OTHERS                         = 2
            .
  
IF sy-subrc <> 0.
    
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  
ENDIF.

  
CLEAR: w_object,w_in_field,w_in_value.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_doj'
    RECEIVING
      
data    = w_object.

  w_in_field ?= w_object.

  
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    
EXPORTING
      date_external                  = w_in_field->
value
*     ACCEPT_INITIAL_DATE            =
   
IMPORTING
     date_internal                  = w_dofj
*   EXCEPTIONS
*     DATE_EXTERNAL_IS_INVALID       = 1
*     OTHERS                         = 2
            .
  
IF sy-subrc <> 0.
    
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  
ENDIF.

  
CLEAR: w_object,w_in_field,w_in_value.

  
CALL METHOD cl_htmlb_manager=>get_data
    
EXPORTING
      request = runtime->server->request
      name    = 
'inputfield'
      
id      = 'ip_salary'
    RECEIVING
      
data    = w_object.

  w_in_field ?= w_object.
  w_in_value = w_in_field->
value.
  w_esalary = w_in_value.

  fs_progmr-emno   = w_employee.
  fs_progmr-dob    = w_dofb.
  fs_progmr-doj    = w_dofj.
  fs_progmr-salary = w_esalary.

  
DELETE zart_programmer FROM fs_progmr.

ENDIF. 

STEP 16: Save, activate and test the program. 

[SCM]actwin,-4,-4,1028,742;Main Page - Microsoft Internet Explorer
iexplore.exe
2/28/2009 , 1:12:24 PM
 

[SCM]actwin,-4,-4,1028,742;Main Page - Microsoft Internet Explorer
iexplore.exe
2/28/2009 , 1:20:01 PM

[SCM]actwin,-4,-4,1028,742;Main Page - Microsoft Internet Explorer
iexplore.exe
2/28/2009 , 1:20:55 PM

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image