2007 Mar 15 9:35 AM
Hi frnds,
i ahav an issue in getting the subtotals in SAP scripts.
i need it to be printed as suppose thr are 6 items in first page then i need the subtotal of only 6 then in second page suppose thr are 3 items then i need subtotal for only 3 items in second page.
But its printing always total.
plzz guide me regarding this frnd.
regards,
sanjay
2007 Mar 15 9:52 AM
Hi,
You can use the following stmt for sub totals.
<b>SUMMING &FS_PROG-SALARY& INTO &W_SUM&</b>
and place w_sum where it is required.
Regards,
Sandhya
2007 Mar 15 9:40 AM
Because we use the AT END OF control break statement for the subtotals, it is not possible for us to have the requirement fulfilled. Instead you can use the PROTECT...ENDPROTECT control command for the items in the script and get the items displayed always on a single page with the subtotal.
2007 Mar 15 9:42 AM
Hello Sanjay,
SAPscripts How to calculate Totals and Subtotals
I have some doubs in BDC and SMART FORMS. I want to change the material number using the transaction code MM02 through BDC.
In scripts and smartforms how to calculate totals and subtotals?
To calculate totals and sub totals in sap scripts you have to use subroutines.
Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine
/: DEFINE &TOT_PRICE&
/: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT& /:CHANGING &TOT_PRICE& /:ENDPERFORM
Then write the variable where ever you want it to be printed (mostly it will be in footer window)
Then create subroutine pool program and you have to write the code.
FORM F_GET_PRICE tables int_cond structure itcsy
outt_cond structure itcsy. data : value type kbert.
statics value1 type kbert.
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
I have given a rough outline, please be aware of the variable conversions as Int_cond-value and outt_cond-value are characters.
If useful reward.
Vasanth
2007 Mar 15 9:52 AM
Hi,
You can use the following stmt for sub totals.
<b>SUMMING &FS_PROG-SALARY& INTO &W_SUM&</b>
and place w_sum where it is required.
Regards,
Sandhya
2007 Mar 15 10:09 AM
Hi
this is the report program.
*"Table declarations...................................................
tables:
yash_programmer. " Details of Programmers at Yash
"----
Type declaration of the structure to hold Employee details *
"----
data:
begin of fs_empl,
pname type yash_programmer-pname, " Employee Name
dob type yash_programmer-dob, " Date of Birth
doj type yash_programmer-doj, " Date of Join
salary type yash_programmer-salary," Salary Data Element
currencykey type yash_programmer-currencykey,
end of fs_empl.
"----
Internal table to hold Employee details *
"----
data:
t_empl like standard table
of fs_empl.
*" Data declarations...................................................
"----
Work variables *
"----
data:
w_pname like yash_programmer-pname,
w_dob like yash_programmer-dob,
w_doj like yash_programmer-doj,
w_salary like yash_programmer-salary,
w_currencykey like yash_programmer-currencykey,
w_total type i,
w_lines type i,
w_count type i,
w_count1 type i.
select pname
dob
doj
salary
currencykey
from yash_programmer
into table t_empl.
if sy-subrc ne 0.
write: 'records not found'.
endif. " IF SY-SUBRC...
call function 'OPEN_FORM'
exporting
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
form = 'YH645_060103'
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.
describe table t_empl lines w_lines.
loop at t_empl into fs_empl.
w_pname = fs_empl-pname.
w_dob = fs_empl-dob.
w_doj = fs_empl-doj.
w_salary = fs_empl-salary.
w_currencykey = fs_empl-currencykey.
if w_count = 5 and w_lines gt sy-tabix.
w_count = 0.
call function 'CONTROL_FORM'
exporting
command = 'NEW-PAGE'
exceptions
unopened = 1
unstarted = 2
others = 3.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
w_total = w_total + fs_empl-salary.
add 1 to w_count.
add 1 to w_count1.
call function 'WRITE_FORM'
exporting
element = 'ELEMENT'
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.
endloop.
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.
***************************script***************
Screen1:
http://www.esnips.com/doc/6a6aef2c-2e2c-463a-8bc4-23f4d8d556f6/01
Screen2:
http://www.esnips.com/doc/6decbbab-a4b1-4159-be68-94c029c1bc4f/02
Screen3:
http://www.esnips.com/doc/dd404551-688b-4f18-95bd-574b83800b37/03
Screen4:
http://www.esnips.com/doc/ff49a9b0-d0eb-408d-ad5b-83990d4ed0dd/04
2007 Mar 15 10:17 AM
hi,
the sum statement is executed in this way it helps u very much.
Summing a Program Symbol: SUMMING
The SUMMING command is used for accumulating a total value for a program symbol. The command should be specified just once. Then, each time the specified program symbol is formatted, its current value is added into the total symbol. Several program symbols may all be added into a single total symbol.
Syntax:
/: SUMMING program_symbol INTO total_symbol
SAPscript cannot create the field for the total dynamically. The summing symbol used for totalling and the accompanying program symbol(s) must be declared with TABLES in the ABAP program. Otherwise, only zero is added. Declaring the symbol with the DATA statement is not sufficient (global data).
For details on summing and carrying forward, see Summing and Carrying Forward is Incorrect.
when u print program_symbol at the time the sum will be up dated.
u will observe in debugging mode.
when u execute that sum command it will refreshed.
do u required i send an example also if u responded well
Message was edited by:
sunil kumar