‎2007 Jun 01 12:48 PM
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
‎2007 Jun 01 1:09 PM
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
‎2007 Jun 01 1:09 PM
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
‎2007 Jun 01 1:17 PM
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?
‎2007 Jun 01 1:20 PM
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
‎2007 Jun 01 1:23 PM
CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum(4) xvbak-bstnk INTO zzbstnk separated by '.'.
‎2007 Jun 01 1:43 PM
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.
‎2007 Jun 01 2:39 PM
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.
‎2007 Jun 01 3:00 PM
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.)
‎2007 Jun 01 3:50 PM