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: 

Add a PO in a Sales Order' document flow

Former Member
0 Kudos

Hello,

I am a beginner in ABAP and I would like to know how to add a line in VBFA to add a Purchase Order in the document flow of a Sales Order.

I tried many function, but nothing is working.

I've got the VBFA line I'd like to use (which works when I use an INSERT), the number of both Sales and Purchase Order and that's all.

If you tell me to use a function, could you please tell me which parameters I have to use (I started ABAP programming 2-3 weeks ago so it's still hard for me to understand everything).

In advance, thanks,

Clément Poissonnier (and not Clent)

11 REPLIES 11

Former Member
0 Kudos

Hi,

First off, you really shouldn't ever insert or modify standard SAP tables directly via ABAP code. Google referential integrity for some reasons why.

If you have only just started ABAP then I think you need to take a step back and go over more of the basics to get a better understanding of how to develop in SAP, not necessarily info around the commands but more about ways of working and standard approaches to development.

I'm curious why you need to manually manipulate the document flow in this way as it seems a little unusual to force a PO into a sales order's document flow after the SO has already been created.

Gareth.

0 Kudos

>

> Hi,

>

> First off, you really shouldn't ever insert or modify standard SAP tables directly via ABAP code. Google referential integrity for some reasons why.

I know that I don't have to modify a standard tables via SQL, I just tried this to be sure that I was going on the good way.

So don't worry, I'm not going to let INSERT instruction in my program, that's why I'm trying to test functions as SD_SALESDOCUMENT_UPDATEDOCFLOW or RV_DOCUMENT_FLOW_ADD. But the VBFA table doesn't seems to be modified by these functions.

>

> If you have only just started ABAP then I think you need to take a step back and go over more of the basics to get a better understanding of how to develop in SAP, not necessarily info around the commands but more about ways of working and standard approaches to development.

You should tell this to my manager. As I said before, I know that I'm not supposed to work this way and I don't intend to continue that way, that's why I'm looking for help here.

>

> I'm curious why you need to manually manipulate the document flow in this way as it seems a little unusual to force a PO into a sales order's document flow after the SO has already been created.

I have to update document flow that way to manage a certain use case (not common) of direct selling (PO => SO).

0 Kudos

Managers never listen

I'm not honestly aware of how to get his working in ECC - I've done something almost identical in a CRM system to link orders to other documents for unusual business scenario's but not in normal R/3.

Thinking of alternatives, is it not possible to manipulate the document flow at the point of the SO creation, and hence use one of the many user-exits in VA01 to add the link to your PO? Or is this part of the problem, that at the point of SO creation they don't have a PO to reference? I don't know if you can actually define a link between an SO and a PO in this way - have you had functional confirmation that this can be done?

Going back to the function modules you've suggested, have you tried to run them and they fail or do they just not appear to do what you want (I haven't worked with them.) Looking at SD_SALESDOCUMENT_UPDATEDOCFLOW it appears to update the VBFA table - do you get errors from your call to it?

0 Kudos

>

> Managers never listen

>

> I'm not honestly aware of how to get his working in ECC - I've done something almost identical in a CRM system to link orders to other documents for unusual business scenario's but not in normal R/3.

>

> Thinking of alternatives, is it not possible to manipulate the document flow at the point of the SO creation, and hence use one of the many user-exits in VA01 to add the link to your PO? Or is this part of the problem, that at the point of SO creation they don't have a PO to reference? I don't know if you can actually define a link between an SO and a PO in this way - have you had functional confirmation that this can be done?

>

For this project, we don't use VA01 but a modification of this transaction ZVA01. I had to modify a dynpro to fill informations about the PO which is related to each items (PO number and Item number) so when the SO is created I have every information I need to create the link.

The problem is that the SO is created by a BAPI, I looked with an experimented ABAP developer and nothing exists there to create the link between SO and PO.

That is why I decided to use functions just before the creation of the SO so I guess this should work.

Unfortunatly, the functionnal consultant (which is an ex-technical consultant) is on vacation so I can't have any confirmations about the way I'm supposed to do this.

>

> Going back to the function modules you've suggested, have you tried to run them and they fail or do they just not appear to do what you want (I haven't worked with them.) Looking at SD_SALESDOCUMENT_UPDATEDOCFLOW it appears to update the VBFA table - do you get errors from your call to it?

The only function that make an error is "SD_SALESDOCUMENT_UPDATEDOCFLOW". But I just need a function with one parameter (the information I want to add) and I don't really understand why all function I find are that complicated. When I run other functions, nothing appears to be modified (but the execution is OK)

If you had to add a document in sales document flow, which function would you use?

0 Kudos

Hi,

So you are using ZVA01 which is a copy of VA01? Have you just changed a few of the dynpro's as you mention and the rest of the logic is as standard?

When you say the SO is created with a BAPI is that customised or as part of the standard VA01 logic you have copied? The standard program is SAPMV45A and this has a number of user-exits available - I'm wondering if there is some way you could add an extra entry to VBFA in the USEREXIT_SAVE_DOCUMENT_PREPARE form? I've just debugged through and XVBFA is available as an internal table - why not try taking an existing sales order and change it via VA02 (or ZVA01?!) and see if you can add your data into an entry in XVBFA at the point of USEREXIT_SAVE_DOCUMENT_PREPARE. The problem here will be ensuring you have all of the correct data in the table - I'm slightly concerned that you will be missing some other piece of data but really can't say for sure.

When you run SD_SALESDOCUMENT_UPDATEDOCFLOW what error do you get? Do you set the COMMIT parameter to equal X so that it saves any updates.

I've not done this in ECC SD but I would be trying to get the above module working as a first attempt.

0 Kudos

>

> Hi,

>

> So you are using ZVA01 which is a copy of VA01? Have you just changed a few of the dynpro's as you mention and the rest of the logic is as standard?

ZVA01 is not a copy of VA01. This is a specific transaction to create Sales Order.

> When you say the SO is created with a BAPI is that customised or as part of the standard VA01 logic you have copied?

This is a customised program, so it's not a part of VA01.

> When you run SD_SALESDOCUMENT_UPDATEDOCFLOW what error do you get? Do you set the COMMIT parameter to equal X so that it saves any updates.

>

> I've not done this in ECC SD but I would be trying to get the above module working as a first attempt.

I used the instruction "COMMIT WORK AND WAIT" so it should be ok.

Concerning the error, I'll tell you that in a couple of hours.

0 Kudos

Hi,

So is it using BAPI_SALESORDER_CREATEFROMDAT2 to create the order?

In this case then yes, you will have to maintain the document flow after the order is created. I'm not sure what else to suggest other than to carry on trying to get the SD_SALESDOCUMENT_UPDATEDOCFLOW function call working. So call the BAPI to create the order, commit it and then call the document flow update function.

It might be worthwhile posting in one of the other forums, say SD to see if someone more functional can suggest some ways of making this work? I genuinly don't know if what you are trying to do is actually possible!

Gareth.

0 Kudos

Yes, it is using BAPI_SALESORDER_CREATEFROMDAT2.

But I've got a good news, I managed to make it work with the function "SD_DOCUMENT_FLOW_MAINTAIN" (I made some silly mistake that I cleared).

Thanks a lot for helping me, you gave me hope after many days on this problem

Clément

0 Kudos

You're welcome.

So can you just call SD_DOCUMENT_FLOW_MAINTAIN to create the document flow entries?

I've learnt something new here - thanks.

Gareth.

0 Kudos

Yes, that is that easy ...

Only 2 parameters and it's working.

0 Kudos

Hi ,

I also need update document flow , based on PO number using FM SD_SALESDOCUMENT_UPDATEDOCFLO in SO.

Plesase let me know how to call the FM.

Best regards,

Alleiah M