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

SD : creating invoice through Output Type Program

Former Member
0 Likes
2,047

Objective : When a Post good Issue (PGI) for a Delivery document (likp-vbeln) is done thru VL02n, the invloce should automatically be created

My approach:

We have thought of using the Output Type Program to write our code .

We went to transaction Nace and for V2(shipping) created a new output typr ZD00.

Processing routines

Special function ZT_SD_VF01 FORM_ACCESS

Partner function

Special function SH Ship-to party

Now I am facing two problen:

1) Inside ZT_SD_VF01 the Delivery document (likp-vbeln) is not available and even the following code

GET PARAMETER ID 'VL' FIELD likp-vbeln.

is not giving me Delivery document (likp-vbeln)

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,635

Hi!

In the printer program you might raise an own event, with RAISE EVENT myevent command.

Then you have to schedule a job (in transaction SM36) to run, after myevent event is triggered. Unfortunately the program within this job can't check the VL parameter id. You have to select the newly created deliveries without following invoice and create the invoice.

Best wishes

Tamá

7 REPLIES 7
Read only

Former Member
0 Likes
1,635

Hi Flora,

The Delivery number will be there in the NAST structure's OBJKY field.

Regards,

Ravi

Read only

0 Likes
1,635

Hi Ravi ,

Your solution did worked!

I have declared Nast but it was declared locally in my subroutine and it was not filling my TABLES: NAST structure.

Thanks.

Read only

Former Member
0 Likes
1,636

Hi!

In the printer program you might raise an own event, with RAISE EVENT myevent command.

Then you have to schedule a job (in transaction SM36) to run, after myevent event is triggered. Unfortunately the program within this job can't check the VL parameter id. You have to select the newly created deliveries without following invoice and create the invoice.

Best wishes

Tamá

Read only

Former Member
0 Likes
1,635

Flora,

I would not recommend you process your output immediately (timing = '4') as it will be processed in the same update task as your delivery and I doubt you can create invoice.

The option may be - either process these outputs via rsnast00, or just call FM from your output program with addition "starting new task" to separate delivery & invoice processing... then in this FM try to lock your delivery if locked successfully - create invoice, otherwise - wait a bit and try again...

Read only

0 Likes
1,635

Hi Siarhei Mahulenka ,

Though your solution was not in line of my problem, but miraclously your have forseen it and it was because of your answer that I have saved hours of debugging.

Thanks

Read only

0 Likes
1,635

Hi Siarhei Mahulenka ,

1) What is the function module for locking delivery. A F4 on se37 for ENQUEUE_* is giving me too many results

2) My code is :

likp-vbeln = nast-objky.

SELECT SINGLE * FROM likp INTO likp

WHERE vbeln = likp-vbeln.

CHECK sy-subrc = 0.

SELECT SINGLE * FROM lips INTO lips WHERE

vbeln = likp-vbeln.

CHECK sy-subrc = 0.

t_billing-salesorg = likp-vkorg.

t_billing-ref_doc = likp-vbeln.

t_billing-ref_item = lips-posnr.

t_billing-doc_number = likp-vbeln.

t_billing-itm_number = lips-posnr.

t_billing-ordbilltyp = 'F2'.

t_billing-price_date = sy-datum.

t_billing-ref_doc_ca = likp-vbtyp.

t_billing-material = lips-matnr.

t_billing-plant = lips-werks.

APPEND t_billing.

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE' IN BACKGROUND TASK

TABLES

billingdatain = t_billing

return = t_return

success = t_success.

Now after this function module is over, I guess I dont have access to the Invoice number (VBRK-VBELN)

But I have to create a Excise Invoice through j1iin tcode.

Any pointers!!

Read only

0 Likes
1,635

Hi Flora,

1) it's much easier to find lock objects based on table... se11, likp, where-used, select lock objects... you'll get lock object which contain LIKP (like EVVBLKE).

2) I believe your FM has billing doc number in SUCCESS structure (if you call it not in background task - you'll get it I think). OR you can use the same approach - output type for invoice & so on... the invoice number is known for sure in the output. OR just search SDN on "auto Excise", maybe you'll find other options 🐵

btw, you are using "select single" from lips ... it is going to work ONLY if you always have just 1 item in your delivery... what if you have more than 1 item ?