top of page

SAP ABAP - Get issue detail from Jira

Updated: Aug 29, 2022



First of all, you have to check Jira's API documentation.

The link of Jira API Documentation: here


  DATA : lv_user TYPE string,
               lv_pwd  TYPE string,
               lv_url  TYPE string.

  DATA : lv_http_status_code TYPE i,
               lv_status_text      TYPE string,
               lv_result_string    TYPE string.


  lv_url = <your_jira_domain> && '/rest/api/2/issue/'.
  lv_url = lv_url &&  <your_issue_id_you_need>.
  CALL METHOD cl_http_client=>create_by_url
    EXPORTING
      url                = lv_url
    IMPORTING
      client             = go_client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.

  IF sy-subrc NE 0.
    "" check your SAP server's internet connection or firewall configuration. Go to your basis   	
    ""team
    "" give error message

    RETURN.
  ENDIF.


  CALL METHOD go_client->authenticate
    EXPORTING
      username = lv_user  // jira_username
      password = lv_pwd.  // Jira api token

  go_client->request->set_method( 'GET' ).
  go_client->request->set_content_type( 'application/json' ).


 TRY.

      go_client->send(
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3
          http_invalid_timeout       = 4
          OTHERS                     = 5
      ).

      IF sy-subrc NE 0.

       // Give error message
        RETURN.
      ENDIF.


      go_client->receive(
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3
          OTHERS                     = 4
      ).

      IF sy-subrc NE 0.

        // Give error message
        RETURN.
      ENDIF.


    CATCH cx_root INTO DATA(lv_any_exp).

      // Give error message

      go_client->close(
        EXCEPTIONS
          http_invalid_state = 1
          OTHERS             = 2
      ).

      RETURN.
  ENDTRY.


CALL METHOD go_client->response->get_status
    IMPORTING
      code   = lv_http_status_code
      reason = lv_status_text.

  IF lv_http_status_code = 0 OR lv_http_status_code = 200.  "" success from jira
    // Give success message

    CALL METHOD go_client->response->get_cdata
      RECEIVING
        data = lv_result_string.



    cl_fdt_json=>json_to_data( EXPORTING iv_json = lv_result_string
                                                   CHANGING ca_data = e_output ).

  ELSE.  "" error from jira
    // Give error message
    
  ENDIF.

  go_client->close(
    EXCEPTIONS
      http_invalid_state = 1
      OTHERS             = 2
  ).



262 views0 comments

Recent Posts

See All
Post: Blog2_Post
bottom of page