Sunday, November 29, 2009

Plant specific number range at Invoicing

The requirement is to trigger plant specific number range at invoicing since every plant has to declare there own excise number range in India. So we need to validate Plant, Billing type and number range object.
Step-1:
Create different number range Interval:-
T-code - SNRO; Use Object RV_BELEG. Click on number Ranges - Click in Change view (Pencil Marked) of Interval.
Add new interval.
Tips: Since, Its a plant specific number range you might want to use Common Starting Alphabet for each of your plant to make your life easier.


Step-2:
T-code: SE38, Use Userexit - RV60AFZZ
 Use code below.


data : lt_xvbrp like xvbrp occurs 0,
ls_xvbrp like line of xvbrp.
data : lv_werks type werks_d.
data : lv_count type i,
lv_numki type numki.
data : lt_xvbrk like xvbrk occurs 0,
ls_xvbrk like line of xvbrk.
data : lv_flag_exp type i value 0,
lv_flag_dom type i value 0.
types : begin of ty_vbak,
vbeln type vbeln_va,
end of ty_vbak.
data : lt_vbak type table of ty_vbak,
ls_vbak type ty_vbak.
If xvbrp is not initial.
lt_xvbrp[] = xvbrp[].
sort lt_xvbrp by werks.
delete ADJACENT DUPLICATES FROM lt_xvbrp COMPARING werks.
describe table lt_xvbrp lines lv_count.
if lv_count gt 1.
message e398(00) with 'Different Plants for Single Billing Not Possible'.
clear lv_count.
elseif lv_count eq 1 .
if lt_xvbrp is not initial.
if sy-tcode ne 'VF11'.
read table xvbrk into ls_xvbrk index 1.
ELSE.
read table xvbrk into ls_xvbrk WITH KEY VBTYP = 'N'.
ENDIF.
if sy-subrc eq 0.
if ls_xvbrk-fkart ne 'ZEXP'.
read table lt_xvbrp into ls_xvbrp index 1.
if sy-subrc eq 0.
select single numki from zsd_binr into lv_numki
where werks = ls_xvbrp-werks
and fkart = ls_xvbrk-fkart.
endif.
endif.
endif.
endif.
if lv_numki is not initial.
US_RANGE_INTERN = lv_numki.
else.
message e398(00) with 'Number range not Maintained for' ls_xvbrp-werks.
endif.
clear : lv_numki,
ls_xvbrp,
ls_xvbrk.
endif.
endif.
ENDENHANCEMENT.
ENDFORM.


At the end of this your result will be somthing like the Picture Enter your plant and billing type with number range interval you have already created in Step1.
This program will over look the number range assignment in billing type adn use the interval that you give here.
Tips:  it is advisable to delete external number range in such case.


No comments:

Post a Comment