Application Development 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: 

Fill an included [z-field] field at the save of an invoice

Former Member
0 Kudos

I need a way to fill an included field (on VBRK) at the save of an invoice. The catch is that this value needs to be provided by the use; it can't be calculated. What is the easiest way to do this? If need be I can do it on the save of the sales order and I will transport it (to the invoice) at the save of the invoice.

Regards,

Davis

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

please check this sample code for popup..

DATA: s_sval TYPE sval,
      t_sval TYPE TABLE OF sval.

* Prepare the input.
s_sval-fieldname = 'MATNR'.
s_sval-tabname   = 'MARA'.
APPEND s_sval TO t_sval.

* Show the popup.
CALL FUNCTION 'POPUP_GET_VALUES'
  EXPORTING
    no_value_check  = 'X'
    popup_title     = 'Enter commission'
  TABLES
    fields          = t_sval
  EXCEPTIONS
    error_in_fields = 1
    OTHERS          = 2.
IF sy-subrc = 0.

* Get the value entered.
  READ TABLE t_sval INTO s_sval INDEX 1.

  WRITE: / s_sval-value.
ENDIF.

Thanks

Naren

9 REPLIES 9

Former Member
0 Kudos

Hi,

You can use "billing document data transfer routine" (VOFM) to move the values from the sales order to the billing document.

OR

You can use the userexit..USEREXIT_FILL_VBRK_VBRP..which is there in the include RV60AFZC...

Is this what you want..? otherwise please let me know the details..

Thanks

Naren

0 Kudos

My issue isn't filling the field so much as prompting the user to enter a value. I need a way to get this information from the user via a user/screen exit.

Regards,

Davis

Former Member
0 Kudos

Hi,

ok..got it...Which version of sap are you working on?

Thanks

Naren

Former Member
0 Kudos

Also,

Does it have to be a z field?

Please check if we can use an existing field which is not used at the header or item level..

Also check if the header texts / ITem texts can be used in this scenario..

Thanks

Naren

0 Kudos

I'm sorry to say but it is 4.6c. I can't use a text because I need it to come through with a select of VBRK or VBRP because the report runs so slow that another FM call would kill it. I was thinking of looking for an unused field but I have a feeling that they will do an upgrade soon so that concerns me. The last thing I want is for them to start using this field and then the report won't work.

Davis

Former Member
0 Kudos

Hi,

I believe if there is no screen exit available in the billing document..

Try using the userexit USEREXIT_FILL_VBRK_VBRP...to call a popup to get the value when saving the invoice..

But I have the following concerns..

incase if you want to change the z field value ...how would you trigger the save again in VF02 without changing any of the standard field...

I think the best way is as you said...change the sales order screen additional data B screen (SAPMV45A) to add a new field...and then move the value from the sales order to the invoice..

anyways I will check if there is any way in invoice itself..

Thanks

Naren

0 Kudos

The amount will never change. It is going to be used to determine the commission, of a sale, so once it is set it will stay set (per order). Do you happen to have sample code (or know where to point me) that would pop a box up to the user for entry?

Regards,

Davis

Former Member
0 Kudos

Hi,

please check this sample code for popup..

DATA: s_sval TYPE sval,
      t_sval TYPE TABLE OF sval.

* Prepare the input.
s_sval-fieldname = 'MATNR'.
s_sval-tabname   = 'MARA'.
APPEND s_sval TO t_sval.

* Show the popup.
CALL FUNCTION 'POPUP_GET_VALUES'
  EXPORTING
    no_value_check  = 'X'
    popup_title     = 'Enter commission'
  TABLES
    fields          = t_sval
  EXCEPTIONS
    error_in_fields = 1
    OTHERS          = 2.
IF sy-subrc = 0.

* Get the value entered.
  READ TABLE t_sval INTO s_sval INDEX 1.

  WRITE: / s_sval-value.
ENDIF.

Thanks

Naren

0 Kudos

Thank you very much for this help. In my opinion, you did more than most as you kept up the conversation and helped figure out the best way to go about this.

Thanks again!

Davis