‎2008 May 14 3:08 PM
HI all,
can anyone tel me how to call a subroutine inside a script..
i have an internal table itab with a feild NETPR.. i want to add all the values in ITAB-NETPR to get my net amount.... so please help me....
please...
‎2008 May 14 3:44 PM
‎2008 May 14 3:14 PM
/:PERFORM get_date IN PROGRAM zreport
/:USING &SALESORDER&
/:CHANGING &S_DATE&
/:ENDPERFORM
The date &S_DATE& ....
The ABAP Code would be
REPORT zreport.
TABLES ztab.
FORM get_date TABLES in_tab STRUCTURE ITCSY out_tab
STRUCTURE ITCSY .
READ TABLE in_tab INDEX 1.
SELECT some_date FROM ztab WHERE salesorder = in_tab-value.
IF sy-subrc EQ 0.
READ TABLE out-tab INDEX 1.
MOVE ztab-somedate TO out_tab-value
MODIFY out_tab INDEX 1.
ENDIF.
ENDFORM.
In the above code USING is used to pass the value to the
subroutine while changing is used to recieve the value from th
subroutine ,for further paramters we can use either USING or
CHANGING .
In the subroutine the type of paramter is always an internal table of
type ITCSY irrespective of the value passed.The VALUE field
of the internal table is used to fill and recieve the values .
‎2008 May 14 3:16 PM
In the script
/: PERFORM MY_FORM IN PROGRAM ZPROGRAM
/: USING &ADRC-NAME1&
/: USING &ADRC-NAME2&
/: CHANGING &NAME50&
/: ENDPERFORM.
and in the program
FORM my_form TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy .
ENDFORM.
You have all the "using" parameters in in_tab and you change all "changing" parameters in out_tab
‎2008 May 14 3:24 PM
/:PERFORM CALCULATE IN PROGRAM Z007POSTSCRIPT
/:USING &I_ZEKPO_GROUP20-NETPR&
/:CHANGING TOTAL
/:ENDPERFORM
where total is the variable into which i would like to get my summed amount...
but in getting an error....
‎2008 May 14 3:27 PM
Total needs to be a text element.
Before calling the form put a define
/: DEFINE &TOTAL&
‎2008 May 14 3:32 PM
can u please tell me the code to be written in the FORM:
im getting an error stating too many parameters passed,but the no of formal parameter is 0.
‎2008 May 14 3:34 PM
FORM CALCULATE TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy .
LOOP AT in_tab .
TOTAL = TOTAL + I_ZEKPO_GROUP20-NETPR
ENDLOOP.
ENDFORM.
i gave this code..... can u please correct it....
‎2008 May 14 3:43 PM
What are you trying to do?
The "using" parameters in the sapscript are passed to the form in in_tab and the "changing" parameters are passed to the sapscript in out_tab.
You access to them with read and modify
It looks like you are trying to loop at table I_ZEKPO_GROUP20 and have the total of all netpr, Is that right?
If yes, a perfom is not the answer, you need to calculate the total in your printing program before calling function "WRITE_FORM"
‎2008 May 14 3:44 PM
‎2008 May 14 3:48 PM
Dude don't panic...
You can't do it with a soubroutine.
In the calling program do this.
data: g_total like I_ZEKPO_GROUP20-NETPR.
loop at I_ZEKPO_GROUP20.
g_total = I_ZEKPO_GROUP20-NETPR + g_total.
endloop.
Then put &G_TOTAL& in your sapscript and the total should appear.
The code should be placed before the call to the sapscript and g_total should be global.
‎2008 May 14 3:48 PM
ALL i need is to sum my NETPR feild and get the total on the script output..
‎2008 May 14 3:55 PM
thanx my friend.... u really solved my probs.....
thanx once again..