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

Changing a field value

Former Member
0 Likes
1,415

Within USEREXIT_SAVE_DOCUMENT I would like to change the Purchase Order Number depending on certain criteria and write this to the vbak table.

I need to be able to change the Purchase Order Number to the current date in DD.MM.YYYY format plus the current contents of the vbak-bstnk field. I have currently got the following code, but this only puts the date in YYYYMMDD format and it doesn't write the new PO Number field to the database.

Therefore when you go back into the sales order it still shows the original PO Number.

   CONCATENATE sy-datum xvbak-bstnk INTO zzbstnk.
   xvbak-bstnk = zzbstnk.

Any help would be greatly received...

Regards

Carly

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,203

Hi Carly,

Use the following code:

DATA: lc_date(10).

WRITE sy-datum TO lc_date. "this gives you the desired date output

CONCATENATE lc_date xvbak-bstnk INTO yvbak-bstnk.

The date takes up 10 characters. BSTNK has 20 character. If you concatenate it and XVBAK-BSTNK is larger then 10 characters, it will be truncated.

In order to change it, make sure that YVBAK = XVBAK. XVBAK is what you receive, YVBAK is what you return so changing XVBAK does not do anything while changing YVBAK does.

Hope this helps.

Kind regards,

Roel van den Berge

8 REPLIES 8
Read only

Former Member
0 Likes
1,204

Hi Carly,

Use the following code:

DATA: lc_date(10).

WRITE sy-datum TO lc_date. "this gives you the desired date output

CONCATENATE lc_date xvbak-bstnk INTO yvbak-bstnk.

The date takes up 10 characters. BSTNK has 20 character. If you concatenate it and XVBAK-BSTNK is larger then 10 characters, it will be truncated.

In order to change it, make sure that YVBAK = XVBAK. XVBAK is what you receive, YVBAK is what you return so changing XVBAK does not do anything while changing YVBAK does.

Hope this helps.

Kind regards,

Roel van den Berge

Read only

Former Member
0 Likes
1,203

Thank you Roel, this solves the DD.MM.YYYY problem.

However this still does not update the new PO Number to the VBAK table. It still shows the original PO Number when I look in VBAK and when I go into the Sales Order.

Can anyone help with this part?

Read only

Former Member
0 Likes
1,203

For the new PO number you can do this:

CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum(4) xvbak-bstnk INTO zzbstnk.

- April King

Read only

Former Member
0 Likes
1,203

CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum(4) xvbak-bstnk INTO zzbstnk separated by '.'.

Read only

Former Member
0 Likes
1,203

I have now got the following code

    IF xvbak-bstnk = ''.
      WRITE sy-datum TO zznewdate.
      CONCATENATE zznewdate yvbak-bstnk INTO yvbak-bstnk.
    ELSE.
      WRITE sy-datum TO zznewdate.
      CONCATENATE zznewdate xvbak-bstnk INTO yvbak-bstnk.
    ENDIF.

This, however, does not update the database with the DD.MM.YYYY + ponumber, it either stays the same if the PO number has not been amended manually or changes to whatever you have changed it to...It doesn't take any notice of the DD.MM.YYYY part.

Read only

0 Likes
1,203

CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum(4) INTO zzbstnk separated by '.'.

CONCATENATE zzbstnk ponumber into zzbstnk.

Let me know how this is displaying for you. If it is not fixed I try for the fix.

Read only

0 Likes
1,203

Mind me...

When I used your code zzbstnk is displaying exactly what I want it to display, but I need this to then write back to VBAK to update the PO Number field. (i.e So next time I go into the Sales Order is shows the new PO field as DD.MM.YYYY+PONumber.)

Read only

0 Likes
1,203

Please see this thread, regarding field updkz for updates:

Also, is there an exit USEREXIT_MOVE_FIELD_TO_VBAK? There was a post where someone had a similar problem with a field in VBAP, and they could use USEREXIT_MOVE_FIELD_TO_VBAP to change a field value.

Please also see this thread:

- April King