01-14-2007 9:21 AM
Hi Friends, In Sapscript, I want to print as follows. Please help.
Empno Name Dept. Salary
A1 AAAA DP01 1000.00
A2 BBBB DP01 1500.00
-
2500.00
A3 CCCC DP02 2000.00
A4 DDDD DP02 2200.00
-
4200.00
01-14-2007 9:36 AM
Hi
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.
PLZ REWARD POINTS
01-14-2007 9:36 AM
Hi
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.
PLZ REWARD POINTS
01-14-2007 9:37 AM
Dept. Empno Name Salary
Rearrange the fields in the above mentioned way:
Now you can:
LOOP AT ITAB.
call function 'EDIT_FORM'.
AT END OF DEPT.
sum.
call function 'EDIT_FORM'
ENDAT.
ENDLOOP.
01-14-2007 9:40 AM
Hi
While you loading the main internal table, yuo can load a new one witn DEPT and SALARY fields only:
ITAB-EMPNO = 'A1'.
ITAB-NAME = 'AAAA'.
ITAB-DEPT = 'DP01'.
ITAB-SALARY = 1000.
APPEND ITAB.
TOT-DEPT = 'DP01'.
TOT-SALARY = 1000.
COLLECT TOT.
So:
SORT ITAB BY DEPT EMPNO NAME.
LOOP AT ITAB.
CALL WRITE_FORM
..............................
AT END OF DEPT.
READ TABLE TOT WITH KEY DEPT = ITAB-DEPT.
CALL WRITE_FORM
..............................
ENDAT.
ENDLOOP.
Here I use AT END statament, but in this sistuation it can be used only if DEPT is the first field:
DATA BEGIN OF ITAB OCCURS,
DEPT ....
If it isn't a first field you can use a variable to check if the value of DEPT is changing and so print the subtotal.
Max
01-23-2007 11:35 AM
01-23-2007 11:49 AM
Hi HARIKRISHNAN,
you may look at print program RVADOR01, form FORM ITEM_PRINT and sapscript form RVORDER01:
In Main Window, element ITEM_HEADER could be used for "Empno Name Dept. Salary", ITEM_LINE for "A1 AAAA DP01 1000.00" and ITEM_SUM for the underline and the sum.
You will trigger the elements using FM WRITE_FORM.
The other hints have been given.
Regards,
Clemens