cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle Errors in Feature Pack1 through Handcraft Solution

Former Member
0 Kudos

Hi,

Hi,

We are  using the handcraft solution for the development based on Duet Future pack 1 development guide.

But I am not able to display the text in output. It is getting only Id and text is displaying like  <text>S:LR:221</text>

Please see the below code for adding bapi message in post mapper method and also output for the same.

Can you please help me on this if you have any idea about this problem.

call method lo_message_container->add_message
      exporting
        is_object_key      = ls_key
        iv_msg_type        = ls_response_return-type "/iwcnt/cl_bec_bpc_cust_const=>gc_error_message"'E'
        iv_msg_id          = ls_response_return-id "/iwcnt/cl_bec_bpc_cust_const=>gc_iwcnt_service_msgclass"'/IWCNT/SERVICES'
        iv_msg_number      = ls_response_return-number"/iwcnt/cl_bec_bpc_cust_const=>gc_message_number_012 "'012'
        IV_MSG_TEXT        = ls_response_return-MESSAGE
        iv_msg_v1          = ls_response_return-MESSAGE_V1 "lv_msgv1
        iv_msg_v2          = ls_response_return-MESSAGE_V2"lv_msgv2
        iv_message_creator = 'SAS' ."/iwcnt/cl_bec_bpc_cust_const=>gc_tango_ser_appl.

output

<nm:StandardMessageFault_LM xmlns:nm="http://sap.com/xi/SAPGlobal/Global" xmlns:prx="urn:sap.com:proxy:NW1:/1SAI/TAS9EF2D25AC1590B315401:702">
- <standard>
  <faultText>Standard Message Fault</faultText>
- <faultDetail>
  <severity>error</severity>
  <text>S:LR:221</text>
  <id>221(LR)</id>
  </faultDetail>
- <faultDetail>
  <severity>error</severity>
  <text>S:LR:221</text>
  <id>221(LR)</id>
  </faultDetail>
- <faultDetail>
  <severity>warning</severity>
  <text>The SAP system could not process your request. Contact your administrator</text>
  <url>http://MSTCNW702.litware.com:8000/sap/xi/docu_apperror?ID=NA&OBJECT=%2fIWFND%2fCOD011&LANGUAGE=E</url>
  <id>011(/IWFND/COD)</id>
  </faultDetail>
  </standard>
  </nm:StandardMessageFault_LM>

<

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Hi Venkat,
I am looking for similar solution for our handcrafted development w r t  p 6.5.7 (page 112) of Developer guide.
Can you help me reproduce the error, you are getting?
Can you elaborate on where did you place your
call method
lo_message_container ->add_message
Where is the error displayed?
Is it in Sharepoint external list .
Awaiting your reply.
Thanks ,
Vishal
Former Member
0 Kudos

Hi Vishal,

 

The error is coming while tesing the SPROXY service.not in sharepoint external list.

Please see the below code for adding bapi message in post mapper method and also output for the same.


* loop through the results
      LOOP AT ls_response_rfc-return INTO ls_response_return.
* check for error conditions
        IF ls_response_return-type EQ 'E' OR ls_response_return-type EQ 'A'.
* if there was an error
          ls_key-value = 'na'.
*          ls_key-scheme_agency_id = iv_system_alias.
          lv_msg_text = ls_response_return-message.
* add a message to the message container. This is the message that will be logged
* in SharePoint and shown in the SharePoint UI
* as well so it is important to add a useful message here
          CALL METHOD lo_message_container->add_messages_from_bapi
            EXPORTING
              is_object_key      = ls_key " ID of the object whose proccessing caused the errors
              it_bapi_messages   = ls_response_rfc-return " Table of BAPIRET2 messages
              iv_message_creator = /capnwlm/cl_constants=>lc_tango_ser_appl. “’SAS’"'.
*          lo_message_container->add_message_text_only( is_object_key               = ls_key
*                                                             iv_msg_type           = /iwfnd/cl_logger=>error
*                                                             iv_msg_text           = lv_msg_text  "à this TEXT IS FROM bapi response
*                                                             iv_error_category     = /iwfnd/if_message_container=>gcs_error_category-processing
*                                                             iv_is_leading_message = abap_true
*                                                             iv_message_creator    = 'SAS' ). " /capnwlm/cl_constants=>lc_tango_ser_appl ).
**  Create your own message class and add the message accordingly..
*    call method lo_message_container->add_message
*      exporting
*        is_object_key      = ls_key
*        iv_msg_type        = ls_response_return-type "/iwcnt/cl_bec_bpc_cust_const=>gc_error_message"'E'
*        iv_msg_id          = ls_response_return-id "/iwcnt/cl_bec_bpc_cust_const=>gc_iwcnt_service_msgclass"'/IWCNT/SERVICES'
*        iv_msg_number      = ls_response_return-number"/iwcnt/cl_bec_bpc_cust_const=>gc_message_number_012 "'012'
*        IV_MSG_TEXT        = ls_response_return-MESSAGE
*        iv_msg_v1          = ls_response_return-MESSAGE_V1 "lv_msgv1
*        iv_msg_v2          = ls_response_return-MESSAGE_V2"lv_msgv2
*        iv_is_leading_message = abap_true
*        iv_message_creator = 'SAS' ."/iwcnt/cl_bec_bpc_cust_const=>gc_tango_ser_appl.


          " Name of the Component which created the message
* set the result code to failed in order to trigger creating a fault message
          CALL METHOD io_request_context->set_result_code
            EXPORTING
              iv_result_code = /iwfnd/if_srd_request_context=>cs_result_code-failed_permanent.
* this code controls the further flow so in case of an error code
* no subsequent Mappers will be processed
          ev_process_code = /iwfnd/if_srd_bop_map=>cs_process_code-fail_operation.
        ENDIF.
      ENDLOOP.

Output:

- <nm:StandardMessageFault_LM xmlns:nm="http://sap.com/xi/SAPGlobal/Global" xmlns:prx="urn:sap.com:proxy:NW1:/1SAI/TAS9EF2D25AC1590B315401:702">
- <standard>
  <faultText>Standard Message Fault</faultText>
- <faultDetail>
  <severity>warning</severity>
  <text>S:LR:206 16.00 8.00</text>
  <id>206(LR)</id>
  </faultDetail>
- <faultDetail>
  <severity>error</severity>
  <text>S:LR:221</text>
  <id>221(LR)</id>
  </faultDetail>
- <faultDetail>

Regards,

Venkat.

Advay
Employee
Employee
0 Kudos

Hi Venkat,

Can you uncomment the add_message piece of code and make the message as leading message.

call method lo_message_container->add_message

      exporting

        is_object_key      = ls_key

        iv_msg_type        = ls_response_return-type "/iwcnt/cl_bec_bpc_cust_const=>gc_error_message"'E'

        iv_msg_id          = ls_response_return-id "/iwcnt/cl_bec_bpc_cust_const=>gc_iwcnt_service_msgclass"'/IWCNT/SERVICES'

        iv_msg_number      = ls_response_return-number"/iwcnt/cl_bec_bpc_cust_const=>gc_message_number_012 "'012'

        IV_MSG_TEXT        = ls_response_return-MESSAGE

       iv_msg_v1          = ls_response_return-MESSAGE_V1 "lv_msgv1

        iv_msg_v2          = ls_response_return-MESSAGE_V2"lv_msgv2

        iv_is_leading_message = abap_true

        iv_message_creator = 'SAS' ."/iwcnt/cl_bec_bpc_cust_const=>gc_tango_ser_appl.

The parameters with Bold are most important while adding the message to message container.

Former Member
0 Kudos

Hi Advay,

Thank you for your reply.

I have uncommented the add_messge code and added the abap_true stement also but still text is not coming . Only coming out id and variables message_v1 and message_v2(

<text>S:HRTIM00REC:014 01 EARN</text> ).

Please see the below code and help me if anything we are missing.

Here is my code in post mapper method.

---------------------------------------------------------------------------------------------------------------------------------------------------

   * cast the generic BOP interface do to the specific generated BOP


  lo_bop_do ?= io_bop_do.

* fill the key structure fields that are constant in the error or non error case


  ls_key-scheme_id = 'CAPNWLM~CRUD'. ""SCL Business Object (GSDO Type) to be used


  ls_key-scheme_agency_id = iv_system_alias.

lo_message_container = io_request_context->get_message_container( ).
* if the instance was created
 
IF io_gsdo IS BOUND.* save the old id
    es_id_mapping-old_id = io_gsdo->get_id( ).
* get the root node
    lo_gsdo_root_node = io_gsdo->get_root_node( ).
* get the RFC response
    lo_bop_do->get_response(
IMPORTING es_response = ls_response_rfc ).

    lt_catsrecords_out = ls_response_rfc-catsrecords_out.

* if there were return results


   

*      READ TABLE ls_response_rfc-return INTO ls_response_return INDEX 1.

* check for error conditions
       
IF ls_response_return-type EQ 'E' OR ls_response_return-type EQ 'A'.

* if there was an error
          ls_key-
value = 'na'.

IF ls_response_rfc-return IS NOT INITIAL.* loop through the results
     
LOOP AT ls_response_rfc-return INTO ls_response_return.

          lv_msg_text = ls_response_return-message.

**  Create your own message class and add the message accordingly..
   
call method lo_message_container->add_message
     
exporting
        is_object_key      = ls_key
        iv_msg_type        = ls_response_return-
type "/iwcnt/cl_bec_bpc_cust_const=>gc_error_message"'E'
        iv_msg_id          = ls_response_return-
id "/iwcnt/cl_bec_bpc_cust_const=>gc_iwcnt_service_msgclass"'/IWCNT/SERVICES'
        iv_msg_number      = ls_response_return-number
"/iwcnt/cl_bec_bpc_cust_const=>gc_message_number_012 "'012'
        IV_MSG_TEXT        = ls_response_return-
MESSAGE
        iv_msg_v1          = ls_response_return-MESSAGE_V1
"lv_msgv1
        iv_msg_v2          = ls_response_return-MESSAGE_V2
"lv_msgv2
        iv_is_leading_message = abap_true
        iv_message_creator =
'SAS' ."/iwcnt/cl_bec_bpc_cust_const=>gc_tango_ser_appl.

         
" Name of the Component which created the message

* set the result code to failed in order to trigger creating a fault message
         
CALL METHOD io_request_context->set_result_code
           
EXPORTING
              iv_result_code = /iwfnd/if_srd_request_context=>cs_result_code-failed_permanent.

* this code controls the further flow so in case of an error code

* no subsequent Mappers will be processed
          ev_process_code = /iwfnd/if_srd_bop_map=>cs_process_code-fail_operation.
       
ENDIF.
     
ENDLOOP.
   
ENDIF.
   
IF ev_process_code <> /iwfnd/if_srd_bop_map=>cs_process_code-fail_operation .

*    LOOP AT lt_catsrecords_out INTO ls_catsrecords_out  .
     
READ TABLE  lt_catsrecords_out INTO ls_catsrecords_out INDEX 1.
     
IF sy-subrc = 0.
        ls_key-
value = ls_catsrecords_out-employeenumber.  "Sclkey.
        lo_gsdo_root_node->set_key( is_key = ls_key ).
* set the new id, this is very important otherwise the key will not be returned* correctly to the calling server proxy
        es_id_mapping-new_id = io_gsdo->get_id( ).
     
ENDIF.

*    ENDLOOP.
   
ENDIF.
 
ENDIF.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Output:

- <nm:StandardMessageFault_LM xmlns:nm="http://sap.com/xi/SAPGlobal/Global" xmlns:prx="urn:sap.com:proxy:NW1:/1SAI/TAS9EF2D25AC1590B315401:702">

- <standard>

<faultText>Standard Message Fault</faultText>

- <faultDetail>

<severity>error</severity>

<text>S:HRTIM00REC:014 01 EARN</text>

<id>014(HRTIM00REC)</id>

</faultDetail>

- <faultDetail>

<severity>error</severity>

<text>S:LR:221</text>

<id>221(LR)</id>

</faultDetail>

- <faultDetail>

<severity>error</severity>

<text>S:LR:221</text>

<id>221(LR)</id>

</faultDetail>

- <faultDetail>

<severity>warning</severity>

<text>The SAP system could not process your request. Contact your administrator</text>

<url>http://MSTCNW702.litware.com:8000/sap/xi/docu_apperror?ID=NA&OBJECT=%2fIWFND%2fCOD011&LANGUAGE=E</url>

<id>011(/IWFND/COD)</id>

</faultDetail>

</standard>

</nm:StandardMessageFault_LM>

     Thanks & Regards,

     Venkat.

Advay
Employee
Employee
0 Kudos

Hi Venkat,

The  add_message () method of class /IWFND/IF_MESSAGE_CONTAINER, expects a message class and message id. In you code, you are passing these 2 values (which are nothing but message class and message number of the BACKEND system).

The message class, I assume is HRTIM00REC and message number being 014.

As this specific message class is not present in Gateway system, it just prints the name of the class.

What you can do is, create your own message class (via SE91), and create a new message "Business exception &1 &2"

In the varible you can pass the exact error that is thrown by backend RFC.

call method lo_message_container->add_message
     
exporting
        is_object_key      = ls_key
        iv_msg_type        = ls_response_return-
type "/iwcnt/cl_bec_bpc_cust_const=>gc_error_message"'E'
        iv_msg_id          = Your Message Class (ZAPP_MSG)

        iv_msg_number      = Your Message Number

        IV_MSG_TEXT        = ls_response_return-
MESSAGE
        iv_msg_v1          = ls_response_return-MESSAGE_V1
"lv_msgv1
        iv_msg_v2          = ls_response_return-MESSAGE_V2
"lv_msgv2
        iv_is_leading_message = abap_true
        iv_message_creator =
'SAS' ."/iwcnt/cl_bec_bpc_cust_const=>gc_tango_ser_appl.

Let me know if this works for you.

BR, Advay

Former Member
0 Kudos

Hi Advay,

Thank you for your help.

I have done the changes as per you mentioned above.

Now it is working fine.

Thanks & Regards,

Venkat.

Answers (1)

Answers (1)

apachon
Participant
0 Kudos

Hi,

is possible return messages BAPIRETURN without throwing exception??

Best regards,

Former Member
0 Kudos

Hi,

Yes, it is possible to return messages from BAPIRETURN table.

If you are having a custom RFC, make sure the table that carries the messages is named as RETURN.

GW data model will internally map RETURN with BAPIRETURN.

Regards,

Advay