2008 Nov 17 5:52 AM
Hi frnds,
How to call a smartform from the transaction J1IP.
I have created a zsmartform now i want o attach it to J1IP tcode.
Regads,
Renga
Hi frnds,
How to call a smartform from the transaction J1IP.
I have created a zsmartform now i want o attach it to J1IP tcode.
Regads,
Renga
2008 Nov 17 5:58 AM
Hi,
First create output type(using standard output type j1i0) , procedure and access sequence using nace.
Here in nace goto v3 for billing....in it modify the standard by entering your smartform.
In output type you have to give your zsmartform in the processing routines.
Regards
Debarshi
2008 Nov 17 5:59 AM
Hello,
call smartform in report we will use this Function module 'SSF_FUNCTION_MODULE_NAME'.
but ur question is not clear to me.
thank u
santhosh
2008 Nov 17 5:59 AM
2008 Nov 17 9:00 AM
Create an executable program in SE38 (Print Program).
In NACE transaction select application type V3 and go to output types.
Select output type for excise invoice print and double click on processing routines.
Give the smartform name in smartform field.
Give report program name in program field ogf processing1 block.
Use the following code in the print program.
Actually this is copy of standard print program for excise invoice print (J_1IEXCP) with small modifications.
report zcall_sf_from_j1ip line-count 100 message-id 8i.
tables : vbrk,
vbrp,
vbfa,
vbdkr,
t001, t005,
j_1iexcdef,
t001w,
likp,
kuagv,
kuwev,
kna1,
thead.
tables : j_1iexchdr,
j_1iexcdtl,
j_1iwrkcus,
j_1iregset.
include rvadtabl.
data : tvbdpr like vbdpr occurs 100 with header line.
data: begin of tj_1iexcdtl occurs 30.
include structure j_1iexcdtl.
data: end of tj_1iexcdtl.
data: retcode like sy-subrc. "Returncode
data: repeat(1) type c.
data: xscreen(1) type c. "Output on printer or screen
*----
FORM ENTRY
*----
The function that is called for printing the excise invoice
*----
form entry using return_code us_screen.
clear retcode.
xscreen = us_screen.
perform processing using us_screen.
case retcode.
when 0.
return_code = 0.
when 3.
return_code = 3.
when others.
return_code = 1.
endcase.
endform.
*----
FORM PROCESSING
*----
form processing using proc_screen.
data : v_fmname type rs38l_fnam, "Stores Smartforms Function Name
wa_control type ssfctrlop, "Smartform Controls
wa_control1 type ssfcompin,
wa_result type ssfcrescl.
perform get_data.
Returns the Function Module Name of the Given Smartform
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZEXCISE_INV_SF'
importing
fm_name = v_fmname.
lwa_control-no_dialog = 'X'.
lwa_control-no_open = 'X'.
lwa_control-no_close = 'X'.
if sy-ucomm = 'ESCR'.
lwa_control-preview = ''.
lwa_control1-tdpreview = 'X'.
lwa_control1-dialog = ''.
elseif sy-ucomm = 'EPRN'.
lwa_control1-tdimmed = 'X'.
endif.
call function 'SSF_OPEN'
exporting
input = wa_control1
exceptions
error = 1
others = 2.
if sy-subrc <> 0.
exit.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
call function lv_fmname
exporting
control_parameters = wa_control
gv_exnum = j_1iexchdr-exnum
gv_exyear = j_1iexchdr-docyr
exceptions
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
retcode = 0.
endif.
Closes the smartform
call function 'SSF_CLOSE'
importing
result = wa_result.
endform.
*----
FORM CHECK_REPEAT
*----
A text is printed, if it is a repeat print for the document.
*----
form check_repeat.
clear repeat.
select * into *nast from nast where kappl = nast-kappl
and objky = nast-objky
and kschl = nast-kschl
and spras = nast-spras
and parnr = nast-parnr
and parvw = nast-parvw
and nacha between '1' and '4'.
check *nast-vstat = '1'.
repeat = 'X'.
exit.
endselect.
endform.
*----
FORM END_PRINT
*----
Print the part2 entry number
*----
form end_print.
call function 'WRITE_FORM'
exporting
element = 'SERIAL_NO_HDR'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
print the RG23A/C part 2 and PLA entry number
call function 'WRITE_FORM'
exporting
element = 'SRNOS'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
endform.
*----
FORM FORM_CLOSE
*----
End of printing the form
*----
form form_close.
call function 'CLOSE_FORM'
exceptions
others = 1.
if sy-subrc ne 0.
retcode = sy-subrc.
perform protocol_update.
endif.
set country space.
endform.
*----
FORM FORM_OPEN
*----
Start of printing the form
*----
form form_open using us_screen us_country.
include rvadopfo.
endform.
*----
FORM FORM_TITLE_PRINT
*----
Printing of the form title depending of the field VBTYP
*----
form form_title_print.
call function 'WRITE_FORM'
exporting
element = 'EXCISE_INV'
window = 'TITLE'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
print the export type if applicable
case j_1iexchdr-expind.
when 'D'.
call function 'WRITE_FORM'
exporting
element = 'DEEMED_EXP'
window = 'TITLE'
function = 'APPEND'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
when 'B'.
call function 'WRITE_FORM'
exporting
element = 'EXP_BOND'
window = 'TITLE'
function = 'APPEND'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
when 'N'.
call function 'WRITE_FORM'
exporting
element = 'EXP_NOBOND'
window = 'TITLE'
function = 'APPEND'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
endcase.
print REPRINT if already printed
if repeat <> space.
call function 'WRITE_FORM'
exporting
element = 'REPEAT'
window = 'TITLE'
function = 'APPEND'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
endif.
endform.
*----
FORM GET_DATA
*----
General provision of data for the form
*----
form get_data.
perform get_delivery_info.
perform get_excise_invoice.
check retcode = 0.
perform get_sending_plant.
perform check_repeat.
perform get_excise_details.
check retcode = 0.
endform.
*----
FORM ITEM_PRINT
*----
Printout of the items
*----
form item_print.
call function 'WRITE_FORM'
exporting
element = 'DASH_LINE'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
header line
call function 'WRITE_FORM'
exporting
element = 'ITEM_HEADER'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
call function 'WRITE_FORM'
exporting
element = 'DASH_LINE'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
sort tj_1iexcdtl by zeile.
loop at tj_1iexcdtl into j_1iexcdtl.
write the item details
call function 'WRITE_FORM'
exporting
element = 'ITEM_VALUES'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
endloop.
call function 'WRITE_FORM'
exporting
element = 'DASH_LINE'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
call function 'WRITE_FORM'
exporting
element = 'TOTALS'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
call function 'WRITE_FORM'
exporting
element = 'DASH_LINE'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
call function 'WRITE_FORM'
exporting
element = 'SPACE_LINE'
exceptions
others = 1.
if sy-subrc ne 0.
perform protocol_update.
endif.
endform.
*----
FORM PROTOCOL_UPDATE
*----
The messages are collected for the processing protocol.
*----
form protocol_update.
check xscreen = space.
call function 'NAST_PROTOCOL_UPDATE'
exporting
msg_arbgb = syst-msgid
msg_nr = syst-msgno
msg_ty = syst-msgty
msg_v1 = syst-msgv1
msg_v2 = syst-msgv2
msg_v3 = syst-msgv3
msg_v4 = syst-msgv4
exceptions
others = 1.
endform.
*----
FORM GET_SENDING_PLANT
*----
This routine determines the address of the plant from where
excise invoice is printed
*----
form get_sending_plant.
clear: t001w,j_1iwrkcus,j_1iregset.
select single * from t001w
where werks = j_1iexchdr-werks.
select single * from j_1iwrkcus
where j_1iwerks = j_1iexchdr-werks.
if sy-subrc <> 0.
plant cutomisation not found
syst-msgid = '8I'.
syst-msgno = 303.
syst-msgty = 'E'.
clear: syst-msgv4.
syst-msgv1 = 'plant'.
syst-msgv2 = j_1iexchdr-werks.
syst-msgv3 = 'J_1IWRKCUS'.
perform protocol_update.
retcode = 4.
exit.
endif.
select single * from j_1iregset
where j_1iregid = j_1iwrkcus-j_1iregid.
if sy-subrc <> 0.
register id cutomisation not found
syst-msgid = '8I'.
syst-msgno = 303.
syst-msgty = 'E'.
clear: syst-msgv4.
syst-msgv1 = 'register id'.
syst-msgv2 = j_1iwrkcus-j_1iregid.
syst-msgv3 = 'J_1IREGSET'.
perform protocol_update.
retcode = 4.
endif.
endform.
*----
Form GET_EXCISE_DETAILS
*----
Get the excise details
*----
form get_excise_details.
data: kawrt like komv-kawrt.
select * from j_1iexcdtl into table tj_1iexcdtl
where trntyp = j_1iexchdr-trntyp
and docyr = j_1iexchdr-docyr
and docno = j_1iexchdr-docno.
select single * from t001 where bukrs = j_1iexchdr-bukrs.
select single * from t005 where land1 = t001-land1.
select single * from j_1iexcdef where j_1itaxcal = t005-kalsm.
loop at tj_1iexcdtl into tj_1iexcdtl.
if tj_1iexcdtl-exbed is initial and j_1iexchdr-expind = 'D'.
kawrt = tj_1iexcdtl-exbas.
call function 'J_1I6_DETERMINE_EXCISE_RATE'
exporting
bukrs = j_1iexchdr-bukrs
werks = j_1iexchdr-werks
matnr = tj_1iexcdtl-matnr
vendor = j_1iexchdr-kunag
kalsm = t005-kalsm
mwskz = j_1iexcdef-j_1itxcode
tax_date = sy-datum
menge = tj_1iexcdtl-menge
kawrt = kawrt
unit = tj_1iexcdtl-meins
importing
exc_amount = tj_1iexcdtl-exbed
exc_perc = tj_1iexcdtl-bedrate
add_amount = tj_1iexcdtl-exaed
add_perc = tj_1iexcdtl-aedrate
sed_amount = tj_1iexcdtl-exsed
sed_perc = tj_1iexcdtl-sedrate
exceptions
chapter_id_missing = 1
company_data_not_setup = 2
tax_proc_invalid = 3
excind_missing = 4
vendor_missing = 5
taxcode_invalid = 6
excise_rate_missing = 7
others = 8.
endif.
if sy-subrc eq 0.
modify tj_1iexcdtl.
endif.
endloop.
endform. " GET_EXCISE_DETAILS
*----
Form GET_EXCISE_INVOICE
*----
get the excise invoice number
*----
form get_excise_invoice.
get the excise invoice for the refrence document
select single * from j_1iexchdr
where trntyp = 'DLFC'
and rdoc = nast-objky(10)
and rind = 'N'
and status = 'C'.
if sy-subrc <> 0.
excise invoice not found
syst-msgid = '8I'.
syst-msgno = 301.
syst-msgty = 'E'.
clear : syst-msgv1,
syst-msgv2,
syst-msgv3,
syst-msgv4.
perform protocol_update.
retcode = 4.
endif.
clear: kuagv, kuwev.
get the ship-to-party
select single * from kna1 into corresponding fields of kuwev
where kunnr = j_1iexchdr-kunwe.
get the sold-to-party
if j_1iexchdr-kunag is initial
or j_1iexchdr-kunag = j_1iexchdr-kunwe.
kuagv = kuwev.
else.
select single * from kna1 into corresponding fields of kuagv
where kunnr = j_1iexchdr-kunag.
endif.
endform. " GET_EXCISE_INVOICE
*----
Form CUSTOMER_ADDRESS_PRINT
*----
Print the customer address
*----
form customer_address_print.
call function 'WRITE_FORM'
exporting
element = 'ADDRESSEE'
window = 'ADDRESS'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
endform. " CUSTOMER_ADDRESS_PRINT
*----
FORM HEADER_DATA_PRINT
*----
form header_data_print.
call function 'WRITE_FORM'
exporting
element = 'HEADER_DATA'
window = 'INFO'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
endform. " HEADER_DATA_PRINT
*----
Form GET_DELIVERY_INFO
*----
Read the delivery information
*----
form get_delivery_info.
clear thead.
thead-tdobject = 'J1II'.
concatenate sy-mandt nast-objky(10) into thead-tdname.
thead-tdspras = sy-langu.
vbdkr-land1 = 'IN'.
clear : vbrk, vbrp, vbfa, likp.
read refrence document header type
select single vbeln vbtyp
from vbrk
into (vbrk-vbeln,vbrk-vbtyp)
where vbeln = nast-objky(10).
read a refrence document item
select single posnr vgbel
from vbrp
into (vbrp-posnr,vbrp-vgbel)
where vbeln = vbrk-vbeln
and vgtyp = 'J'.
get the delivery number
select single *
from vbfa
where vbelv = vbrp-vgbel
and vbeln = vbrk-vbeln
and posnn = vbrp-posnr
and vbtyp_n = vbrk-vbtyp
and vbtyp_v = 'J'.
if sy-subrc = 0.
read the delivery header
select single * from likp
where vbeln = vbfa-vbelv.
endif.
if sy-subrc <> 0.
delivery not found
syst-msgid = '8I'.
syst-msgno = 301.
syst-msgty = 'E'.
clear : syst-msgv1,
syst-msgv2,
syst-msgv3,
syst-msgv4.
perform protocol_update.
retcode = 4.
endif.
endform. " GET_DELIVERY_INFO
*----
FORM TEXT_BEFORE_ITEM_PRINT
*----
Print the header text before the items are printed
*----
form text_before_item_print.
call function 'WRITE_FORM'
exporting
element = 'HEADER_TEXT_BEFORE_ITEMS'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
endform. " TEXT_BEFORE_ITEM_PRINT
*----
FORM TEXT_AFTER_ITEM_PRINT
*----
Print the header text before the items are printed
*----
form text_after_item_print.
call function 'WRITE_FORM'
exporting
element = 'HEADER_TEXT_AFTER_ITEMS'
exceptions
element = 1
window = 2.
if sy-subrc ne 0.
perform protocol_update.
endif.
endform. " TEXT_AFTER_ITEM_PRINT
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |