‎2006 Aug 24 4:28 AM
hi i am working on print tax invoice program.
every thing is fine but in the output i am getting duplicate values as below. values repeating again. hope i am clear with my doubt.
222 000 222
1234 000 1234
222 000 222
1234 000 1234
‎2006 Aug 24 4:32 AM
You will have to check your SAP Script / SMART form, why the data is being printed twice. See where exactly this data is being printed and check if there is any loop there or the same data is being passed twice.
Regards,
Ravi
Note : Please mark all the helpful answers
‎2006 Aug 24 4:42 AM
Hi Ravi,
here i attached my code. can u go through it and suggest me..itz very urgent for me.
thanks wil reward the points
report zar0020." LINE-SIZE 80 LINE-COUNT 65 NO STANDARD PAGE HEADING.
*----
Release : ECC 5.0
Module : FI-AR
*
Description : This program will print Tax Invoice on A4
paper
************************************************************************
T A B L E S *
************************************************************************
tables: t001,
bkpf,
kna1,
bsik,
tcurx.
************************************************************************
S E L E C T I O N S C R E E N *
************************************************************************
selection-screen begin of block bl1 with frame title text-101.
parameters: p_bukrs like t001-bukrs memory id buk obligatory,
p_gjahr like bkpf-gjahr default sy-datum(4).
select-options: s_monat for bkpf-monat default sy-datum+4(2),
s_kunnr for kna1-kunnr,
s_lifnr for bsik-lifnr,
s_blart for bkpf-blart,
s_belnr for bkpf-belnr memory id bln,
s_budat for bkpf-budat,
s_bldat for bkpf-bldat,
s_cpudt for bkpf-cpudt.
selection-screen end of block bl1.
selection-screen begin of block bl2 with frame title text-102.
parameters: p_hkont as checkbox.
selection-screen end of block bl2.
selection-screen begin of block bl3 with frame title text-103.
parameters: p_inter as checkbox.
selection-screen end of block bl3.
selection-screen begin of block bl4 with frame title text-104.
parameters: p_rep as checkbox.
selection-screen end of block bl4.
************************************************************************
D A T A D E C L A R A T I O N *
************************************************************************
constants:
c_formname like rsscf-tdform value 'ZTAXINVOICE'.
data: begin of t_inv_hdr occurs 0,
bukrs like bkpf-bukrs,
kunnr like bsid-kunnr,
gjahr like bkpf-gjahr,
belnr like bkpf-belnr,
bldat like bkpf-bldat,
budat like bkpf-budat,
waers like bkpf-waers,
hwaer like bkpf-hwaer,
gst_no like t001z-paval,
reg_no like t001z-paval,
bschl like bsid-bschl,
lifnr like bsik-lifnr,
inv_type(20),
end of t_inv_hdr.
data: begin of t_inv_item occurs 0,
belnr like bseg-belnr,
hkont like bseg-hkont,
bukrs like bseg-bukrs,
gjahr like bseg-gjahr,
buzei like bseg-buzei,
buzid like bseg-buzid,
bschl like bseg-bschl,
koart like bseg-koart,
mwskz like bseg-mwskz,
wrbtr like covp-wogbtr,
dmbtr like covp-wogbtr,
sgtxt like bseg-sgtxt,
tax_rate like covp-wogbtr,
sup_tot like covp-wogbtr,
gst_tot like covp-wogbtr,
pay_tot like covp-wogbtr,
slip_tot type p decimals 2,
total like covp-wogbtr,
shkzg like bseg-shkzg,
lifnr like bsik-lifnr,
***
qsskz like bseg-qsskz,
***
end of t_inv_item.
data:it_item1 like t_inv_item occurs 0 with header line.
data: g_company like t001.
data: it_wrbtr1(20).
data:it_pay_tot1(20).
data:it_mwskz like bseg-mwskz.
data:it_kbetr like bset-kbetr.
data:it_gst type p decimals 2.
data:sup_tot type p decimals 2 .
data:gst_tot type p decimals 2.
data:pay_tot type p decimals 2.
data:pay_tot1 type p decimals 2.
data:pay_tot3 type p decimals 2.
*data:pay_tot3(20).
data:v_pay_tot3 type p decimals 2.
data:v_pay_tot2 type p decimals 2.
data:v_gt_total type p decimals 2.
data:v_pay_total type p decimals 2.
data:sup_tot2 type p decimals 2.
data:gst_tot2 type p decimals 2.
data:pay_tot2 type p decimals 2.
***Revised
data:gst_tot3 type p decimals 2.
data:sup_tot3 type p decimals 2.
*data:gst_tot3(20).
*data:sup_tot3(20).
***
data:pay_tot11(20).
data:k type i.
data:final_sup_tot type p decimals 2 ,
final_gst_tot type p decimals 2,
final_pay_tot type p decimals 2 ,
slip_tot type p decimals 2,
act_total type p decimals 2.
data: final_sup_tot9(20),
final_gst_tot9(20),
act_total9(20),
tax_rate9(20),
pay_tot9(20),
slip_tot9(20).
data:item(3) type c.
data: l_addr_sel like addr1_sel.
data: l_gst_no like t001z-paval,
l_reg_no like t001z-paval.
data:it_adrnr like adrc-addrnumber.
data:begin of it_tax occurs 0,
belnr like bset-belnr,
gjahr like bset-gjahr,
mwskz like bset-mwskz,
hwste like bset-hwste,
fwste like bset-fwste,
fwbas like bset-fwbas,
hwbas like bset-hwbas,
end of it_tax.
data:
v_name1 like adrc-name1,
v_name2 like adrc-name2,
v_name3 like adrc-name3,
v_name4 like adrc-name4,
v_name1_new like adrc-name1,
v_name2_new like adrc-name2,
v_name3_new like adrc-name3,
v_name4_new like adrc-name4,
v_name5(80),
v_name6(80),
v_street5(80),
v_name7(160),
v_name8(160),
v_name9(160),
v_street like adrc-street,
v_street4 like adrc-str_suppl3,
v_city like adrc-city1,
v_post like adrc-post_code1,
v_tele like adrc-tel_number,
v_fax like adrc-fax_number,
v_uri like adr12-uri_srch,
v_regno like t001z-paval,
c_name1 like adrc-name1,
c_name2 like adrc-name2,
c_name3 like adrc-name3,
c_name4 like adrc-name4,
c_nam1 like adrc-name1,
c_nam2 like adrc-name2,
c_nam3 like adrc-name3,
c_nam4 like adrc-name4,
c_name5(80),
c_name6(80),
c_street5(80),
c_street like adrc-street,
c_street4 like adrc-str_suppl3,
c_city like adrc-city1,
c_city1 like adrc-city1,
c_post like adrc-post_code1,
c_tele like adrc-tel_number,
c_fax like adrc-fax_number,
c_country like adrc-country,
c_landx like t005t-landx,
c_country1 like t005t-landx,
c_cntry like t005t-landx,
v_remark like adrct-remark.
data:name like thead-tdname.
data:it_phone like tline occurs 0 with header line.
data:it_name like tline occurs 0 with header line.
data:it_account like tline occurs 0 with header line.
data:it_addi like tline occurs 0 with header line.
data:it_cheque like tline occurs 0 with header line.
data:it_item like tline occurs 0 with header line.
data:it_ben like tline occurs 0 with header line.
data: ls_faede like faede.
data:it_sgtxt like bseg-sgtxt.
data: ls_bkpf like bkpf,
ls_bseg like bseg,
it_duedate(10).
data:it_waers like t001-waers.
data:it_waers1 like t001-waers.
data:n1 type i.
data:diff1 type p decimals 2.
data:tax_rate type p decimals 5.
data:it_header(20).
data:it_bschl like bsid-bschl.
data:it_land like t001-land1.
data:it_landx like t005t-landx.
data:text(2000).
data:text1(200).
data:it_kbetr1 like bset-kbetr,
it_tax1(3) type c.
data:it_acctype(1).
data:it_cust like kna1-lifnr.
data:it_land1 like t001-land1,
it_kalsm like t005-kalsm,
it_text1(50).
data:it_kverm like knb1-kverm.
data: vari1(18),
v_flag(1) value 'F'.
data:it_fwbas(20),
it_fwste(20),
pay_tot19(20),
gst_tot29(20),
sup_tot29(20),
pay_tot29(20),
gst_tot39(20),
sup_tot39(20),
pay_tot39(20),
tax_rate99(20),
v_amt(20),
v_amt1(20),
v_fwbas type bset-fwbas,
v_taxamt(20),
v_total(20),
v_amount type bseg-wrbtr,
gt_amt type p decimals 2,
gt_taxamt type p decimals 2,
gt_netamt type p decimals 2,
gt_tax type p decimals 2,
gt_amt1(20),
gt_total type p decimals 2,
v_grpid like bkpf-grpid,
v_grpid1(3) type c,
v_text(100) type c,
v_text20(20) type c.
*********************
***************************************************
I N I T I A L I Z A T I O N *
************************************************************************
*initialization.
************************************************************************
A T S E L E C T I O N - S C R E E N *
************************************************************************
at selection-screen on p_bukrs.
select single * into g_company
from t001
where bukrs = p_bukrs.
if sy-subrc ne 0.
message e398(00) with 'Company code' p_bukrs 'does not exist'."#EC *
endif.
authority-check object 'F_BKPF_BUK'
id 'BUKRS' field p_bukrs
id 'ACTVT' field '03'.
if sy-subrc ne 0.
message e398(00) with 'You are not authorized to access company '
p_bukrs.
endif.
at selection-screen on p_inter.
if s_lifnr ne '' and p_inter = ''.
message e398(00) with 'Please select Interco check box'."#EC *
elseif s_kunnr ne '' and p_inter ne ''.
message e398(00) with 'Ple dont select Interco when you select Customer '."#EC *
endif.
************************************************************************
S T A R T O F D A T A S E L E C T I O N *
************************************************************************
start-of-selection.
item = '00'.
if p_inter eq ''.
it_acctype = 'D'.
else.
it_acctype = 'K'.
endif.
perform read_customer_invoices.
if t_inv_item[] is initial.
write ' No Records Found'.
endif.
perform form_print_out.
end-of-selection.
************************************************************************
E N D O F D A T A S E L E C T I O N *
************************************************************************
&----
*& Form form_print_out
&----
form form_print_out.
data: itab_options like itcpo occurs 0 with header line.
itab_options-tddest = 'LOCL'.
itab_options-tdpreview = 'X'.
itab_options-tdtitle = sy-title.
itab_options-tdiexit = 'X'.
itab_options-tdnewid = 'X'.
itab_options-tddelete = 'X'.
append itab_options.
call function 'OPEN_FORM'
exporting
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
device = 'PRINTER'
DIALOG = 'X'
form = c_formname
language = sy-langu
options = itab_options
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
spool_error = 10
codepage = 11
others = 12
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
loop at t_inv_hdr.
clear sup_tot.
clear pay_tot.
clear gst_tot.
clear slip_tot.
clear act_total.
clear it_waers.
clear it_waers1.
clear it_duedate.
clear it_item.
refresh it_item.
clear it_phone.
refresh it_phone.
clear it_account.
refresh it_account.
clear it_name.
refresh it_name.
clear it_addi.
refresh it_addi.
clear it_ben.
refresh it_ben.
clear name.
clear it_cust.
clear it_header.
clear it_land1.
clear it_kalsm.
clear it_text1.
clear it_kverm.
clear pay_tot3.
clear it_item1.
refresh it_item1.
clear k.
clear v_flag.
clear : c_country1, c_cntry.
customer number
if p_inter eq ''.
it_cust = t_inv_hdr-kunnr.
else.
it_cust = t_inv_hdr-lifnr.
endif.
read customer address
if one time vendor
select single name1 name2 name3 name4 pstlz ort01 stras
into (c_name1, c_name2, c_name3, c_name4, c_post, c_city, c_street5)
from bsec where bukrs = t_inv_hdr-bukrs and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr.
if sy-subrc <> 0.
*Logic changed bsrao on 27.07.2006
if sy-subrc <> 0 or c_name1 eq ' '.
if p_inter eq ''.
select single adrnr from kna1 into it_adrnr where kunnr = t_inv_hdr-kunnr.
select single kverm from knb1 into it_kverm where kunnr = t_inv_hdr-kunnr and
bukrs = p_bukrs.
else.
select single adrnr from lfa1 into it_adrnr where lifnr = t_inv_hdr-lifnr.
select single kverm from lfb1 into it_kverm where lifnr = t_inv_hdr-lifnr and
bukrs = p_bukrs.
endif.
select single name1 name2 name3 name4 street str_suppl3 city1 post_code1 tel_number fax_number country
from adrc into (c_name1,c_name2,c_name3,c_name4,c_street,c_street4,c_city,c_post,c_tele,c_fax, c_country)
where addrnumber = it_adrnr.
select single landx from t005t into c_landx
where land1 = c_country
and spras = sy-langu.
***Revised
v_city1 = itab_cust-city1.
clear : c_cntry, c_country1.
c_city1 = c_city.
translate c_city1 to lower case.
c_cntry = c_landx.
translate c_cntry to lower case.
if c_city1 ne c_cntry .
c_country1 = c_landx.
endif.
read table itab_t005t with key lnd1 = itab_cust-country.
v_cntry = itab_t005t-landx.
translate v_cntry to lower case.
***
concatenate c_street(35) c_street4(35) into c_street5 separated by space.
endif.
concatenate c_name1(35) c_name2(35) into c_name5 separated by space.
concatenate c_name3(35) c_name4(35) into c_name6 separated by space.
***Revised
*clear : v_name7.
concatenate v_name5(70) v_name6(70) into v_name7 separated by space.
***
concatenate t_inv_hdr-bukrs t_inv_hdr-belnr t_inv_hdr-gjahr into name.
read singnature details
PHONE
call function 'READ_TEXT'
exporting
client = sy-mandt
id = 'Z001'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_phone
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc <> 0.
select single ztel from ztarinv into it_phone-tdline where bukrs = p_bukrs.
endif.
read table it_phone index 1.
bank name
call function 'READ_TEXT'
exporting
CLIENT = SY-MANDT
id = 'Z002'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_name
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
if sy-subrc <> 0.
select single zbankname from ztarinv into it_name-tdline where bukrs = p_bukrs.
endif.
read table it_name index 1.
Account no
call function 'READ_TEXT'
exporting
CLIENT = SY-MANDT
id = 'Z003'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_account
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
if sy-subrc <> 0.
select single zbankacc from ztarinv into it_account-tdline where bukrs = p_bukrs.
endif.
read table it_account index 1.
Additional note.
call function 'READ_TEXT'
exporting
CLIENT = SY-MANDT
id = 'Z004'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_addi
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
if sy-subrc <> 0.
endif.
read table it_addi index 1.
loop at it_addi.
text1 = it_addi-tdline.
concatenate text text1 into text .
endloop.
cheque payable to
call function 'READ_TEXT'
exporting
CLIENT = SY-MANDT
id = 'Z005'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_cheque
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
if sy-subrc <> 0.
endif.
read table it_cheque index 1.
beneficiary
call function 'READ_TEXT'
exporting
CLIENT = SY-MANDT
id = 'Z007'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_ben
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
if sy-subrc <> 0.
endif.
read table it_ben index 1.
header text
call function 'READ_TEXT'
exporting
CLIENT = SY-MANDT
id = 'Z008'
language = sy-langu
name = name
object = 'BELEG'
tables
lines = it_item
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
if sy-subrc <> 0.
endif.
read table it_item index 1.
if sy-subrc = 0.
concatenate p_bukrs t_inv_hdr-belnr t_inv_hdr-gjahr into vari1.
v_flag = 'T'.
endif.
due date
select single * from bkpf into ls_bkpf "because of 'BLDAT'
where bukrs = p_bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr.
select single * from bseg into ls_bseg
where bukrs = p_bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr
and zfbdt ne '00000000'.
move-corresponding ls_bkpf to ls_faede.
move-corresponding ls_bseg to ls_faede.
call function 'DETERMINE_DUE_DATE'
exporting
i_faede = ls_faede
importing
e_faede = ls_faede
exceptions
others = 1.
concatenate ls_faede-netdt6(2) '.' ls_faede-netdt4(2) '.' ls_faede-netdt+0(4) into it_duedate.
calculating tax amount
loop at t_inv_item where belnr eq t_inv_hdr-belnr and koart <> it_acctype.
clear it_gst.
clear it_kbetr.
clear it_mwskz.
select single mwskz from bseg into it_mwskz where bukrs = t_inv_item-bukrs and
belnr = t_inv_item-belnr and
gjahr = t_inv_item-gjahr and
buzei = t_inv_item-buzei .
select single kbetr from bset into it_kbetr where bukrs = t_inv_item-bukrs and
belnr = t_inv_item-belnr and
gjahr = t_inv_item-gjahr and
mwskz = t_inv_item-mwskz .
it_gst = it_kbetr / 1000.
it_gst = it_gst * t_inv_item-wrbtr.
t_inv_item-tax_rate = it_gst.
t_inv_item-pay_tot = t_inv_item-wrbtr + t_inv_item-tax_rate.
modify t_inv_item.
endloop.
caluculating actual amount
loop at t_inv_item where bukrs = t_inv_hdr-bukrs and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr and
koart eq it_acctype and buzid <> 'T' .
write t_inv_item-wrbtr to it_wrbtr1 currency t_inv_hdr-waers.
act_total = act_total + t_inv_item-wrbtr .
endloop.
act_total = 0 - act_total.
if click gl account check box
data : v_txt like bseg-sgtxt.
clear : v_txt.
sort t_inv_item by belnr.
sort t_inv_item by belnr hkont.
if p_hkont ne '' .
sort t_inv_item by belnr hkont.
loop at t_inv_item where belnr = t_inv_hdr-belnr .
delete t_inv_item where koart = it_acctype and belnr = t_inv_hdr-belnr .
at new hkont.
read table t_inv_item index sy-tabix.
move-corresponding t_inv_item to it_item1.
append it_item1.
endat.
if t_inv_item-koart ne it_acctype.
sup_tot = sup_tot + t_inv_item-wrbtr.
gst_tot = gst_tot + t_inv_item-tax_rate.
pay_tot = sup_tot + gst_tot.
at end of hkont.
k = k + 1.
it_item1-wrbtr = sup_tot .
it_item1-tax_rate = gst_tot .
it_item1-pay_tot = pay_tot.
modify it_item1 index k.
clear sup_tot.
clear gst_tot.
clear pay_tot.
clear it_sgtxt.
endat.
endif.
endloop.
delete t_inv_item where belnr = t_inv_hdr-belnr .
endif.
loop at it_item1 where belnr = t_inv_hdr-belnr.
move-corresponding it_item1 to t_inv_item.
append t_inv_item.
endloop.
if it_item-tdline ne '' and p_hkont ne 'X'.
clear sup_tot.
clear gst_tot.
clear pay_tot.
clear it_sgtxt.
loop at t_inv_item where belnr = t_inv_hdr-belnr .
if t_inv_item-koart ne it_acctype.
sup_tot = sup_tot + t_inv_item-wrbtr.
gst_tot = gst_tot + t_inv_item-tax_rate.
pay_tot = sup_tot + gst_tot.
delete t_inv_item .
endif.
endloop.
if v_flag = 'T'.
clear it_item-tdline.
endif.
t_inv_item-sgtxt = it_item-tdline.
t_inv_item-wrbtr = sup_tot .
t_inv_item-tax_rate = gst_tot .
t_inv_item-pay_tot = pay_tot.
append t_inv_item.
endif.
select belnr gjahr mwskz hwste fwste fwbas hwbas from bset into table it_tax where
bukrs = t_inv_hdr-bukrs and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr .
call function 'START_FORM'
exporting
ARCHIVE_INDEX =
form = c_formname
language = sy-langu
startpage = 'FIRST'
PROGRAM = ' '
MAIL_APPL_OBJECT =
IMPORTING
LANGUAGE =
exceptions
form = 1
format = 2
unended = 3
unopened = 4
unused = 5
spool_error = 6
codepage = 7
others = 8
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if p_inter eq '' and p_rep eq ''.
select single bschl from bsid into it_bschl where bukrs = t_inv_hdr-bukrs and
kunnr = t_inv_hdr-kunnr and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr.
if it_bschl = '11'.
it_header = 'Credit Note'.
else.
it_header = 'Tax Invoice'.
endif.
elseif p_inter eq '' and p_rep eq 'X'.
select single bschl from bsad into it_bschl where bukrs = t_inv_hdr-bukrs and
kunnr = t_inv_hdr-kunnr and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr.
if it_bschl = '11'.
it_header = 'Credit Note'.
else.
it_header = 'Tax Invoice'.
endif.
elseif p_inter eq 'X' .
select single bschl from bsik into it_bschl where bukrs = t_inv_hdr-bukrs and
lifnr = t_inv_hdr-lifnr and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr.
if it_bschl = '31'.
it_header = 'Credit Note'.
else.
it_header = 'Tax Invoice'.
endif.
elseif p_inter eq 'X' and p_rep eq 'X'.
select single bschl from bsak into it_bschl where bukrs = t_inv_hdr-bukrs and
lifnr = t_inv_hdr-lifnr and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr.
if it_bschl = '31'.
it_header = 'Credit Note'.
else.
it_header = 'Tax Invoice'.
endif.
endif.
currency
call function 'WRITE_FORM'
exporting
element = 'INVOICE_HEADING'
function = 'SET'
type = 'BODY'
window = 'HEADER'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
loop at t_inv_item where bukrs = t_inv_hdr-bukrs and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr and
koart <> it_acctype and buzid <> 'T' .
if t_inv_item-qsskz+0(1) eq 'I'.
delete t_inv_item.
endif.
final_sup_tot = final_sup_tot + t_inv_item-wrbtr.
final_gst_tot = final_gst_tot + t_inv_item-tax_rate.
final_pay_tot = final_sup_tot + final_gst_tot.
slip_tot = slip_tot + t_inv_item-wrbtr + t_inv_item-tax_rate.
endloop.
describe table t_inv_item lines n1 .
if act_total ne final_pay_tot .
diff1 = act_total - final_pay_tot.
slip_tot = slip_tot + diff1.
final_gst_tot = final_gst_tot + diff1.
do n1 times .
read table t_inv_item index n1.
if t_inv_item-tax_rate <> 0.
exit.
endif.
n1 = n1 - 1 .
enddo.
t_inv_item-tax_rate = t_inv_item-tax_rate + diff1.
t_inv_item-pay_tot = t_inv_item-pay_tot + diff1.
modify t_inv_item index n1.
endif.
select local currency
select single waers land1 from t001 into (it_waers, it_land) where bukrs = p_bukrs.
select document currency
select single waers from bkpf into it_waers1 where bukrs = t_inv_hdr-bukrs and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr.
select local country name
select single landx from t005t into it_landx where spras = sy-langu and land1 = it_land.
write slip_tot to slip_tot9 currency t_inv_hdr-waers.
write pay_tot3 to pay_tot9 currency t_inv_hdr-waers.
call function 'WRITE_FORM'
exporting
element = 'SLIP'
function = 'APPEND'
type = 'BODY'
window = 'PAYMEN_D'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
delete t_inv_item where koart = it_acctype and belnr = t_inv_hdr-belnr.
loop at t_inv_item where bukrs = t_inv_hdr-bukrs and
belnr = t_inv_hdr-belnr and
gjahr = t_inv_hdr-gjahr and
koart <> it_acctype and buzid <> 'T' .
write t_inv_item-wrbtr to it_wrbtr1 currency t_inv_hdr-waers.
write t_inv_item-pay_tot to it_pay_tot1 currency t_inv_hdr-waers.
write t_inv_item-tax_rate to tax_rate9 currency t_inv_hdr-waers.
item = item + 1.
if v_flag = 'T'.
clear item.
call function 'WRITE_FORM'
exporting
element = 'HEAD_TEXT'
function = 'APPEND'
type = 'BODY'
window = 'MAIN'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
endif.
call function 'WRITE_FORM'
exporting
element = 'LINE_ITEM'
function = 'APPEND'
type = 'BODY'
window = 'MAIN'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
call function 'WRITE_FORM'
exporting
element = 'COMP_ADD'
function = 'SET'
type = 'BODY'
window = 'COM_ADDR'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
call function 'WRITE_FORM'
exporting
element = 'COMP_DET'
function = 'SET'
type = 'BODY'
window = 'COMP_DET'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
at end of belnr . "#EC *
item = '00'.
write final_sup_tot to final_sup_tot9 currency t_inv_hdr-waers.
write final_gst_tot to final_gst_tot9 currency t_inv_hdr-waers.
write act_total to act_total9 currency t_inv_hdr-waers.
call function 'WRITE_FORM'
exporting
element = 'TOTAL'
function = 'APPEND'
type = 'BODY'
window = 'MAIN'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
data : v_tabix like sy-tabix,
v_count type i.
clear : v_tabix, v_count.
describe table it_tax lines v_count.
loop at it_tax.
v_tabix = sy-tabix.
pay_tot1 = it_tax-fwbas + it_tax-fwste.
gst_tot2 = gst_tot2 + it_tax-fwbas.
sup_tot2 = sup_tot2 + it_tax-fwste.
pay_tot2 = pay_tot2 + pay_tot1.
gst_tot3 = gst_tot3 + it_tax-hwbas.
sup_tot3 = sup_tot3 + it_tax-hwste.
pay_tot11 = it_tax-hwbas + it_tax-hwste.
pay_tot3 = pay_tot3 + pay_tot11.
select single kbetr from bset into it_kbetr1 where bukrs = p_bukrs and
belnr = it_tax-belnr and
gjahr = it_tax-gjahr and
mwskz = it_tax-mwskz.
it_tax1 = it_kbetr1 / 10.
tax description
select single land1 from t001 into it_land1 where bukrs = p_bukrs.
select single kalsm from t005 into it_kalsm where land1 = it_land1.
select single text1 from t007s into it_text1 where spras = sy-langu and
kalsm = it_kalsm and
mwskz = it_tax-mwskz .
data : it_sgtxt like bseg-sgtxt,
v_string type string,
v_var1 type string,
v_var2 type string.
clear : it_sgtxt, v_string, v_var1, v_var2.
clear : v_amt, v_taxamt, v_total, v_fwbas.
if g_company-land1 = 'SG' and g_company-waers <> 'SGD'.
select single sgtxt from bseg into it_sgtxt
where bukrs = p_bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr
and mwskz = it_tax-mwskz
and buzid = 'T'.
if sy-subrc = 0.
v_string = it_sgtxt.
split v_string at '/' into v_var1 v_var2 .
if v_var1 co '1234567890.'.
v_amt = v_var1.
endif.
if v_var2 co '1234567890.'.
v_taxamt = v_var2.
endif.
gt_amt = gt_amt + v_amt.
gt_taxamt = gt_taxamt + v_var2.
else.
call function 'CONVERT_TO_LOCAL_CURRENCY'
exporting
date = ls_bkpf-budat
foreign_amount = it_tax-fwbas
foreign_currency = ls_bkpf-waers
local_currency = 'SGD'
type_of_rate = 'M'
importing
local_amount = v_fwbas
exceptions
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
others = 6.
v_amt1 = v_fwbas.
gt_amt1 = gt_amt1 + v_amt1.
endif.
gt_netamt = gt_amt + gt_amt1.
gt_tax = gt_taxamt.
gt_total = gt_netamt + gt_tax.
endif.
write it_tax-fwbas to it_fwbas currency t_inv_hdr-waers.
write it_tax-fwste to it_fwste currency t_inv_hdr-waers.
write i_fwste to it_fwste currency t_inv_hdr-waers.
write pay_tot1 to pay_tot19 currency t_inv_hdr-waers.
call function 'WRITE_FORM'
exporting
element = 'TAX'
function = 'APPEND'
type = 'BODY'
window = 'MAIN'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
delete it_tax index v_tabix.
endloop.
if v_count ne 0.
write gst_tot2 to gst_tot29 currency t_inv_hdr-waers.
write sup_tot2 to sup_tot29 currency t_inv_hdr-waers.
write pay_tot2 to pay_tot29 currency t_inv_hdr-waers.
else.
write final_sup_tot9 to gst_tot29 currency t_inv_hdr-waers.
write final_gst_tot9 to sup_tot29 currency t_inv_hdr-waers.
write act_total9 to pay_tot29 currency t_inv_hdr-waers.
endif.
if g_company-land1 = 'SG' and g_company-waers <> 'SGD'.
if v_count ne 0.
write gt_netamt to gst_tot39 .
write gt_taxamt to sup_tot39 .
write gt_total to pay_tot39 .
it_waers = 'SGD'.
else.
clear : v_amount.
call function 'CONVERT_TO_LOCAL_CURRENCY'
exporting
date = ls_bkpf-budat
foreign_amount = act_total
foreign_currency = ls_bkpf-waers
local_currency = 'SGD'
type_of_rate = 'M'
importing
local_amount = v_amount
exceptions
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
others = 6.
pay_tot39 = v_amount.
it_waers = 'SGD'.
endif.
select single * from tcurx where currkey = g_company-waers.
if sy-subrc = 0.
if tcurx-currdec = 0.
v_gt_total = gt_total * 100.
elseif tcurx-currdec = 3.
v_gt_total = gt_total / 10.
endif.
else.
v_gt_total = gt_total.
endif.
select single * from tcurx where currkey = t_inv_hdr-waers.
if sy-subrc = 0.
if tcurx-currdec = 0.
v_pay_total = pay_tot2 * 100.
elseif tcurx-currdec = 3.
v_pay_total = pay_tot2 / 10.
endif.
else.
v_pay_total = pay_tot2.
endif.
if v_pay_total ne 0.
tax_rate = v_gt_total / v_pay_total.
write tax_rate to tax_rate99. "currency g_company-waers.
endif.
else.
select single * from tcurx where currkey = g_company-waers.
if sy-subrc = 0.
if tcurx-currdec = 0.
v_pay_tot3 = pay_tot3 * 100.
elseif tcurx-currdec = 3.
v_pay_tot3 = pay_tot3 / 10.
endif.
else.
v_pay_tot3 = pay_tot3.
endif.
select single * from tcurx where currkey = t_inv_hdr-waers.
if sy-subrc = 0.
if tcurx-currdec = 0.
v_pay_tot2 = pay_tot2 * 100.
elseif tcurx-currdec = 3.
v_pay_tot2 = pay_tot2 / 10.
endif.
else.
v_pay_tot2 = pay_tot2.
endif.
tax_rate = v_pay_tot3 / v_pay_tot2.
write gst_tot3 to gst_tot39 currency g_company-waers.
write sup_tot3 to sup_tot39 currency g_company-waers.
write tax_rate to tax_rate99. "currency g_company-waers.
if v_count ne 0 .
write pay_tot3 to pay_tot39 currency g_company-waers.
endif.
endif.
call function 'WRITE_FORM'
exporting
element = 'TAX_TOTAL'
function = 'APPEND'
type = 'BODY'
window = 'MAIN'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
clear final_sup_tot.
clear final_pay_tot.
clear final_gst_tot.
clear gst_tot2.
clear pay_tot2.
clear sup_tot2.
clear gst_tot3.
clear sup_tot3.
clear act_total.
clear it_item1.
clear gt_netamt.
clear gt_tax.
clear gt_total.
clear gt_amt.
clear gt_amt1.
clear gt_taxamt.
clear : gst_tot39.
clear : sup_tot39.
clear : pay_tot39.
refresh it_item1.
delete t_inv_item where belnr = t_inv_hdr-belnr.
endat.
endloop.
***Revised
select single grpid from bkpf into v_grpid where bukrs = p_bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr
and grpid ne ' '.
if sy-subrc = 0.
v_grpid1 = v_grpid+0(3).
select single text20 from ztar001 into v_text20 .
if v_grpid1 = 'GVS'.
clear : v_name7.
concatenate v_name5(70) v_name6(70) into v_name7 separated by space.
concatenate v_name7 '-' v_text20 into v_name7.
if v_name2 eq ' '.
c_nam1 = v_name1.
*
*
clear : v_name1.
v_name1 = c_name1.
concatenate c_nam1 '-' v_text20 into v_name1.
concatenate v_name1 '-' v_text20 into c_nam1.
else.
c_nam1 = v_name1.
endif.
if v_name3 eq ''.
c_nam2 = v_name2.
*
clear : v_name2.
v_name2 = c_name2.
concatenate c_nam2 '-' v_text20 into v_name2.
concatenate v_name2 '-' v_text20 into c_nam2.
else.
c_nam2 = v_name2.
endif.
if v_name4 eq ''.
c_nam3 = v_name3.
*
clear : v_name3.
v_name2 = c_name3.
concatenate c_nam3 '-' v_text20 into v_name3.
concatenate v_name3 '-' v_text20 into c_nam3.
else.
c_nam3 = v_name3.
endif.
endif.
endif.
else.
c_nam1 = v_name1 .
c_nam2 = v_name2 .
c_nam3 = v_name3 .
c_nam4 = v_name4 .
endif.
select single grpid from bkpf into v_grpid where bukrs = p_bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr.
*
if sy-subrc = 0.
v_grpid1 = v_grpid+0(3).
*
if v_grpid1 = 'GVS'.
concatenate v_name7 '-' 'GVS' into v_name7.
else.
**
v_text = v_name5.
*
endif.
*
endif.
***
call function 'WRITE_FORM'
exporting
element = 'SIGNATORY'
function = 'APPEND'
type = 'BODY'
window = 'MAIN'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
codepage = 9
others = 10.
call function 'END_FORM'
exceptions
unopened = 1
bad_pageformat_for_print = 2
spool_error = 3
codepage = 4
others = 5.
clear t_inv_hdr.
endloop.
call function 'CLOSE_FORM'
exceptions
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
codepage = 5
others = 6.
endform. " form_print_out
&----
*& Form read_customer_invoices
&----
form read_customer_invoices .
clear : v_remark.
Read company
select single * into g_company
from t001
where bukrs = p_bukrs.
Read company address
l_addr_sel-addrnumber = g_company-adrnr.
select single name1 name2 name3 name4 street str_suppl3 city1 post_code1 tel_number fax_number
from adrc into (v_name1,v_name2,v_name3,v_name4,v_street,v_street4,v_city,v_post,v_tele,v_fax)
where addrnumber = l_addr_sel-addrnumber.
c_nam1 = v_name1.
*
c_nam2 = v_name2.
*
c_nam3 = v_name3.
*
c_nam4 = v_name4.
*Remark
select single remark
from adrct into v_remark
where addrnumber = l_addr_sel-addrnumber
and langu = 'EN'.
select single uri_srch from adr12 into v_uri where addrnumber = l_addr_sel-addrnumber.
select single paval from t001z into v_regno where bukrs = p_bukrs
and party = 'SAPI14'.
translate v_uri to lower case. "#EC *
concatenate v_name1(35) v_name2(35) into v_name5 separated by space.
concatenate v_name3(35) v_name4(35) into v_name6 separated by space.
concatenate v_street(35) v_street4(35) into v_street5 separated by space.
clear : v_name7.
concatenate v_name5(70) v_name6(70) into v_name7 separated by space.
Read company GST No
select single paval into l_gst_no
from t001z
where bukrs = p_bukrs
and party = 'SAPI11'.
Read company Registration no
select single paval into l_reg_no
from t001z
where bukrs = p_bukrs
and party = 'SAPI14'.
Read country's tax procedure
select single kalsm into l_tax_proc
from t005
where land1 = g_company-land1.
Due date
if it is customer
if p_inter eq '' and p_rep eq ''.
select * into corresponding fields of t_inv_hdr
from bsid
where bukrs = p_bukrs
and kunnr in s_kunnr
and belnr in s_belnr
and blart in s_blart
and gjahr = p_gjahr
and monat in s_monat
and budat in s_budat
and bldat in s_bldat
and cpudt in s_cpudt.
t_inv_hdr-gst_no = l_gst_no.
t_inv_hdr-reg_no = l_reg_no.
t_inv_hdr-hwaer = g_company-waers.
append t_inv_hdr.
endselect.
elseif p_inter eq '' and p_rep eq 'X'.
if it is cleared items
select * into corresponding fields of t_inv_hdr
from bsad
where bukrs = p_bukrs
and kunnr in s_kunnr
and belnr in s_belnr
and blart in s_blart
and gjahr = p_gjahr
and monat in s_monat
and budat in s_budat
and bldat in s_bldat
and cpudt in s_cpudt.
t_inv_hdr-gst_no = l_gst_no.
t_inv_hdr-reg_no = l_reg_no.
t_inv_hdr-hwaer = g_company-waers.
append t_inv_hdr.
endselect.
elseif p_inter eq 'X' and p_rep eq ''.
if it is vendor
select * into corresponding fields of t_inv_hdr
from bsik
where bukrs = p_bukrs
and lifnr in s_lifnr
and belnr in s_belnr
and blart in s_blart
and gjahr = p_gjahr
and monat in s_monat
and budat in s_budat
and bldat in s_bldat
and cpudt in s_cpudt
and ( blart = 'IA' or blart = 'IB' or blart = 'IC' or blart = 'ID' ).
t_inv_hdr-gst_no = l_gst_no.
t_inv_hdr-reg_no = l_reg_no.
t_inv_hdr-hwaer = g_company-waers.
append t_inv_hdr.
endselect.
if it is cleared items
elseif p_inter eq 'X' and p_rep eq 'X'.
select * into corresponding fields of t_inv_hdr
from bsak
where bukrs = p_bukrs
and lifnr in s_lifnr
and belnr in s_belnr
and blart in s_blart
and gjahr = p_gjahr
and monat in s_monat
and budat in s_budat
and bldat in s_bldat
and cpudt in s_cpudt
and ( blart = 'IA' or blart = 'IB' or blart = 'IC' or blart = 'ID' ).
t_inv_hdr-gst_no = l_gst_no.
t_inv_hdr-reg_no = l_reg_no.
t_inv_hdr-hwaer = g_company-waers.
append t_inv_hdr.
endselect.
endif.
loop at t_inv_hdr.
if it is cusomer
if p_inter eq ''.
if t_inv_hdr-bschl = '11'. "Credit note
t_inv_hdr-inv_type = 'CREDIT NOTE'.
else.
t_inv_hdr-inv_type = 'TAX INVOICE'.
endif.
select * into corresponding fields of t_inv_item
from bseg
where bukrs = t_inv_hdr-bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr
and buzid eq '' .
if t_inv_hdr-inv_type = 'TAX INVOICE'.
if t_inv_item-shkzg = 'S'.
t_inv_item-wrbtr = 0 - t_inv_item-wrbtr.
t_inv_item-dmbtr = 0 - t_inv_item-dmbtr.
endif.
else.
if t_inv_item-shkzg = 'H'.
t_inv_item-wrbtr = 0 - t_inv_item-wrbtr.
t_inv_item-dmbtr = 0 - t_inv_item-dmbtr.
endif.
endif.
append t_inv_item.
endselect.
if it is vendor
else.
if t_inv_hdr-bschl = '31'. "Credit note
t_inv_hdr-inv_type = 'CREDIT NOTE'.
else.
t_inv_hdr-inv_type = 'TAX INVOICE'.
endif.
select * into corresponding fields of t_inv_item
from bseg
where bukrs = t_inv_hdr-bukrs
and belnr = t_inv_hdr-belnr
and gjahr = t_inv_hdr-gjahr
and buzid eq '' .
if t_inv_hdr-inv_type = 'TAX INVOICE'.
if t_inv_item-shkzg = 'S'.
t_inv_item-wrbtr = 0 - t_inv_item-wrbtr.
t_inv_item-dmbtr = 0 - t_inv_item-dmbtr.
endif.
else.
if t_inv_item-shkzg = 'H'.
t_inv_item-wrbtr = 0 - t_inv_item-wrbtr.
t_inv_item-dmbtr = 0 - t_inv_item-dmbtr.
endif.
endif.
append t_inv_item.
endselect.
endif.
endloop.
endform. "read_customer_invoices
‎2006 Aug 24 5:00 AM
hi
good
if you r printing under if loop than check the loop how many time it is going to that printing point,if you find out that it is printing two time than clear that variable after the if statement so that second time it owuld not contain any value.
thanks
mrutyun