Skip to Content
0
Former Member
Nov 11, 2005 at 03:59 PM

how to use BAPI_BUSPROCESSND_CHANGEMULTI and BAPI_ACTIVITYCRM_SAVE

97 Views

hi boys

I need to change some text in my operations massively, but my code doesn't work.

I exec tc CRMD_BUS2000126 to check if the orders were changed but nothing happends.

I Hope someone can help

rgds

A. Garduño

This is the code:

REPORT ZCRM_TOUCH_ORDERS .

TABLES: CRMD_ORDERADM_H .

DATA: BEGIN OF ZCRM_OBJECT_ID,

object_id TYPE CRMT_OBJECT_ID,

END OF ZCRM_OBJECT_ID,

it_object_id LIKE TABLE OF ZCRM_OBJECT_ID WITH HEADER LINE,

it_guid TYPE TABLE OF CRMT_OBJECT_GUID WITH HEADER LINE,

guid TYPE CRMT_OBJECT_GUID.

DATA: it_guid32 TYPE TABLE OF BAPIBUS20001_GUID_DIS,

wa_guid32 LIKE BAPIBUS20001_GUID_DIS,

it_text TYPE TABLE OF BAPIBUS20001_TEXT_DIS WITH HEADER LINE,

hit_text_za02 TYPE HASHED TABLE OF BAPIBUS20001_TEXT_DIS

WITH UNIQUE KEY REF_GUID.

DATA: BEGIN OF DOCS,

guid LIKE CRMD_ORDERADM_H-guid ,

object_id LIKE CRMD_ORDERADM_H-object_id,

text TYPE BAPIBUS20001_TEXT_DIS-TDLINE,

END OF DOCS,

it_docs LIKE TABLE OF DOCS.

*jus a few sample operations

APPEND '0201340821' TO it_object_id.

APPEND '0201340816' TO it_object_id.

APPEND '0201340831' TO it_object_id.

APPEND '0201340841' TO it_object_id.

*get guids from crmd_orderadm_h

SELECT guid INTO TABLE it_guid FROM CRMD_ORDERADM_H

FOR ALL ENTRIES IN it_object_id

WHERE object_id = it_object_id-object_id.

*cast it to a format for bapi_bussprocessnd_getdetailmul

it_guid32 = it_guid[] .

*get text for each opeartion

CALL FUNCTION 'BAPI_BUSPROCESSND_GETDETAILMUL'

TABLES

guid = it_guid32

text = it_text .

*I'm just interested in text witht tdid = ZA02 and...

*put it_text in a hashed table

LOOP AT it_text WHERE tdid = 'ZA02'.

INSERT it_text INTO TABLE hit_text_za02 .

ENDLOOP.

FIELD-SYMBOLS -tdline

SEPARATED BY SPACE.

ENDLOOP.

*LOOP AT hit_text_za02 INTO wa.

  • WRITE: AT / wa-ref_guid, wa-tdline .

*ENDLOOP .

DATA:it_text_ins TYPE TABLE OF BAPIBUS20001_TEXT_INS WITH HEADER LINE,

i_fields TYPE TABLE OF BAPIBUS20001_INPUT_FIELDS WITH HEADER LINE.

*put modified data in it_text_ins

MOVE hit_text_za02 TO it_text_ins[].

*LOOP AT it_text_ins.

  • WRITE: AT / it_text_ins-ref_guid, it_text_ins-tdline .

*ENDLOOP .

LOOP AT it_guid32 INTO wa_guid32.

i_fields-ref_guid = wa_guid32 .

i_fields-ref_kind = 'B' .

i_fields-objectname = 'TEXTS'.

APPEND i_fields.

ENDLOOP.

*LOOP AT i_fields .

  • WRITE AT / i_fields-ref_guid .

*ENDLOOP.

*change order

CAll FUNCTION 'BAPI_BUSPROCESSND_CHANGEMULTI'

TABLES

INPUT_FIELDS = i_fields

TEXT = it_text_ins .

*make changes persitent in the database

CALL FUNCTION 'BAPI_ACTIVITYCRM_SAVE'

TABLES

OBJECTS_TO_SAVE = it_guid32 .

Message was edited by: Gerardo Cepeda