cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with BAPI

Former Member
0 Kudos

hi,

I have written a se38 program to change the status o an activity in a complaint tcode CIC0. I have written the following coed. but then it doesn't work I am forwarding the code too. can you please cgeck and tell me where I am going wrong :

REPORT  Z_CRMORDERREAD.

data : lt_header_guid type CRMT_OBJECT_GUID_TAB,
       wa_header_guid 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,

       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.

   wa_header_guid = '443A2B18B2AA01D802000000888DE636'.
*                    443A2B18B2AA01D802000000888DE636
     append wa_header_guid to lt_header_guid.

     CALL FUNCTION 'CRM_ORDER_READ'
      EXPORTING
         IT_HEADER_GUID                = lt_header_guid
      IMPORTING
         ET_STATUS                     = lt_status
         ET_DOC_FLOW                   = lt_doc_flow
               .
     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_header_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.

was_status-ref_guid = wa_doc_flow-objkey_b.
was_status-status = 'E0004'.
append was_status to s_status.

wasx_status-ref_guid = 'X'.
wasx_status-status = 'X'.
append wasx_status to sx_status.


CALL FUNCTION 'BAPI_ACTIVITYCRM_CHANGEMULTI'
 TABLES
   HEADER              = h_header
   HEADERX             = hx_header

   STATUS              = s_status
   STATUSX             = sx_status
   RETURN              = return
          .


commit work.
write sy-subrc.
*loop at return.
*
*endloop.

break-point.

Regards,

Vijay.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Varun,

If you read documentation of FM 'BAPI_ACTIVITYCRM_CHANGEMULTI' it clearly says that you need follow it with a call FM BAPI_ACTIVITYCRM_SAVE.

After this, BAPI_TRANSACTION_COMMIT needs to be called.

This is the basic usage for any BAPI that works on Business transactions like avtivity, contracts, etc.

1. Change business transaction - using FM CRM_ORDER_MAINTAIN (All BAPIs like BAPI_ACTIVITYCRM_CHANGEMULTI eventually call CRM_ORDER_MAINTAIN).

2. Save the changed docuement -using CRM_ORDER_SAVE (again, all save BAPIs eventually call CRM_ORDER_SAVE)

3. Commit changs to DB using BAPI_TRANSACTION_COMMIT or simply commit work.

Please close the thread if this solves your problem.

Regards

Kaushal

Former Member
0 Kudos

Hi,

If it is just the status you wish to maintain use function module CRM_ORDER_CHANGE_STATUS

You also need to call function module CRM_ORDER_SAVE after each service ticket change.

Please reward point if this works.

Cheers

Colin.

Former Member
0 Kudos

Hi ,

I dont think the above said FM's work for this. Can anybody tell why my code is not working.

Regards,

Varun.

Former Member
0 Kudos

Does the function give back information in the return parameter?

Former Member
0 Kudos

Hi,

Yeah It does.

Regards,

Varun.

Former Member
0 Kudos

... What exactly does it say?

any messages?

Former Member
0 Kudos

Hi,

These are the messages in the BAPI return structure :

Type Message Class Number Description

W CRM_ORDER 004 Referenced object type (STATUS) not allowed

S CRM_MESSAGES 006 Start of processing 'Individual receipt'

Regards,

Varun.

Former Member
0 Kudos

Hi,

can you set the status in the online tranaction?

--> maybe your status profile is configured in such a way that it doesn't allow this user status in the present state of the activity.

Michael.

Former Member
0 Kudos

Hi,

sadly the documentation of the bapi is very poor.

But the BAPI works fine at all.

Try to fill the structures like this:

.....
*SET HEADER
ls_act_header_bapi-guid = 47568315A45.....
ls_act_header_bapi-handle = 1. "e.g.
APPEND ls_act_header_bapi TO lt_act_header_bapi.

CLEAR ls_input_bapi.
ls_input_bapi-ref_guid = 47568315A45.....
ls_input_bapi-ref_handle = 1.
ls_input_bapi-ref_kind = 'A'. 
ls_input_bapi-objectname = 'ORDERADM_H'.
ls_input_bapi-logical_key = '0001'. "e.g.
APPEND ls_input_bapi TO lt_input_bapi.

*SET STATUS
ls_status_bapi-ref_handle = 1.
ls_status_bapi-ref_guid = 47568315A45.....
ls_status_bapi-ref_kind = 'A'.
ls_status_bapi-status = 'E0004'. "e.g.
ls_status_bapi-user_stat_proc = ..."enter your status sheme here
ls_status_bapi-activate = 'X'. 
APPEND ls_status_bapi TO lt_status_bapi.

*Set the change fields
ls_statusx_bapi-status = 'X'.
ls_statusx_bapi-activate = 'X'.
ls_statusx_bapi-user_stat_proc = 'X'.
APPEND ls_statusx_bapi TO lt_statusx_bapi.

CLEAR ls_input_bapi.
ls_input_bapi-ref_guid = 47568315A45.....
ls_input_bapi-ref_handle = 1.
ls_input_bapi-ref_kind = 'A'. 
ls_input_bapi-objectname = 'STATUS'.
ls_input_bapi-logical_key = '0001'. "e.g.
ls_input_bapi-fieldname = 'STATUS'. 
APPEND ls_input_bapi TO lt_input_bapi.
ls_input_bapi-fieldname = 'USER_STAT_PROC'.
APPEND ls_input_bapi TO lt_input_bapi.
ls_input_bapi-fieldname = 'ACTIVATE'.
APPEND ls_input_bapi TO lt_input_bapi.

CALL FUNCTION 'BAPI_ACTIVITYCRM_CHANGEMULTI'
TABLES
HEADER = lt_act_header_bapi
STATUS = lt_status_bapi
STATUSX = lt_statusx_bapi
INPUT_FIELDS = lt_input_bapi
RETURN = lt_return2.
.....

then you call BAPI_ACTIVITYCRM_SAVE

and BAPI_TRANSACTION_COMMIT and it should work.

sorry. our customer has disabled the copy/paste function in the browser, so I only give you this snippet.

Try if it works, you perhaps have not to fill all fields but there are all mandatory fields mentioned. I use this programm to set the status after a migration of thousands of activitys and it works fine.

Hope it helps a little bit

Greetings

Chris

Former Member
0 Kudos

Hi,

I have a similar case. We are trying to change some partner id's from an activity as:

CALL FUNCTION 'BAPI_ACTIVITYCRM_CHANGEMULTI'

TABLES

PARTNER = lt_prtnr_set

PARTNERX = lt_prtnr_ch_flg

RETURN = lt_rtn.

in partnerx, REF_PARTNER_NO = 'X' (the only field that is updated) also, iam calling BAPI_TRANSACTION_COMMIT after CHANGEMULTI. Still, the changes are not being saved.

Also, should the no of lines in PARTNER and PARTNERX tables be same ? can you please comment on how to populate PARTNER and PARTNERX tables ?

Former Member
0 Kudos

Hi,

have you filled all input-fields and the header structure as well? You have to fill ref_kind, object_type, logical_key, etc.

It´s hard to say why your code doesn´t work without having a look on it. Can you poste the relevant structures and how you fill the fields?

Greetings

Chris

Former Member
0 Kudos

Hi Christian,

I have a similar problem.

I am trying to create sales order transaction using BAPI

'BAPI_SLSTRANSACT_CREATEMULTI'.The BAPI creates the information for the object name 'ORDERADM_H' and 'ORDERADM_I'.When I tried to include the object 'ORGMAN' the BAPI return table RETURN shows the following message

A CRM_ORDER 017 An authorization check could not be executed

The input fields and ORGAMAN structure are as follows.

IT_INPUT_FIELDS-REF_HANDLE = V_HAND_O.
IT_INPUT_FIELDS-OBJECTNAME = 'ORGMAN'.
IT_INPUT_FIELDS-ref_kind = 'A'.
IT_INPUT_FIELDS-FIELDNAME = 'REF_HANDLE'.
APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-REF_HANDLE = V_HAND_O.
IT_INPUT_FIELDS-OBJECTNAME = 'ORGMAN'.
IT_INPUT_FIELDS-ref_kind = 'A'.
IT_INPUT_FIELDS-FIELDNAME = 'DIS_CHANNEL'.
APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-REF_HANDLE = V_HAND_O.
IT_INPUT_FIELDS-OBJECTNAME = 'ORGMAN'.
IT_INPUT_FIELDS-ref_kind = 'A'.
IT_INPUT_FIELDS-FIELDNAME = 'SALES_ORG'.
APPEND IT_INPUT_FIELDS.

IT_ORG-REF_HANDLE = V_HAND_O.
IT_ORG-DIS_CHANNEL = '10'.
IT_ORG-SALES_ORG = 'O 50000001'.
IT_org-ref_kind = 'A'.
APPEND IT_ORG.

The handle V_HAND_O was generated through FM 'CRM_PRP_IL_GET_HANDLE'.

Is this an authorization issue.

Thanks,

Chamu

Former Member
0 Kudos

Hi All,

Had the same problem.

Nothing happend when using 'CRM_ORDER_CHANGE_STATUS'

But when calling 'CRM_ORDER_SAVE' afterwards and finishing of with a COMMIT WORK it worked.

Hope that it helps.

Best regards

Dennis

Former Member
0 Kudos

Hi Chamu,

Use REF_GUID instead of REF_HANDLE. Generate a guid using FM 'GUID_CREATE'.

Then it wont throw you the authorization exception.

Regards,

Karthik.

Former Member
0 Kudos

Hi Raviraj,

Whatever fields you handle in Partner, set an update flag TRUE (X) for that field in Partnerx.

Also everytime you append a line to the partner table, you need to append appropriate line to partnerx also.

Regards,

Karthik.

Former Member
0 Kudos

Hi Karthik,

Thank you so much.

I used REF_GUID and it worked.

Thanks,

Chamu

Former Member
0 Kudos

try to use function module 'CRM_ORDER_MAINTAIN' to chage the status.

Former Member
0 Kudos

HI,

I dont think the said FM works because none of the parameters have a field <b>status</b>.

Regards,

Varun.

Former Member
0 Kudos

Hi,

import parameter IT_STATUS of the said function ...

Michael.