Advertisement
yaramohamed78

FUNCTION Z_ASG_FN_INSERT

Jan 18th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 1.29 KB | None | 0 0
  1. FUNCTION Z_ASG_FN_INSERT.
  2. *"----------------------------------------------------------------------
  3. *"*"Local Interface:
  4. *"  IMPORTING
  5. *"     REFERENCE(WA_EMP) TYPE  ZASG_EMP
  6. *"  EXPORTING
  7. *"     VALUE(E_SUBRC) TYPE  SY-SUBRC
  8. *"----------------------------------------------------------------------
  9. TABLES : ZASG_EMP.
  10. CONSTANTS: admin  TYPE c LENGTH 4 VALUE 'admin'.
  11. DATA: temp_name LIKE wa_emp-name.
  12. TRANSLATE temp_name TO LOWER CASE.
  13.  
  14. * CHANGE POSITION VALUES TO FIT THE DATABASE.
  15. IF wa_emp-emppositon = 'Junior Developer'.
  16. wa_emp-empposition = 'JUNIOR'.
  17. ELSEIF wa_emp-empposition = 'Senior Developer'.
  18. wa_emp-empposition = 'SENIOR'.
  19. ELSEIF wa_emp-empposition = 'Team Leader'.
  20. wa_emp-empposition = 'TL'.
  21. ELSEIF wa_emp-empposition = 'Project Manager'.
  22. wa_emp-empposition = 'PM'.
  23. ENDIF.
  24.  
  25.  
  26.  
  27.  
  28. if temp_name = admin.
  29.   E_SUBRC ='0'.
  30. ELSE.
  31. SELECT * FROM ZASG_EMP
  32.   WHERE id = wa_emp-id.
  33. ENDSELECT.
  34. IF NOT ZASG_EMP-id is INITIAL.
  35.   E_SUBRC = '3'.
  36. ELSE.
  37.     SELECT * FROM ZASG_EMP
  38.       WHERE name = wa_emp-name.
  39.     ENDSELECT.
  40. IF ZASG_EMP-id IS INITIAL.
  41.   ZASG_EMP-id = wa_emp-id.
  42.   ZASG_EMP-name = wa_emp-name.
  43.   ZASG_EMP-empposition = wa_emp-empposition.
  44.   INSERT INTO ZASG_EMP VALUES ZASG_EMP.
  45.   E_SUBRC = '1'.
  46.  ELSE.
  47.    E_SUBRC = '2'.
  48.  ENDIF.
  49. ENDIF.
  50. ENDIF.
  51.  
  52. ENDFUNCTION.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement