2007 Oct 15 8:08 AM
Hi,
I have a form printing an invoice having
1) VAT amount (A)
2)Total invoice amount including VAT (B)
I want to add one more field to it, which will also print the amount without VAT (C).
I.e. c = b - a.
how can i do that in the FORM or my print program ? If i create a local variable in the print program and populate it, how do i call that from the FORM ? Please help.
Thanks & Regards
Hrishi
2007 Oct 15 8:20 AM
write a perform routine in the SAPScript where you need to pass the following:
define: &w_vatc& := &w_vata&.
perform sub_calculate_valtc in program zprog_script
using &w_vata&
&w_vatb&
changing &w_vatc&
endperform.
and in the perform routine in the Zprogram do the relavent calculations
Hope That Helps
Anirban M.
2007 Oct 15 8:20 AM
write a perform routine in the SAPScript where you need to pass the following:
define: &w_vatc& := &w_vata&.
perform sub_calculate_valtc in program zprog_script
using &w_vata&
&w_vatb&
changing &w_vatc&
endperform.
and in the perform routine in the Zprogram do the relavent calculations
Hope That Helps
Anirban M.
2007 Oct 15 9:02 AM
2007 Oct 15 10:07 AM
Here is the program::
*&---------------------------------------------------------------------*
*& Report ZTEST_PRG3
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report ztest_prg3.
*WRITE: 'This is the Submitted Program'.
data: w_lgort type lgort_d,
w_werks type werks_d.
parameters: p_matnr type matnr obligatory.
select single lgort werks from mard
into (w_lgort, w_werks)
where matnr = p_matnr.
check sy-subrc = 0.
call function 'OPEN_FORM'
exporting
application = 'TX'
device = 'PRINTER'
form = 'ZZTEST_FORM1'
language = sy-langu
* 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.
call function 'WRITE_FORM'
exporting
element = 'ADDR'
function = 'SET'
type = 'BODY'
window = 'MAIN'
* IMPORTING
* PENDING_LINES =
* 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
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'CLOSE_FORM'
* IMPORTING
* RESULT =
* RDI_RESULT =
* TABLES
* OTFDATA =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SEND_ERROR = 3
* SPOOL_ERROR = 4
* CODEPAGE = 5
* OTHERS = 6
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*&---------------------------------------------------------------------*
*& Form ZTEST_CALC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->INTAB text
* -->OUTTAB text
*----------------------------------------------------------------------*
form ztest_calc tables intab structure itcsy
outtab structure itcsy.
data: w_werks type werks_d,
w_lgort type lgort_d,
w_lgobe type lgobe.
** READ THE INTAB.
read table intab with key name = 'W_WERKS'.
if sy-subrc = 0.
w_werks = intab-value.
read table intab with key name = 'W_LGORT'.
if sy-subrc = 0.
w_lgort = intab-value.
select single lgobe from t001l into w_lgobe
where werks = w_werks
and lgort = w_lgort.
if sy-subrc = 0.
outtab-value = w_lgobe.
modify outtab index 1 transporting value.
endif.
endif.
endif.
endform. "ZTEST_CALCand here is what i wroye inside the Form routine:
DEFINE &W_LGOBE& = &MARD-LGOBE&.
BOX WIDTH '17.5' CM HEIGHT '10' CM FRAME 10 TW INTENSITY 15
PERFORM ZTEST_CALC IN PROGRAM ZTEST_PRG3
USING &W_WERKS&
USING &W_LGORT&
CHANGING &W_LGOBE&
ENDPERFORM.
&W_LGOBE&Hope That Helps
Anirban M.
2007 Oct 16 1:40 AM
Thanks Anirban,
this is what i have written in print prog.
form cal tables intab structure itcsy
outtab structure itcsy.
data: EXCL_VAT type KOMK-FKWRT.
data: w_fkwrt type komk-fkwrt.
data: w_kwert type KOMVD-KWERT.
READ THE INTAB.
read table intab with key name = 'KOMVD-KWERT'.
if sy-subrc = 0.
w_kwert = intab-value.
read table intab with key name = 'komk-fkwrt'.
if sy-subrc = 0.
w_fkwrt = intab-value.
EXCL_VAT = W_FKWRT - W_KWERT.
outtab-value = EXCL_VAT.
modify outtab index 1 transporting value.
endif.
endif.
endform.
and this is what i have written in form.
DEFINE &EXCL_VAT& = &KOMK-FKWRT&
PERFORM CAL IN PROGRAM ZSDARVADIN01
USING &KOMVD-KWERT&
USING &KOMK-FKWRT&
CHANGING &EXCL_VAT&
ENDFORM
AMOUNT EXLUSIVE VAT,, &EXCL_VAT&
this does not work ! it prints komk-fkwrt as excl_vat.
i need excl_vat as EXCL_VAT = W_FKWRT - W_KWERT.
Pls help. Thanks in advance
Regards
Hrishi
2007 Oct 16 6:50 AM
Please do the small change:
DEFINE &EXCL_VAT& := &KOMK-FKWRTHope That Helps
Anirban M.
2007 Oct 16 8:32 AM
Hi Anirban,
It still doesnt work. now, Its not printing anything at all. I could find what the problem is. In this code :
40 EXCL_VAT = komk-fkwrt - komvd-kwert.
41 READ TABLE outtab INDEX 1.
42 outtab-value = EXCL_VAT.
43 MODIFY outtab INDEX 1.
endform.
If i debug, excl_vat will have the correct value.
But outtab-value will have prev. routine return value till line 42. After line 42 it will go blank.
What can be the reason that it is not copying the value of excl_vat ??
Please help.
Thanks a lot
Hrishi
2007 Oct 16 8:37 AM
The reason is quite simple:
EXCL_VAT is a quantity field and the value field in ITCSY is a Character field, ( sooory i mssed it last time..) so please change in the following manner.
write EXCL_VAT to outtab-value.
condense outtab-value. Hope That Helps
Anirban M.
2007 Oct 17 11:52 PM
You are the MAN !!!!! 10/10.. problem solved !
Thanks Anirban !
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |