cancel
Showing results for 
Search instead for 
Did you mean: 

Problem creating change document for BP1012

Former Member
0 Kudos

Hello all,

I have a problem with creating change documents for the table BP1012 (which is used to store the data from the Ratings tab in the BP module). When I create a change document with the code at the end of the posting everything executes fine without any sy-subrc being different from zero. But when I lateron update the previously created change document I get an position_insert_failed exception in the CHANGEDOCUMENT_CLOSE function. I use objectclas BUPA_FS08, which I think is right for BP1012 (since BUPA_FS08 is defined for the Ratings tab in the BDT tool) and I'm preatty sure that I create a unique objectid (it consists of all the primary keys in the table). I spent some time debugging into these CHANGEDOCUMENT_* functions, but it is preatty cumbersome and not really insightful. Maybe somebody has an idea where I could start searching for the problem.

Thanks, Oliver Plohmann

FUNCTION zdra_changedoc_bp1012.

*"----

-


""Lokale Schnittstelle:

*" IMPORTING

*" REFERENCE(PARTNER) LIKE BUT000-PARTNER

*" REFERENCE(BP1012_NEW) LIKE BP1012 STRUCTURE BP1012

*" REFERENCE(BP1012_OLD) LIKE BP1012 STRUCTURE BP1012

*" REFERENCE(MODE) TYPE CHAR1

*"----

-


DATA:

wrk_mode(1) TYPE c,

wrk_objectid LIKE cdhdr-objectid, " Objekt-ID

con_objectclas LIKE cdhdr-objectclas VALUE 'BUPA_FS08'.

MOVE mode TO wrk_mode.

MOVE partner TO wrk_objectid. " konvertieren

MOVE bp1012_new-timestamp TO wrk_objectid+10.

MOVE bp1012_new-diftval TO wrk_objectid+24.

MOVE bp1012_new-date_to TO wrk_objectid+34.

MOVE bp1012_new-grade_method TO wrk_objectid+42.

  • PARTNER BU_PARTNER CHAR 10

*.INCLUDE BP1012_KEY STRU 0

*TIMESTAMP BP_TIMESTAMP CHAR 14

*DIFTVAL BP_CRITER CHAR 10

*DATE_TO BP_DATE_R DATS 8

*GRADE_METHOD BP_GRADE_METHOD CHAR 10

CALL FUNCTION 'CHANGEDOCUMENT_OPEN' "

EXPORTING "

objectclass = con_objectclas " Objektklasse

objectid = wrk_objectid " Objekt-ID

  • PLANNED_CHANGE_NUMBER = ' ' "

  • PLANNED_OR_REAL_CHANGES = ' ' "

EXCEPTIONS "

sequence_invalid = 1 "

OTHERS = 2 "

. "

IF sy-subrc <> 0. "

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. "

ENDIF. "

IF mode = 'U'.

CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE' "

EXPORTING "

change_indicator = 'U' " Update

docu_delete = 'X'

  • DOCU_DELETE = ' ' "

  • REFAREA_NEW = ' ' "

  • REFAREA_OLD = ' ' "

  • REFTABLENAME = ' ' "

tablename = 'BP1012' " Tabelle

workarea_new = bp1012_new " neue Werte

workarea_old = bp1012_old " alte Werte

EXCEPTIONS "

nametab_error = 1 "

open_missing = 2 "

position_insert_failed = 3 "

OTHERS = 4 "

. "

IF sy-subrc <> 0. "

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. "

ENDIF. "

ENDIF.

IF mode = 'I'.

CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE' "

EXPORTING "

change_indicator = 'I' " Update

  • DOCU_DELETE = ' ' "

  • REFAREA_NEW = ' ' "

  • REFAREA_OLD = ' ' "

  • REFTABLENAME = ' ' "

tablename = 'BP1012' " Tabelle

workarea_new = bp1012_new " neue Werte

  • workarea_old = bp1012_old " alte Werte

EXCEPTIONS "

nametab_error = 1 "

open_missing = 2 "

position_insert_failed = 3 "

OTHERS = 4 "

. "

IF sy-subrc <> 0. "

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. "

ENDIF. "

ENDIF.

CALL FUNCTION 'CHANGEDOCUMENT_CLOSE' "

EXPORTING "

date_of_change = sy-datum " Änderungsdatum

objectclass = con_objectclas " Objektklasse

objectid = wrk_objectid " Objekt-ID

tcode = 'BP' " Transaktion

time_of_change = sy-uzeit " Änderungszeit

username = sy-uname " Änderer

object_change_indicator = wrk_mode "

  • PLANNED_OR_REAL_CHANGES = ' ' "

  • NO_CHANGE_POINTERS = ' ' "

  • IMPORTING "

  • CHANGENUMBER = "

EXCEPTIONS "

header_insert_failed = 1 "

no_position_inserted = 2 "

object_invalid = 3 "

open_missing = 4 "

position_insert_failed = 5 "

OTHERS = 6 "

. "

IF sy-subrc <> 0. "

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. "

ENDIF.

ENDFUNCTION.

Accepted Solutions (1)

Accepted Solutions (1)

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Oliver!

Change documents are best created by SAP. Go into transaction SCDO, double click BUPA_FS08 (and switch somehow to display mode), push generation info.

Normally you should inlude the mentioned includes into your own program (FBUPA_FS08CDC, FBUPA_FS08CDT - rest is in top include) and just call routine CD_CALL_BUPA_FS08. Compare other standard implementations. You might also only use FM BUPA_FS08_WRITE_DOCUMENT, but at least in the same way as the includes do this.

Regards,

Christian

Answers (0)