Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

success of a BAPI

Former Member
0 Kudos

Hi all,

Can I check the success of BAPI using sy-subrc ? what does the warning message <b>Referenced object type (STATUS) not allowed</b>mean ? Say when I run the tcode mm02 from where the data will be fetched into the screens ? If it from sap tables , will any changes made directly to the database will be reflecetd on the screen or not ?

Regards,

Varun.

Message was edited by: varun sonu

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi,

check the return table of BAPI, it is of type BAPIRET2 or something.

read the table and find the success or failure.

Regards

vijay

25 REPLIES 25

former_member188685
Active Contributor
0 Kudos

Hi,

check the return table of BAPI, it is of type BAPIRET2 or something.

read the table and find the success or failure.

Regards

vijay

0 Kudos

Hi,

I have a warning mesage and success message. This is the warning message : <b>Referenced object type (STATUS) not allowed</b> STATUS is the field I am trying to change. What can I figure out from the warning message ? This is CRM related task.

Regards,

Varun.

0 Kudos

From the message number and class, check to see if there is a long text for the message.

Rob

0 Kudos

Hi Rob,

In the message class this is all I have :

<b>Referenced object type (&1) not allowed</b>

Regards,

Varun.

0 Kudos

Then what is the message number and class? It should be in bapireturn.

Rob

0 Kudos

Hi,

Message Class : CRM_ORDER

Number : 004

Regards,

Varun.

0 Kudos

Go to SE91 and enter the message class and number. When the messages are displayed, select number 004 and press the 'long text' button at the top. If there is a long text for this message, it will be displayed.

Rob

0 Kudos

Hi Rob,

When clicked on longtext it says the short description is quite sufficient.

Regards,

Varun

0 Kudos

Well, I don't have access to a CRM system, but maybe the others do. What BAPI are you trying to execute?

Rob

0 Kudos

Hi,

The BAPI I am trying to use is BAPI_ACTIVITYCRM_CHANGEMULTI.

I will forward you the whole code I have written.

REPORT Z_CRMORDERREAD.

data : lt_header_guid type CRMT_OBJECT_GUID_TAB,

wa_header_guid type CRMT_OBJECT_GUID,

wac type CRMT_OBJECT_GUID,

lt_doc_flow type CRMT_DOC_FLOW_WRKT,

wa_doc_flow type CRMT_DOC_FLOW_WRK,

lt_status type CRMT_STATUS_WRKT,

lt_SAVE type table of BAPIBUS20001_GUID_DIS,

wa_save type BAPIBUS20001_GUID_DIS,

h_header type table of BAPIBUS2000110_HEADER_INS,

wah_header type BAPIBUS2000110_HEADER_INS, " work area

hx_header type table of bapibus2000110_header_insx,

wahx_header type bapibus2000110_header_insx, " work area

s_status type table of BAPIBUS20001_STATUS_INS,

was_status type BAPIBUS20001_STATUS_INS, " work area

sx_status type table of BAPIBUS20001_STATUS_INSX,

wasx_status type BAPIBUS20001_STATUS_INSX. " work area

data : return type table of BAPIRET2,

vc_LOG_HANDLE type BALLOGHNDL. " log_handle

wa_header_guid = '442EFEBDF11501C700000000888DE636'.

append wa_header_guid to lt_header_guid.

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

IT_HEADER_GUID = lt_header_guid

  • IT_ITEM_GUID =

  • IV_MODE =

  • IV_ONLY_SPEC_ITEMS =

  • IT_REQUESTED_OBJECTS =

  • IV_NO_AUTH_CHECK =

  • IT_ITEM_USAGE_RANGE =

  • IV_SUBITEM_DEPTH = -1

  • IT_OBJECT_FILTER =

  • IV_ONLY_CHANGED_OBJ = FALSE

IMPORTING

  • ET_ORDERADM_H =

  • ET_OPPORT_H =

  • ET_LEAD_H =

  • ET_ACTIVITY_H =

  • ET_ORDERADM_I =

  • ET_ACTIVITY_I =

  • ET_PRODUCT_I =

  • ET_FINPROD_I =

  • ET_BATCH =

  • ET_CONFIG =

  • ET_STRUCT_I =

  • ET_SALES =

  • ET_PRICING =

  • ET_PRICING_I =

  • ET_ORGMAN =

  • ET_SHIPPING =

  • ET_CUSTOMER_H =

  • ET_CUSTOMER_I =

  • ET_SERVICE_H =

  • ET_SERVICE_I =

  • ET_SERVICE_ASSIGN =

  • ET_QUALIF =

  • ET_PAYPLAN =

  • ET_PAYPLAN_D =

  • ET_APPOINTMENT =

  • ET_TEXT =

  • ET_SCHEDLIN =

  • ET_PARTNER =

  • ET_SERVICE_OS =

  • ET_REFOBJ =

  • ET_SUBJECT =

  • ET_CUMULAT_H =

ET_STATUS = lt_status

  • ET_STATUS_H =

  • ET_SCHEDLIN_I =

  • ET_CANCEL =

  • ET_CANCEL_IR =

  • ET_CANCEL_CR =

  • ET_BILLPLAN =

  • ET_BILLING =

  • ET_ORDPRP_I =

  • ET_ORDPRP_I_D =

  • ET_ORDPRP_OBJL_I_D =

  • ET_CUMULATED_I =

ET_DOC_FLOW = lt_doc_flow

  • ET_EXCEPTION =

  • ET_PRIDOC =

  • ET_PRICE_AGREEMENTS_CRM =

  • ET_PRICE_AGREEMENTS_BBP =

  • ET_CONFIG_FILTER =

  • ET_SERVICEPLAN_I =

  • ET_SERVICEPLAN_IE =

  • ET_EXTENSION =

  • ET_CREDITVALUES =

  • ET_SURVEY =

  • ET_AC_ASSIGN =

CHANGING

CV_LOG_HANDLE = vc_LOG_HANDLE

  • EXCEPTIONS

  • DOCUMENT_NOT_FOUND = 1

  • ERROR_OCCURRED = 2

  • DOCUMENT_LOCKED = 3

  • NO_CHANGE_AUTHORITY = 4

  • NO_DISPLAY_AUTHORITY = 5

  • NO_CHANGE_ALLOWED = 6

  • OTHERS = 7

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at lt_doc_flow into wa_doc_flow.

*write 😕 wa_doc_flow-objkey_b.

wah_header-GUID = wa_doc_flow-objkey_b.

was_status-ref_guid = wa_doc_flow-objkey_b.

wac = wa_doc_flow-objkey_b.

wa_save-guid = wa_doc_flow-objkey_b.

*was_status-ref_guid = wa_header_guid. "wa_doc_flow-objkey_b.

append wah_header to h_header.

endloop.

wahx_header-GUID = 'X'.

append wahx_header to hx_header.

*loop at lt_doc_flow into wa_doc_flow.

*was_status-ref_guid = wa_header_guid. "wa_doc_flow-objkey_b.

was_status-status = 'E0004'.

was_status-REF_HANDLE = vc_LOG_HANDLE.

append was_status to s_status.

*endloop.

wasx_status-ref_guid = 'X'.

wasx_status-status = 'X'.

wasx_status-REF_HANDLE = 'X'.

append wasx_status to sx_status.

CALL FUNCTION 'BAPI_ACTIVITYCRM_CHANGEMULTI'

TABLES

HEADER = h_header

HEADERX = hx_header

  • PARTNER =

  • PARTNERX =

  • ORGANISATION =

  • ORGANISATIONX =

  • DATE =

  • DATEX =

  • TEXT =

  • TEXTX =

  • REASON =

  • REASONX =

  • OUTCOME =

  • OUTCOMEX =

STATUS = s_status

STATUSX = sx_status

  • LOCATION =

  • LOCATIONX =

  • INPUT_FIELDS =

RETURN = return

  • DOCUMENT_FLOW =

  • JOURNAL =

  • JOURNALX =

  • MATERIAL =

  • MATERIALX =

  • EXTENSIONIN =

.

*append wa_save to lt_save.

**commit work.

CALL FUNCTION 'BAPI_ACTIVITYCRM_SAVE'

  • EXPORTING

  • UPDATE_TASK_LOCAL = 1

  • SAVE_FRAME_LOG = 0

  • IMPORTING

  • LOG_HANDLE =

TABLES

OBJECTS_TO_SAVE = lt_SAVE

  • SAVED_OBJECTS =

  • RETURN =

.

call function 'BAPI_TRANSACTION_COMMIT'

exporting wait = 'X'.

*CALL FUNCTION 'CRM_ORDER_REGISTER_SAVEGRP_OW'

  • EXPORTING

  • iv_master_guid = wac

  • iv_slave_guid = wac.

*write sy-subrc.

break-point.

Regrads,

Varun.

0 Kudos

Varun,

Its not necessary to have a LONG TEXT for every message in your message class. Looks like this is one of them

There will be 4 paramters in the same record where you have recieved this message. Replace &1 with the first parameter and that is your error message.

There is some object that you are trying to refer, which the system is not allowing.

Regards,

Ravi

0 Kudos

Hi Varun,

is it warning message or Error message. i feel it is warning message, what do you say.

Regards

vijay

0 Kudos

HI,

This is warning message. You are absolutely correct. But what difference does it make ? The data is not updated to the database.

Regards,

Varun.

0 Kudos

Well, you've commented out the return and saved objects tables from the call to BAPI_ACTIVITYCRM_SAVE. Why don't you try un-commenting them and see what they hold?

Rob

0 Kudos

Hi varun,

are you using BAPI_TRANSACTION_COMMIT after your BAPI call.

Regards

vijay

0 Kudos

Hi Rob,

This is the inofrmation in the return and saved_ojects.

saved_objects : this table is empty

return : this has the follwoing message.

A crm_order 009 Program error: Incorrect values in interface parameters

Regards,

Varun.

Message was edited by: varun sonu

0 Kudos

So it looks like a problem with the call to BAPI_ACTIVITYCRM_SAVE. Is there documentation for this BAPI? If so, does it help?

Rob

0 Kudos

Hi Rob,

this is the info available in Documentation of the above said BAPI :

<b>

FU BAPI_ACTIVITYCRM_SAVE

____________________________________________________

Text

Save and Initialize Activities

Functionality

Functionality

Saving and initializing sales orders. This BAPI does not transmit a COMIT WORK. This must be transmitted explicitly via the service BAPI_TRANSACTION_COMMIT.

Notes

If the parameter UPDATE_TASK_LOCAL is reserved with the value TRUE, it is not necessary to reserve the parameter WAIT when you call up the service BAPI_TRANSACTION_COMMIT.

Further information

Parameters

UPDATE_TASK_LOCAL

SAVE_FRAME_LOG

LOG_HANDLE

OBJECTS_TO_SAVE

SAVED_OBJECTS

RETURN

Exceptions

Function Group

CRM_ACTIVITYCRM_BAPI

</b>

Regards,

Varun.

0 Kudos

Hi Rob,

Passing the table lt_save to the function module BAPI_ACTIVITYCRM_SAVE the return table contains the message : <b>The document could not be saved</b>

In se91 the long text provided or this is :

<b>

NA CRM_ORDER037

____________________________________________________

Text

The document could not be saved

Diagnosis

The document cannot be saved in this condition.

System response

The system cancelled saving the document.

Procedure

Detailed information is contained in the log for the document

</b>

Regards,

Varun.

0 Kudos

I think you also have to check the documentation for the parameters and check that against the parameters you are passing.

Rob

0 Kudos

In the original BAPI, in the return structure, or in any of the other return structures, was there a document number given? If so, is there a log against which you can look at?

Rob

Former Member
0 Kudos

You have to check the contents of the bapireturn table.

Rob

naimesh_patel
Active Contributor
0 Kudos

Hello Varun,

Read the return table. You will find the messag number for all messages. Read the table with your message, which says process ends sucessfully.

Regards,

Naimesh

Former Member
0 Kudos

Hi,

You should NOT check for sy-subrc. Instead check for messages in RETURN table.

Regards,

Ravi

former_member181962
Active Contributor
0 Kudos

The data that is being viewed in mm02 transaction is being fetched from database only.

If you change the database in whatever way you want, it must be visible in the transaction.

If you are updating the database using bapi, and u are not able to view it in transaction, then it means your update to the database wasn't successful.

BAPIRET2 is the structure which has the messages.

Regards,

Ravi