2007 Aug 29 7:14 AM
hai all
i write the program its script. i create the Z-Table also for it name"zvoucher" ... normally that program execute we can see the print window...now i can print form and print preview... i want to print only one time in each document number. plz tel me how should i do it.... ???? AND how should i recognized "print command "and "print preview " command?
my program is below.
*&----
*
*& Report ZFORM1
*&
*&----
*
*&
*&
*&----
*
report zform1_p.
*PARAMETERS:P_VBLNR LIKE REGUH-VBLNR.
*PARAMETERS:Payment Document No LIKE REGUH-VBLNR.
tables: reguh,
regup,
bseg,
skat,
payr,
zvoucher. " ztable
parameters : p_vblnr like reguh-vblnr obligatory.
parameters : p_gjahr like bseg-gjahr obligatory.
parameters : p_bukrs like bseg-bukrs default 'EPFD'.
parameters : p_fil type payr-zanre.
parameters : p_bud type payr-zanre.
data: z_vblnr like reguh-vblnr.
z_vblnr = p_vblnr.
data n1 type i.
data scarr_wa type zvoucher.
data :w_anum like zvoucher-anum,
w_anum_n like zvoucher-anum,
w_val like zvoucher-anum.
*DATA: CRAMT TYPE P DECIMALS 2,
DRAMT TYPE P DECIMALS 2,
TOTCR TYPE P DECIMALS 2,
TMP_WORDS TYPE STRING,
TOTDR TYPE P DECIMALS 2.
data: cramt like bseg-dmbtr,
dramt like bseg-dmbtr,
totcr like bseg-dmbtr,
tmp_words type string,
totdr like bseg-dmbtr.
data: somme type p.
data: i_tab like reguh occurs 0 with header line.
data: i_tab1 like payr occurs 0 with header line.
data: i_tab2 like bseg occurs 0 with header line.
data: i_tab3 like skat occurs 0 with header line.
data: i_tab4 like regup occurs 0 with header line.
data: i_inwords like spell occurs 0 with header line.
types :begin of ty_tab,
anum like zvoucher-anum,
pr like zvoucher-pr,
vblnr like zvoucher-vblnr,
gjahr like zvoucher-gjahr,
end of ty_tab.
data : it_tab type standard table of ty_tab,
wa_tab type ty_tab.
select * from reguh where vblnr = p_vblnr.
move-corresponding reguh to i_tab.
append i_tab.
endselect.
select * from payr where vblnr = p_vblnr
and gjahr = p_gjahr.
move-corresponding payr to i_tab1.
append i_tab1.
endselect.
select * from bseg where belnr = p_vblnr
and gjahr = p_gjahr.
move-corresponding bseg to i_tab2.
append i_tab2.
endselect.
select * from regup where vblnr = p_vblnr
and gjahr = p_gjahr.
move-corresponding regup to i_tab4.
append i_tab4.
endselect.
Début d'impression du formulaire
call function 'OPEN_FORM'
exporting
form = 'ZPAY_VOUCHER_P'
device = 'PRINTER'.
call function 'START_FORM'.
*CALL FUNCTION 'WRITE_FORM'
*EXPORTING
*window = 'HEADER'.
Impression de l'élément de texte ITEM_HEADER de la fenêre MAIN
call function 'WRITE_FORM'
exporting
element = 'ITEM_HEADER'
window = 'MAIN'.
loop at i_tab.
p_vblnr = i_tab.
read table i_tab1 with key vblnr = p_vblnr.
dramt = 0.
cramt = 0.
totdr = 0.
totcr = 0.
loop at i_tab2.
bseg = i_tab2.
somme = 0.
select * from skat where saknr = i_tab2-hkont.
move-corresponding skat to i_tab3.
append i_tab3.
endselect.
if bseg-bschl = '25'.
dramt = bseg-dmbtr.
totdr = totdr + dramt.
cramt = 0.
endif.
if bseg-bschl = '50'.
cramt = bseg-dmbtr.
totcr = totcr + cramt.
dramt = 0.
endif.
read table i_tab3 with key saknr = i_tab2-hkont.
**Insert Data Into the ZTABLE.
select single anum from zvoucher into w_val
where vblnr = z_vblnr.
scarr_wa-anum = w_val.
if w_val = ''.
select max( anum ) from zvoucher into w_anum.
WHERE VBLNR = ZVOUCHER-VBLNR.
AND GJAHR = ZVOUCHER-GJAHR .
w_anum_n = w_anum + 1.
UPDATE ZVOUCHER CLIENT SPECIFIED
SET PR = 'X'.
scarr_wa-anum = w_anum_n.
scarr_wa-vblnr = i_tab-vblnr.
scarr_wa-gjahr = i_tab2-gjahr.
scarr_wa-PR = 'X'.
insert into zvoucher values scarr_wa.
endif.
Impression de l'élément de texte ITEM_LINE de la fenêtre MAIN
call function 'WRITE_FORM'
exporting
element = 'ITEM_DETAIL1'
function = 'APPEND'
window = 'MAIN'.
endloop.
call function 'WRITE_FORM'
exporting
element = 'TOTAL_1'
window = 'MAIN'.
endloop.
call function 'WRITE_FORM'
exporting
element = 'ITEM_HEADER1'
window = 'MAIN'.
Print Invoice Detail
dramt = 0.
cramt = 0.
totdr = 0.
totcr = 0.
loop at i_tab4.
regup = i_tab4.
somme = 0.
clear i_tab2[].
select * from bseg where belnr = i_tab4-belnr.
move-corresponding bseg to i_tab2.
append i_tab2.
endselect.
loop at i_tab2.
bseg = i_tab2.
somme = 0.
clear i_tab3[].
select * from skat where saknr = i_tab2-hkont.
move-corresponding skat to i_tab3.
append i_tab3.
endselect.
read table i_tab3 with key saknr = i_tab2-hkont.
if bseg-bschl = '40'.
dramt = bseg-dmbtr.
totdr = totdr + dramt.
cramt = 0.
endif.
if bseg-bschl = '31'.
cramt = bseg-dmbtr.
totcr = totcr + cramt.
dramt = 0.
endif.
Impression de l'élément de texte ITEM_LINE de la fenêtre MAIN
call function 'WRITE_FORM'
exporting
element = 'ITEM_DETAIL2'
function = 'APPEND'
window = 'MAIN'.
endloop.
endloop.
call function 'WRITE_FORM'
exporting
element = 'TOTAL_2'
window = 'MAIN'.
Convert Total Amount into words
call function 'SPELL_AMOUNT'
exporting
amount = totcr
currency = 'LKR '
FILLER = ' '
language = sy-langu
importing
in_words = i_inwords
exceptions
not_found = 1
too_large = 2
others = 3 .
if i_inwords-decword = 'ZERO'.
concatenate i_inwords-word 'Only' into tmp_words
separated by space.
else.
concatenate i_inwords-word 'AND CENTS' i_inwords-decword 'ONLY' into
tmp_words separated by space.
endif.
Impression de l'élément de texte ITEM_END de la fenêtre MAIN
call function 'WRITE_FORM'
exporting
element = 'ITEM_END'
window = 'MAIN'.
call function 'END_FORM'.
call function 'CLOSE_FORM'.
regard
nawa
in your z table add one more field as flag... whenever particular sap script is called you make this flag as 'X'.
Or may be after printing you can give pop-up to user asking whether print was successful.. if user presses yes then update this flag as 'X'.
and for all entries having this flag set.. you can deny print permission.
2007 Aug 29 9:26 AM
in your z table add one more field as flag... whenever particular sap script is called you make this flag as 'X'.
Or may be after printing you can give pop-up to user asking whether print was successful.. if user presses yes then update this flag as 'X'.
and for all entries having this flag set.. you can deny print permission.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |