Update BSEG-ZUONR with Function Module

Marsha picture Marsha · Nov 19, 2015 · Viewed 10.3k times · Source

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.

Answer

Suncatcher picture Suncatcher · Dec 24, 2015

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.