cancel
Showing results for 
Search instead for 
Did you mean: 

how to use BAPI_BUSPROCESSND_CHANGEMULTI and BAPI_ACTIVITYCRM_SAVE

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I have modified the code and its working fine now.

The line

MOVE hit_text_za02 TO it_text_ins[] is incorrect .

Both structures are not similar and data is mismatching here in it_text_ins.

and BAPIBUS20001_TEXT_INS-MODE should set to 'A' .

Use the following code and let me know whether it is resolved your issue.

Thanks,

Thirumala.

&----


*& Report ZCRM_TOUCH_ORDERS *

*& *

&----


*& *

*& *

&----


REPORT ZCRM_TOUCH_ORDERS .

include CRM_OBJECT_NAMES_CON.

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 TABLE OF BAPIBUS20001_TEXT_DIS with header line,

wa_it_text like line of it_text.

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.

CONSTANTS: GC_TEXT_OBJ_H TYPE COMT_TEXT_TEXTOBJECT VALUE 'CRM_ORDERH',

GC_TEXT_OBJ_I TYPE COMT_TEXT_TEXTOBJECT VALUE 'CRM_ORDERI'.

*Constants for fieldname

constants: gc_text_lines type crmt_fieldname value 'LINES'.

*jus a few sample operations

APPEND '0000000921' 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'.

*LOOP AT it_text WHERE tdid = 'A001'.

LOOP AT it_text into wa_it_text.

concatenate wa_it_text-tdline wa_it_text-ref_guid into wa_it_text-tdline.

wa_it_text-tdspras = 'E'.

append wa_it_text to hit_text_za02 .

*INSERT it_text INTO TABLE hit_text_za02 .

ENDLOOP.

DATA: it_text_ins TYPE TABLE OF BAPIBUS20001_TEXT_INS WITH HEADER LINE,

it_text_insx TYPE TABLE OF BAPIBUS20001_TEXT_INSX WITH HEADER LINE,

i_fields TYPE TABLE OF BAPIBUS20001_INPUT_FIELDS WITH HEADER LINE,

wa_it like line of it_text_ins.

*put modified data in it_text_ins

loop at hit_text_za02 into wa_it_text.

clear wa_it.

move-corresponding wa_it_text to wa_it.

wa_it-mode = 'A'.

append wa_it to it_text_ins.

endloop.

LOOP AT it_guid32 INTO wa_guid32.

i_fields-ref_guid = wa_guid32 .

i_fields-ref_kind = 'A' .

i_fields-objectname = 'TEXTS'.

i_fields-FIELDNAME = 'LINES'.

APPEND i_fields.

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 .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

Former Member
0 Kudos

Hi,

Add field name in inputfields table.

LOOP AT it_guid32 INTO wa_guid32.

i_fields-ref_guid = wa_guid32 .

i_fields-ref_kind = 'B' .

i_fields-objectname = 'TEXTS'.

i_fields-fieldname = """ Whatever the field u r updating"

APPEND i_fields.

ENDLOOP.

Then call BAPI_BUSPROCESSND_SAVE

then call BAPI_TRANSACTION_COMMIT.

If you still have problem put breakpoint at crmd_order_maintain FM and change the document in GUI get the parameters passed.

Thanks and Regards,

Abdul raaheem S

Former Member
0 Kudos

Try using a transaction commit.

Michael.

Former Member
0 Kudos

I added to the code the statement

COMMIT WORK .

but it didn't work

rgds

A. Garduñ

Former Member
0 Kudos

Try function bapi_transaction_commit.

Michael.