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: 

Invoice creation(automatic) after PGI done

former_member630092
Participant
0 Kudos

My requirement is create VF01 invoice immediately after pgi done in system ( not using Manually VF01 transaction).

How can i proceed . Is there any enhancement point / BAdi in tcode VL02N which confirms that pgi has been done and saved in database table so that at that point transaction VF01 can we called in VL02N.

Or any other way, please suggest the way...

Thanks

22 REPLIES 22

Usharsree_7999
Participant
0 Kudos

Hi Ravi Kumar,

You can use either the BADI "LE_SHP_DELIVERY_PROC" or user exit "MV50AFZ1" (USEREXIT_SAVE_DOCUMENT).

In the exit you can call BDC or BAPI BAPI_BILLINGDOC_CREATEMULTIPLE to create the invoice VF01.

Hope this helps.

Thanks,

Ushasrii

sanilbhandari
Product and Topic Expert
Product and Topic Expert

Hi

Scheduling a job for VF04 might be a better solution rather than a custom development. You can schedule it for the time interval you want may be 2-5 mins. I would suggest working with an SD Colleague for the same.

If your business insists on immediate billing, ask them the business rationale that they cannot wait for 2-3 mins after PGI for the billing to be generated immediately. Again I would suggest to involve your SD Colleague on this conversation.

Regards

Sanil Bhandari

Sanil Bhandari

0 Kudos

Another option to have the immediate billing would be to schedule/call the VF04 for the given document in the described user-exit. So you rely on the SAP-standard process using VF04, but it's faster than just scheduling the report.

KR
Jens

0 Kudos

Regarding Invoice creation(automatic) after PGI done

I am trying to create the BDC recording , but the recording is not getting saved and generating billing document .

Can be create the bdc for VF01 ?

former_member630092
Participant
0 Kudos

Is it feasible to call SDBILLDL program in enhancement of vl02n/vl01n when pgi done and vf01 is automatically created.

First step is to create enhancement for SDBILLDL what are other steps that invoice is created automatically.

Thanks

mohdsap
Active Participant
0 Kudos

Some how see the output type I think it is possible I saw somewhere it was working fine other wise go for jobs

0 Kudos

I am getting the following statements while doing BDC :

T VF01

SAPMV60A 0102 X

BDC_CURSOR KOMFK-VBELN(01)

BDC_OKCODE /00

KOMFK-VBELN(01) 0083132310

SAPMV60A 0104 X

BDC_CURSOR VBRK-FKART

BDC_OKCODE =SICH

But it is not generating the billing document number to complete the recording.

Can anyone guide me what is mistake. Or T-Code VF01 bdc is feasible ?

0 Kudos

Hi, i am working on VF01 bdc , but final vf01 document is not being posted using this bdc.

Any one had experiance on VF01 bdc...

0 Kudos

Any one have experiance on VF01 BDC ?

venkateswaran_k
Active Contributor
0 Kudos

Hi Ravi,

Instead of BDC, use this BAPI. This will create the Invoice document based on the delivery / PGI doc.

        wa_datain-ref_doc   = <YOUR DELIVERY DOCUMENT NO> 
        wa_datain-bill_date = <YOUR DATE>
        wa_datain-price_date = wa_datain-serv_date = <YOUR DATE>.
        wa_datain-ref_doc_ca = 'J'.
        APPEND wa_datain TO it_datain.

        CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
          TABLES
            billingdatain = it_datain
            return        = it_ret
            success       = it_succ.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.

it_ret will get the billing documnetn number if successful.

Regards,

Venkat

0 Kudos

Hi ,

Thanks for reply. I have checked the BAPI. it is working fine. But major issue is we have many z enhancements in the mentioned VF01 ( user exits )( LIKE number ranges plant wise , FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN,

FORM USEREXIT_PRICING_PREPARE_TKOMP. INCLUDE LV60AA97 ,FORM USEREXIT_FILL_VBRK_VBRP.

and also subsitution rules at fi end based on document types and business area.

How can be handled these cases...

Thanks

0 Kudos

I did not understand your comment.

1. Is your requirement is resolved? after implementing this BAPI in PGI save - is invoice is created sucessfully?

2. What is your further issue on these mentioned exits?

Can you please explain.

0 Kudos

Yes sir, BAPI is creating invoice successfully. Thank you.

But BAPI is not taking into account the Z enhancements. ( BAPI is by passing )

We have implemented the Plant wise number range enhancement,

We have implemented the Discount conditions based on customer Credit amount balance.

And business substitution rules for plants and document type based on business area.

This bapi is not considering these cases..

0 Kudos

Hi ravi.kumar109

I cannot believe the user exit is by-passed. Can you please share the code you have written on that exit.

Is there any sy-tocde = xxxx such statements inside the exit.?

Please share the user exit codes.

0 Kudos

Thank you sir. I check my enhancements and that are working fine with some changes like sy-tcode .

But one of my enhancement is inside the include "MV60AF0B_BELEG_SICHERN" which is not triggering if i am using bapi BAPI_BILLINGDOC_CREATEMULTIPLE.

FORM BELEG_SICHERN.
READ TABLE XVBRK INDEX 1.
IF SY-SUBRC NE 0.
CALL FUNCTION 'DEQUEUE_ALL'.
MESSAGE S032.
EXIT.
ENDIF.
IF SAMH_MOD = ON.
EXPORT XKOMFK TO MEMORY ID 'SDBILLDL'.
ENDIF.
DATA: CALC_TYPE.
IF REBATE_DETERMINED = 'Y'.
CALC_TYPE = 'A'.
ELSE.
CALC_TYPE = 'I'.
ENDIF.
ENHANCEMENT-SECTION BELEG_SICHERN_11 SPOTS ES_SAPMV60A.
CALL FUNCTION 'RV_INVOICE_DOCUMENT_ADD'
EXPORTING
VBSK_I = VBSK
WITH_POSTING = 'A'
PREISFINDUNGSART = CALC_TYPE
IMPORTING
VBSK_E = VBSK
TABLES
XKOMFK = XKOMFK
XTHEAD = XTHEAD
XVBFS = XVBFS
XVBSS = XVBSS
XVBRK = XVBRK
XVBRP = XVBRP
XVBPA = XVBPA
XKOMV = XKOMV.
END-ENHANCEMENT-SECTION.
CALL FUNCTION 'STACK_RESET'.
R185D-DATALOSS = SPACE.
FOLGEAUFRUF102 = SPACE.
PERFORM SETPAR_INIT.
LEAVE.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form BELEG_SICHERN, End A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZVF01_VF11_DISCOUNT_GL_ENTRY. "active version

code is calling bdc based on sepecific gl

ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
ENDFORM.

If I AM USING VF01 then system control is calling include "MV60AF0B_BELEG_SICHERN"

and my enhancement is working fine. But when i am using bapi BAPI_BILLINGDOC_CREATEMULTIPLE. system is not calling the include "MV60AF0B_BELEG_SICHERN"

and enhancement is not working.

Please advice.

0 Kudos

I think it is based on some discount conditions applied to your Sales order / invoice.

Please check with your Functional consultant the overall invoice created is okay or not.

As far as I understand, all these exits will be executed wherever you are coming from either VF01 or BAPI or BDC.

For test case, use the same set of data , Put a break point there

1. First execute through BAPI - see on what condition it skips

2. Second execute thorugh VF01 - see what is the value that decides.

0 Kudos

Hi venkateswaran.k sir,

Thank you sir. During the debugging process ,I checked using vf01 , it is capturing all includes and exits and enhancements ( weather the invoice is with or without conditions no restriction ).

And other way using BAPI "BAPI_BILLINGDOC_CREATEMULTIPLE" the system does not enter the include "MV60AF0B_BELEG_SICHERN" ( may be more includes or exists but i checked one with my enhancement ( with no condition restrictions ).

Thanks

0 Kudos

okay, did you chk with functional consultant whether the invoice created by bapi is correct, is there any difference between invooice created by bapi and invoice created by vf01? anything is missing in bapi invoice?

0 Kudos

Hi ravi.kumar109

Did you check as per my above comment? Is this issue resolved ?

0 Kudos

Hi venkateswaran.k,

Sorry for delay. Yes check the data ,all tables are updating properly. But one of my enhancement is not being called during BAPI . Then it may be possible if we implement knew more enhancements then they are not being captured in this bapi. First thing the BAPI is for complete vf01 but its not calling above mentioned enhancement during vf01.

If bapi is not calling the complete enhancements then no use of automatic billing.

Thank you sir.