Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Assign Reference Field at runtime Tx: MIRO

Former Member
0 Likes
762

Hi,

I'm trying to set in the field BKPF-XBLNR the number of the document created by MIRO.

I made a debug and I notice that there is a structure called BKPF which contains all the information about the document. I manually set the field with some text before the end of the transaction and it works OK.

I found the BADI INVOICE_UPDATE which contains as a paremeter the number of the new invoice and I tried the following code:


  IF sy-tcode = 'MIRO'.
    break jchavez.

    FIELD-SYMBOLS: <fs> TYPE ANY.

    ASSIGN ('(SAPLFDCB)BKPF-XBLNR') TO <fs>.

    IF sy-subrc = 0.
      <fs> = s_rbkp_new-belnr.
    ENDIF.
  ENDIF.

And it works fine, when I continued the debugging I can see the value in the structure but in some part of the program the value is deleted.

Have you ever tried to do something similar?

I have tried with Substitution Exits (OBBH) but it doesn't work =(

Thanx in advanced.

2 REPLIES 2
Read only

Former Member
0 Likes
579

Hi,

Please try this.


IF sy-tcode = 'MIRO'.
  break jchavez.
 
  FIELD-SYMBOLS: <fs> TYPE ANY.
 
  ASSIGN ('(SAPLFDCB)BKPF-XBLNR') TO <fs>.
 
  IF sy-subrc = 0.
    <fs> = s_rbkp_new-belnr.
  ENDIF.
   
  UNASSIGN <fs>.                       "Add here
ENDIF.

Regards,

Ferry Lianto

Read only

matt
Active Contributor
0 Likes
579

Sometimes SAP store the original contents of the field before the user exit call, and then, except for the ones they allow you to change, they set them back. So no matter what you do in the exit, the values are always reset.

matt