1

I successfully change BKPF-BKTXT with FM CHANGE_DOCUMENT but why can't I change BSEG-ZUONR with FM CHANGE_DOCUMENT too?

Here's the FM CHANGE_DOCUMENT:

CALL FUNCTION 'CHANGE_DOCUMENT'
  TABLES
    T_BKDF           = t_bkdf
    T_BKPF           = t_bkpf
    T_BSEC           = t_bsec
    T_BSED           = t_bsed
    T_BSEG           = t_bseg
    T_BSET           = t_bset
*   T_BSEG_ADD       =
          .

Here's the code to change BKPF-BKTXT (succeeded):

wa_t_bkpf-mandt = sy-mandt.
wa_t_bkpf-bukrs = '1000'.
wa_t_bkpf-gjahr = gjahr_import.
wa_t_bkpf-belnr = belnr_import.
wa_t_bkpf-bktxt = zuonr_import.
APPEND wa_t_bkpf TO t_bkpf.

Here's the code to change BSEG-ZUONR (failed):

wa_t_bseg-mandt = sy-mandt.
wa_t_bseg-bukrs = '1000'.
wa_t_bseg-gjahr = gjahr_import.
wa_t_bseg-belnr = belnr_import.
wa_t_bseg-buzei = '1'.
wa_t_bseg-zuonr = zuonr_import.
APPEND wa_t_bseg TO t_bseg.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Marsha
  • 167
  • 3
  • 3
  • 18
  • Did you try debugging this function module to see where the problem might be? – Jagger Nov 19 '15 at 07:49
  • @Jagger yes, and it turns out that the t_bkpf has to be declared too if we wanted to update the BSEG – Marsha Nov 19 '15 at 08:33
  • So the problem has been solved? If yes, then please post an answer to your own question, so that if someone comes across the same issue in the future, he can find your solution. – Jagger Nov 20 '15 at 07:19

3 Answers3

1

As author has no time to confirm, I can do this for him as I just tested this case. If we pass to FM all parameters from its signature the update runs smoothly. For example, like this:

DATA: lt_bkdf TYPE TABLE OF bkdf,
      lt_bkpf TYPE TABLE OF bkpf,
      wa_bkpf TYPE bkpf,
      lt_bsec TYPE TABLE OF bsec,
      wa_bseg  TYPE bseg,
      lt_bsed TYPE TABLE OF bsed,
      lt_bseg TYPE TABLE OF bseg,
      lt_bset TYPE TABLE OF bset.

wa_bkpf-mandt = sy-mandt.
wa_bkpf-bukrs = '5900'.
wa_bkpf-gjahr = gjahr_import.
wa_bkpf-belnr = belnr_import.
wa_bkpf-bktxt = 'Batch'.
APPEND wa_bkpf TO lt_bkpf.

wa_bseg-mandt = sy-mandt.
wa_bseg-bukrs = '5900'.
wa_bseg-gjahr = gjahr_import.
wa_bseg-belnr = belnr_import.
wa_bseg-buzei = '1'.
wa_bseg-zuonr = '20151131'.
APPEND wa_bseg TO lt_bseg.

  CALL FUNCTION 'CHANGE_DOCUMENT'
    TABLES
      t_bkdf           = lt_bkdf
      t_bkpf           = lt_bkpf
      t_bsec           = lt_bsec
      t_bsed           = lt_bsed
      t_bseg           = lt_bseg
      t_bset           = lt_bset
      .

COMMIT WORK.

All FM table parameters except the last one are mandatory.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
1

Do not use this FM

CALL FUNCTION 'CHANGE_DOCUMENT' 

This FM is changing all other fields to initial if not provided.


CALL FUNCTION 'FI_DOCUMENT_CHANGE'

It seems that this FM cannot be used to change line item which has account type (BSEG-KOART) - 'S' (GL Account).


Try this FM:

'FI_ITEMS_MASS_CHANGE'
CKE
  • 1,533
  • 19
  • 18
  • 29
SIDDHARTH
  • 11
  • 1
0

The field zuonr references to an object it belongs to. For example a purchase order.

Lets asume you pay a position of a purchase order. A document in bkpf/bseg is created (and more). Bseg-Zuonr contains the number of this purchase order position.

If you were allowed to change this field, you would destroy the referential integrity of the data. It would point to a purchase order position it was not created from or one that doesn't exist at all.

So from a business standpoint it makes no sense to ever change this field after it is created, therefore SAP will never allow to change it.

Gerd Castan
  • 6,275
  • 3
  • 44
  • 89