Calling service on BC via RFC


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. *&---------------------------------------------------------------------*
  2. *& Include Z_GET_PERSON_DATA_PROGRAM_TOP Module Pool Z_GET_PERSON_DATA_PROGRAM
  3. *&
  4. *&---------------------------------------------------------------------*
  5. PROGRAM z_get_person_data_program.
  6. *&---------------------------------------------------------------------*
  7. *& Module READ_PESEL INPUT
  8. *&---------------------------------------------------------------------*
  9. * text
  10. *----------------------------------------------------------------------*
  11. * Global data declarations
  12.  
  13. DATA: gr_regex TYPE REF TO cl_abap_regex,
  14. gr_matcher TYPE REF TO cl_abap_matcher,
  15. ok_code TYPE sy-ucomm,
  16. pesel_input TYPE zzpersons-pesel,
  17. name_output TYPE zzpersons-name,
  18. surname_output TYPE zzpersons-surname,
  19. birthdate_output TYPE dats,
  20. g_msg TYPE c,
  21. g_out TYPE string.
  22.  
  23. *----------------------------------------------------------------------*
  24. * MODULE READ_PESEL INPUT
  25. *----------------------------------------------------------------------*
  26. *
  27. *----------------------------------------------------------------------*
  28. MODULE read_pesel INPUT.
  29. IF ok_code EQ 1.
  30. g_out = pesel_input.
  31. CREATE OBJECT gr_regex
  32. EXPORTING
  33. pattern = `{11}`.
  34. gr_matcher = gr_regex->create_matcher( text = g_out ).
  35. IF gr_matcher->match( ) IS INITIAL.
  36. MESSAGE 'Pesel must consist of 11 numeral' TYPE 'I' DISPLAY LIKE 'E'.
  37. ELSE.
  38. CALL FUNCTION 'Z_SAP_PERSON_DATA' DESTINATION 'ZPLASAPBC'
  39. EXPORTING
  40. i_pesel = pesel_input
  41. IMPORTING
  42. e_name = name_output
  43. e_surname = surname_output
  44. e_birthdate = birthdate_output
  45. EXCEPTIONS
  46. no_input_given = 1
  47. communication_failure = 2 MESSAGE g_msg
  48. system_failure = 3 MESSAGE g_msg
  49. OTHERS = 4.
  50. CASE sy-subrc.
  51. WHEN 1.
  52. g_out = 'Exception received: NO_INPUT_GIVEN' .
  53. WHEN 2.
  54. CONCATENATE 'COMMUNICATION_FAILURE received:' g_msg INTO g_out SEPARATED
  55. BY space.
  56. WHEN 3.
  57. CONCATENATE 'SYSTEM_FAILURE received:' g_msg INTO g_out SEPARATED BY
  58. space.
  59. WHEN 4.
  60. g_out = 'Exception received: OTHERS'.
  61. ENDCASE.
  62. IF sy-subrc <> 0.
  63. WRITE g_out.
  64. ENDIF.
  65.  
  66. "MESSAGE g_msg TYPE 'I'.
  67. MESSAGE 'Pesel OK' TYPE 'S'.
  68. ENDIF.
  69.  
  70. ENDIF.
  71.  
  72. " LEAVE TO SCREEN 0.
  73. ENDMODULE. " READ_PESEL INPUT
  74. *&---------------------------------------------------------------------*
  75. *& Module CHECK_INPUT INPUT
  76. *&---------------------------------------------------------------------*
  77. * text
  78. *----------------------------------------------------------------------*
  79. MODULE check_input INPUT.
  80.  
  81. ENDMODULE. " CHECK_INPUT INPUT
  82. *&---------------------------------------------------------------------*
  83. *& Module EXIT INPUT
  84. *&---------------------------------------------------------------------*
  85. * text
  86. *----------------------------------------------------------------------*
  87. MODULE exit INPUT.
  88. CASE ok_code.
  89. WHEN 'CANCEL'.
  90. CLEAR ok_code.
  91. LEAVE TO SCREEN 0.
  92. WHEN 'EXIT'.
  93. LEAVE PROGRAM.
  94. ENDCASE.
  95. ENDMODULE. " EXIT INPUT

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.