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: 

Enhancement to Invoicr creation in Background mode throught t cod VF06

former_member208541
Participant
0 Kudos

Hi,

we have an issue when outbound delivery has zero quantities, those zero quantities get copied to invoices. we put a code in enhancement points available between delivery and invoice that if any delivery qty is zero in internal table,we deleted that line in internal table and the system passes only the non zero qty to the invoice creation program.

so when creating invoices through VF01 t code, this works and only non zero qty is copied in invoices.

but the issue is hwn we create invoices through batch job in background mode, this does not work and zero qty is aslo copied from delivery. this is happening because during invoice creation thriugh batch job, the system creates invoices through another program .

we are not able to find where to put our code (user exit etc) for invoices created through background job so that zero qty in deliveries are not copied to invoices.

any answers ??

regards

sachin

3 REPLIES 3

Former Member
0 Kudos

Hi,

Create a copying requirements VOFM routine for billing document and assign the routine in VTFL for the corresponding delivery type and billing type..

Transaction VOFM -> COPYING REQUIREMENTS -> BILLING DOCUMENTS.

In the VOFM routine check if the quantity is greater than zero. If not set the SY-SUBRC = 4. otherwise set 0.

Check the routine 4 (Deliv-related item) for sample.

This will work in online as well as background mode..

Thanks

Naren

0 Kudos

hi,

i am also facing the same problem. for me also zero quantity is copied to invoice and there is a routine inside VOFM (928). how to code inside that can you please help me? what condition should i give to avoid thpose zero values coming to invoice for vf01?

0 Kudos

hi,

I am having problem with VF01. one sales document having 3 line items like this:-

item descrptn invoiced quantity net value material cost

10 MATERIAL ITEM 11 0 0 MITEM11 0

20 MATERIAL ITEM 12 0 0 MITEM12 0

30 MATERIAL ITEM 13 30 9000 MITEM13 30000

Now inspite of line item 10 and 20 does not have any value still it is coming into invoice i.e zero(0) values get copied to invoice for VF01.

Now there is a routine 928-Order-related.3rd Party Item in VOFM.

Here inside that loop (LOOP AT gi_vbep INTO gwa_vbep.)

Every item is copied to gwa_vbep.

What change in the code i need to do to stop other values coming to invoice.

I have given the code below:-

FORM BEDINGUNG_PRUEFEN_928.

  • Data declaration for additional check from routine 900.

data:

gv_lfrel type vbep-lfrel,

gv_subrc type sy-subrc,

gv_text(34) type c,

gv_vbeln type vbfa-vbeln,

gv_posnn type vbfa-posnn,

gv_ebeln type ekpo-ebeln,

gv_ebelp type ekpo-ebelp,

gv_elikz type ekpo-elikz,

gv_vbeln2 type vbfa-vbeln,

gv_lfsta type vbup-lfsta.

*begin of DDIK902383

data : gv_rfmng type vbfa-rfmng,

gv_rfmng1 type vbfa-rfmng.

*end of DDIK902383

  • Constants declaration

data:

c_x(1) type c value 'X',

c_c(1) type c value 'C',

c_4 type i value 4,

c_0 type i value 0,

c_text1(6) type c value 'item',

c_text2(22) type c value 'is not fully completed'.

*begin of DDIK902383

data : c_r(1) type c value 'R',

c_m(1) type c value 'M',

c_a(1) TYPE c VALUE 'A',

c_b(1) TYPE c VALUE 'B',

c_j(1) TYPE c VALUE 'J'.

*end of DDIK902383

  • Internal table declaration

Types:

begin of gty_vbep,

vbeln type vbep-vbeln,

posnr type vbep-posnr,

lfrel type vbep-lfrel,

banfn type vbep-banfn,

end of gty_vbep.

*begin of DDIK902383

types : begin of gty_vbap,

vbeln type vbap-vbeln,

posnr type vbap-posnr,

end of gty_vbap,

begin of gty_vbfa,

vbeln type vbfa-vbeln,

vbelv type vbfa-vbelv,

posnv type vbfa-posnv,

rfmng type vbfa-rfmng,

vbtyp_n type vbfa-vbtyp_n,

vbtyp_v type vbfa-vbtyp_v,

end of gty_vbfa.

  • internal table declaration and workarea declaration

data : i_vbap type standard table of gty_vbap,

i_vbfa type standard table of gty_vbfa,

i_vbfa1 type standard table of gty_vbfa,

gwa_vbap type gty_vbap,

gwa_vbfa type gty_vbfa,

gwa_vbfa1 type gty_vbfa.

types : begin of gty_eban,

banfn type eban-banfn,

ebeln type eban-ebeln,

bsmng type eban-bsmng,

end of gty_eban,

begin of gty_ekpo,

ebeln type ekpo-ebeln,

ebelp type ekpo-ebelp,

elikz type ekpo-elikz,

end of gty_ekpo,

begin of gty_vbup,

vbeln type vbup-vbeln,

gbsta type vbup-gbsta,

end of gty_vbup,

begin of gty_vbup1,

vbeln type vbup-vbeln,

lfsta type vbup-lfsta,

gbsta type vbup-gbsta,

end of gty_vbup1.

data : li_ekpo type standard table of gty_ekpo,

lwa_ekpo type gty_ekpo,

li_eban type standard table of gty_eban,

lwa_eban type gty_eban,

li_vbup type standard table of gty_vbup,

lwa_vbup type gty_vbup,

li_vbup1 type standard table of gty_vbup1,

lwa_vbup1 type gty_vbup1.

  • Internal table declaration

data:

gi_vbep type standard table of gty_vbep.

  • Work area declaration

data: gwa_vbep type gty_vbep.

  • End of data declaration for additional check from routine 900.

SY-SUBRC = 0.

CHECK : ANALYZE_MODE IS INITIAL.

  • Billing Block

IF VBAP-FAKSP NE SPACE.

SELECT SINGLE * FROM TVFSP WHERE FAKSP = VBAP-FAKSP

AND FKART = TVFK-FKART.

IF SY-SUBRC = 0.

PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR '015' SPACE

SPACE SPACE.

SY-SUBRC = 4.

EXIT.

ENDIF.

SY-SUBRC = 0.

ENDIF.

  • Billing Status

  • IF VBUP-FKSAA = ' '.

IF VBUP-FKSAA = 'C'.

PERFORM VBFS_HINZUFUEGEN_ALLG

USING VBAP-VBELN VBAP-POSNR 'VF' 'I' '045'

SPACE SPACE SPACE SPACE.

SY-SUBRC = 4.

EXIT.

ENDIF.

  • Check order related billing relevancy of item category

IF VBAP-FKREL NA 'BF'.

PERFORM VBFS_HINZUFUEGEN_ALLG

USING VBAP-VBELN VBAP-POSNR 'VF' 'I' '044'

SPACE SPACE SPACE SPACE.

SY-SUBRC = 4.

EXIT.

ENDIF.

  • Billing Block in Customer Master

IF KURGV-FAKSD NE SPACE.

SELECT SINGLE * FROM TVFSP WHERE FAKSP = KURGV-FAKSD

AND FKART = TVFK-FKART.

IF SY-SUBRC = 0.

PERFORM VBFS_HINZUFUEGEN USING '000000' '068' KURGV-KUNNR

SPACE SPACE.

SY-SUBRC = 4.

EXIT.

ENDIF.

SY-SUBRC = 0.

ENDIF.

  • Check that there is a quantity due to be billed

IF VBRP-FKIMG = 0.

PERFORM VBFS_HINZUFUEGEN_ALLG

USING VBAP-VBELN VBAP-POSNR 'VF' 'I' '147'

SPACE SPACE SPACE SPACE.

SY-SUBRC = 4.

ENDIF.

  • Check that no negative billing documents are created

IF TVFK-VBTYP = 'M'.

IF VBRP-SHKZG CA 'BX'.

SY-SUBRC = 4.

ENDIF.

ENDIF.

IF ( TVCPF-FKMGK = 'F' AND VBAPF-REWRT = 0 ) OR

TVFK-VBTYP = 'O'.

VBRP-WAVWR = '0.01'.

ENDIF.

  • Code inserted for additional check from routine 900

SELECT vbeln posnr lfrel banfn

FROM vbep

INTO TABLE gi_vbep

WHERE vbeln EQ vbap-vbeln.

if gi_vbep[] is not initial.

select banfn ebeln bsmng

from eban

into table li_eban

for all entries in gi_vbep

where banfn = gi_vbep-banfn

and bsmng NE 0.

if sy-subrc = 0.

select ebeln ebelp elikz

from ekpo into table li_ekpo

for all entries in li_eban

where ebeln eq li_eban-ebeln

and elikz eq c_x.

endif.

endif.

select vbeln vbelv posnv rfmng vbtyp_n vbtyp_v

from vbfa

into table i_vbfa1

for all entries in gi_vbep

where vbelv eq gi_vbep-vbeln

and posnv eq gi_vbep-posnr

and vbtyp_n eq c_j

and vbtyp_v eq c_c.

if sy-subrc eq 0.

select vbeln lfsta gbsta from vbup

into table li_vbup1

for all entries in i_vbfa1

where vbeln = i_vbfa1-vbelv.

select vbeln gbsta from vbup

into table li_vbup

for all entries in i_vbfa1

where vbeln = i_vbfa1-vbeln.

endif.

LOOP AT gi_vbep INTO gwa_vbep.

CLEAR:

gv_vbeln2,

gv_lfsta.

IF NOT gwa_vbep-banfn IS INITIAL.

read table li_eban into lwa_eban

with key banfn = gwa_vbep-banfn.

if sy-subrc = 0.

Read table li_ekpo into lwa_ekpo

with key ebeln = lwa_eban-ebeln

elikz = c_x.

IF sy-subrc NE c_0.

sy-subrc = c_4.

gv_subrc = sy-subrc.

gv_vbeln2 = gwa_vbep-posnr.

ENDIF.

ELSE.

sy-subrc = c_4.

gv_subrc = sy-subrc.

gv_vbeln2 = gwa_vbep-posnr.

ENDIF.

ELSEIF gwa_vbep-lfrel EQ c_x.

read table i_vbfa1 into gwa_vbfa1

with key vbelv = gwa_vbep-vbeln

posnv = gwa_vbep-posnr

vbtyp_n = c_j

vbtyp_v = c_c.

if sy-subrc eq 0.

Read table li_vbup1 into lwa_vbup1

with key vbeln = gwa_vbfa1-vbelv

lfsta = c_c.

endif.

if sy-subrc = 0.

Read table li_vbup into lwa_vbup

with key gbsta = c_b.

if sy-subrc ne 0.

Read table li_vbup into lwa_vbup

with key gbsta = c_a.

if sy-subrc ne 0.

Read table li_vbup into lwa_vbup

with key gbsta = ' '.

if sy-subrc ne 0.

else.

gv_subrc = c_4.

endif.

else.

gv_subrc = c_4.

endif.

else.

gv_subrc = c_4.

endif.

if gv_subrc ne c_4.

Read table li_vbup into lwa_vbup

with key gbsta = c_c.

if sy-subrc = 0.

gv_subrc = c_0.

endif.

endif.

if gv_subrc = c_4.

sy-subrc = c_4.

else.

sy-subrc = c_0.

endif.

endif.

if sy-subrc = 0.

sy-subrc = 0.

else.

  • error processing

  • issue an error message u2013 item is already fully invoiced

PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR '147' SPACE SPACE SPACE.

Sy-subrc = c_4.

endif.

if sy-subrc ne c_0.

sy-subrc = c_4.

gv_subrc = sy-subrc.

gv_vbeln2 = gwa_vbep-posnr.

endif.

endif.

  • Start of Addition on 01/08/05 - Request DD1K902189

    • endif.

  • End of Addition on 01/08/05 - Request DD1K902189

endloop.

if gv_subrc eq c_4.

concatenate c_text1 gv_vbeln2 c_text2 into gv_text

separated by space.

perform vbfs_hinzufuegen_allg using vbap-vbeln vbap-posnr 'VF' 'W'

'801'gv_text space space space.

sy-subrc = gv_subrc.

endif.

  • End of code insertion for additional check from routine 900.

  • Start of Addition on 01/08/05 - Request DD1K902189

  • Donot Invoice if it is a Contracted Item

if vbap-zseno = c_x.

sy-subrc = 4.

endif.

  • End of Addition on 01/08/05 - Request DD1K902189

ENDFORM. "BEDINGUNG_PRUEFEN_928

*eject