on 08-25-2012 12:45 PM
Hello Experts,
I have written ABAP program to trigger data change from SAP to SUP.
I am getting HTTP Communication error on receive.
client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ) .
I have setup the RFC destination , do i need to setup the logical port.
what configuration i need to do in R/3
Thanks in Advance.
Regards
Manish
I do not have any problem on SUP.
I have written code to Push Data from ABAP to SUP .
When i manually run from browser from REST client data is pushed to SUP.
I am getting error of http communication on receive, here is my code
client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ) .
IF sy-subrc <> 0.
client->get_last_error(
IMPORTING
code = subrc
message = errortext
) .
WRITE: / 'communication_error( receive )', / 'code: ', subrc, 'message: ', errortext.
EXIT.
ELSE. " not communicaiton error
client->response->get_status(
IMPORTING
code = http_rc
reason = http_reason ).
IF http_rc NE 200 .
WRITE : 'Error. HTTP response code:' , http_rc , / , http_reason .
ELSE.
Do i need to do any setting to configure web service in ABAP
I have already gone through both the post
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
* Below is the piece of Code
REPORT z_notif_json_send.
*&---------------------------------------------------------------------* *& Report Z_FLIGHT_JSON_SEND *& *&---------------------------------------------------------------------* *& *&
*&---------------------------------------------------------------------*
INCLUDE z_dcn_utils .
DATA : lv_body TYPE string ,
lv_id TYPE string ,
json_content TYPE string ,
json_data TYPE string ,
json_col TYPE string ,
dcn_id TYPE string.
DATA : http_rc TYPE i ,
http_reason TYPE string,
lt_return TYPE TABLE OF bapiret2 .
DATA : dest TYPE rfcdest ,
client TYPE REF TO if_http_client ,
errortext TYPE string,
subrc TYPE sy-subrc.
DATA: lv_resp TYPE string,
lt_match_open TYPE match_result_tab ,
lt_match_close TYPE match_result_tab ,
lw_match_open TYPE match_result ,
lw_match_close TYPE match_result,
lt_string TYPE TABLE OF string ,
lw_string TYPE string , lf_length TYPE i.
DATA : lt_notif_list TYPE TABLE OF mam_30_notif_header.
FIELD-SYMBOLS <notif> LIKE LINE OF lt_notif_list.
START-OF-SELECTION.
DATA maxrow TYPE bapisflaux-bapimaxrow .
maxrow = 15 .
CALL FUNCTION 'MAM30_011_GETLIST'
EXPORTING
user = 'SAPUSER'
TABLES
notification_list = lt_notif_list
return = lt_return.
LOOP AT lt_notif_list
ASSIGNING <notif> .
CLEAR : json_col , json_content.
PERFORM write_string_to_json USING 'NOTIF_NO' <notif>-notif_no CHANGING json_content .
PERFORM write_string_to_json USING 'mbo' 'GetList' CHANGING json_content .
PERFORM write_string_to_json USING 'op' ':upsert' CHANGING json_content .
PERFORM write_string_to_json USING 'EQUIPMENT' <notif>-equipment CHANGING json_col.
PERFORM write_string_to_json USING 'PLANPLANT' <notif>-planplant CHANGING json_col.
PERFORM write_string_to_json USING 'NOTIF_TYPE' <notif>-notif_type CHANGING json_col.
PERFORM write_date_to_json USING 'NOTIF_DATE' <notif>-notif_date CHANGING json_col.
PERFORM write_string_to_json USING 'SHORT_TEXT' <notif>-short_text CHANGING json_col.
PERFORM write_string_to_json USING 'PRIORITY' <notif>-priority CHANGING json_col.
PERFORM write_string_to_json USING 'CAT_TYPE' <notif>-cat_type CHANGING json_col.
PERFORM write_string_to_json USING 'CODE_GROUP' <notif>-cat_type CHANGING json_col.
PERFORM write_string_to_json USING 'CODING' <notif>-coding CHANGING json_col.
PERFORM write_string_to_json USING 'SERIALNO' <notif>-serialno CHANGING json_col.
IF sy-tabix = 1 .
CONCATENATE '{' json_content ',"cols":{' json_col '}}' INTO json_data .
ELSE.
CONCATENATE json_data ',{' json_content ',"cols":{' json_col '}}' INTO json_data .
ENDIF.
ENDLOOP.
CONCATENATE '{"pkg":"dummy","messages":[' json_data ']}' INTO lv_body. dest = 'DCN_DESTINATION' .
cl_http_client=>create_by_destination(
EXPORTING
destination = dest
IMPORTING client = client
EXCEPTIONS
destination_not_found = 1
internal_error = 2
argument_not_found = 3
destination_no_authority = 4
plugin_not_active = 5 OTHERS = 6 ) .
client->request->set_form_field(
EXPORTING name = 'cmd'
value = 'dcn') .
client->request->set_form_field(
EXPORTING
name = 'domain'
value = 'default') .
client->request->set_form_field(
EXPORTING name = 'package'
value = 'DCN1:1.0') .
client->request->set_cdata( lv_body ).
client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ) .
IF sy-subrc <> 0.
client->get_last_error(
IMPORTING
code = subrc
message = errortext ) .
WRITE: / 'communication_error( send )', / 'code: ', subrc, 'message:' , errortext.
EXIT.
ENDIF.
client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ) .
IF sy-subrc <> 0.
client->get_last_error(
IMPORTING
code = subrc
message = errortext
) .
WRITE: / 'communication_error( receive )', / 'code: ', subrc, 'message: ', errortext.
EXIT.
ELSE. " not communicaiton error
client->response->get_status(
IMPORTING
code = http_rc
reason = http_reason ).
IF http_rc NE 200 .
WRITE : 'Error. HTTP response code:' , http_rc , / , http_reason .
ELSE.
* *HTTP return code 200 Check Application error. *check if there is any record which contain false with Regex.
lv_resp = client->response->get_cdata( ).
FIND ALL OCCURRENCES OF REGEX '\{' IN lv_resp RESULTS lt_match_open.
FIND ALL OCCURRENCES OF REGEX '\}' IN lv_resp RESULTS lt_match_close.
LOOP AT lt_match_open INTO lw_match_open .
READ TABLE lt_match_close INTO lw_match_close INDEX sy-tabix.
lf_length = lw_match_close-offset - lw_match_open-offset + 1 .
lw_string = lv_resp+lw_match_open-offset(lf_length) .
APPEND lw_string TO lt_string .
ENDLOOP.
DATA num TYPE i .
LOOP AT lt_string INTO lw_string.
FIND ALL OCCURRENCES OF REGEX 'false' IN lw_string MATCH COUNT num .
IF num > 0 .
WRITE lw_string .
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
Could you please add some more details, your abap code, any sup errors, etc. Did you refer to the sup help docs to validate that your process?
This blog should help too...
http://scn.sap.com/community/developer-center/mobility-platform/blog/2012/06/11/calling-the-sup-data...
Regards,
Jamie
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.