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

FM to create document flow

Former Member
0 Likes
6,788

Hi,

I'm using the fm BAPI_BILLINGDOC_CREATEMULTIPLE to create an invoice for a sales order. In the next step I want to link this new invoice to the document flow of the sales order.


I've found several fms to do this (BINARY_RELATION_CREATE_COMMIT, SD_DOCUMENT_FLOW_MAINTAIN, RV_DOCUMENT_FLOW_UPDATE, RV_XVBFA_MAINTAIN ...) but I have no idea which one is correct and how it has to be called.


Any ideas/examples would be greatly appreciated.


Greetings Stefan

1 ACCEPTED SOLUTION
Read only

jay_kumar8
Active Participant
0 Likes
3,720

Yes..You can do as Juwin said...

Initialize the flow

  CALL FUNCTION 'SD_DOCUMENT_FLOW_INIT'

    EXPORTING

      i_vbtyp_n = 'V'.

And prepare the structures..

DATA:  ls_vbfa        TYPE vbfa.

  ls_vbfa-mandt = sy-mandt.

  ls_vbfa-vbelv = is_vbap-vbeln.

  ls_vbfa-posnv = is_vbap-posnr.

  ls_vbfa-vbeln = iv_ponum.

  ls_vbfa-posnn = is_vbap-posnr.

  ls_vbfa-vbtyp_n = 'V'.

  ls_vbfa-rfmng = is_vbap-kwmeng.

  ls_vbfa-meins = is_vbap-vrkme.

  ls_vbfa-vbtyp_v = 'H' .

  ls_vbfa-erdat = sy-datum.

  ls_vbfa-erzet = sy-uzeit.

  ls_vbfa-matnr = is_vbap-matnr.

* Maintain document flow

  CALL FUNCTION 'SD_DOCUMENT_FLOW_MAINTAIN'

    EXPORTING

      i_delete = space

      i_status = 'H'

      i_vbfa   = ls_vbfa.

And finally save the document flow

CALL FUNCTION 'SD_DOCUMENT_FLOW_SAVE_PO'.

Regards

Raj

Hi,

I'm using the fm BAPI_BILLINGDOC_CREATEMULTIPLE to create an invoice for a sales order. In the next step I want to link this new invoice to the document flow of the sales order.


I've found several fms to do this (BINARY_RELATION_CREATE_COMMIT, SD_DOCUMENT_FLOW_MAINTAIN, RV_DOCUMENT_FLOW_UPDATE, RV_XVBFA_MAINTAIN ...) but I have no idea which one is correct and how it has to be called.


Any ideas/examples would be greatly appreciated.


Greetings Stefan

6 REPLIES 6
Read only

Juwin
Active Contributor
0 Likes
3,720

Initialize the call using  SD_DOCUMENT_FLOW_INIT

Call  SD_DOCUMENT_FLOW_MAINTAIN passing  i_status = 'H', and  i_vbfa = new document flow record

Call  SD_DOCUMENT_FLOW_SAVE_PO to save the record to database.

Thanks,

Juwin

Read only

jay_kumar8
Active Participant
0 Likes
3,721

Yes..You can do as Juwin said...

Initialize the flow

  CALL FUNCTION 'SD_DOCUMENT_FLOW_INIT'

    EXPORTING

      i_vbtyp_n = 'V'.

And prepare the structures..

DATA:  ls_vbfa        TYPE vbfa.

  ls_vbfa-mandt = sy-mandt.

  ls_vbfa-vbelv = is_vbap-vbeln.

  ls_vbfa-posnv = is_vbap-posnr.

  ls_vbfa-vbeln = iv_ponum.

  ls_vbfa-posnn = is_vbap-posnr.

  ls_vbfa-vbtyp_n = 'V'.

  ls_vbfa-rfmng = is_vbap-kwmeng.

  ls_vbfa-meins = is_vbap-vrkme.

  ls_vbfa-vbtyp_v = 'H' .

  ls_vbfa-erdat = sy-datum.

  ls_vbfa-erzet = sy-uzeit.

  ls_vbfa-matnr = is_vbap-matnr.

* Maintain document flow

  CALL FUNCTION 'SD_DOCUMENT_FLOW_MAINTAIN'

    EXPORTING

      i_delete = space

      i_status = 'H'

      i_vbfa   = ls_vbfa.

And finally save the document flow

CALL FUNCTION 'SD_DOCUMENT_FLOW_SAVE_PO'.

Regards

Raj

Read only

0 Likes
3,720

Thanks for your answers, I did as you said and added a COMMIT WORK and it works!

Read only

0 Likes
3,720

Thank you Stefan for asking the question and thanks to Juwin and Raj for the helpful answers.

I had a similar Problem : i deleted a handling Unit in a packing proposal of a scheduling Agreement with FM "V51F_DELETE_HU" (commit for the deletion of HU is done with FM "HU_POST".

To maintain the document flow I used FM "RV_XVBFA_MAINTAIN".

I did not understand why table VBFA was not updated.

Thanks to this post I used FM "RV_DOCUMENT_FLOW_UPDATE_U" -> it is inside of FM "SD_DOCUMENT_FLOW_SAVE_PO".

It worked.

Regards

Stephan

Read only

0 Likes
3,720

Hi Stephan,

it's great to hear this.

Regards

Raj

Read only

Former Member
0 Likes
3,720

Hi,

I used the same code for tried to make flow between Contract & Billing after Contract creation, but it didnt work out. I'm getting below challenge

1> What do I need to export in SD_DOCUMENT_FLOW_INIT, as V is for PO.

2> In, SD_DOCUMENT_FLOW_SAVE_PO, it asking me to export PO, but I'm creating Contract from Billing, there is no EBELN.

Code is below

CALL FUNCTION 'SD_DOCUMENT_FLOW_INIT'

EXPORTING

i_vbtyp_n = 'V'.

And prepare the structures..

DATA: ls_vbfa TYPE vbfa.

ls_vbfa-mandt = sy-mandt.

ls_vbfa-vbelv = is_vbap-vbeln.

ls_vbfa-posnv = is_vbap-posnr.

ls_vbfa-vbeln = iv_ponum.

ls_vbfa-posnn = is_vbap-posnr.

ls_vbfa-vbtyp_n = 'G'.

ls_vbfa-rfmng = is_vbap-kwmeng.

ls_vbfa-meins = is_vbap-vrkme.

ls_vbfa-vbtyp_v = 'M' .

ls_vbfa-erdat = sy-datum.

ls_vbfa-erzet = sy-uzeit.

ls_vbfa-matnr = is_vbap-matnr.

* Maintain document flow

CALL FUNCTION 'SD_DOCUMENT_FLOW_MAINTAIN'

EXPORTING

i_delete = space

i_status = 'H' OR 'V'

i_vbfa = ls_vbfa.

And finally save the document flow

CALL FUNCTION 'SD_DOCUMENT_FLOW_SAVE_PO'.

EXPORT

I_EBELN = ''.