Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SCRIPT plese help.......

Former Member
0 Likes
1,041

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...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,017

PLEASE HELP.............!!!!

11 REPLIES 11
Read only

former_member226999
Contributor
0 Likes
1,017

/: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 .

Read only

Former Member
0 Likes
1,017

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

Read only

Former Member
0 Likes
1,017

/: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....

Read only

0 Likes
1,017

Total needs to be a text element.

Before calling the form put a define


/: DEFINE &TOTAL&

Read only

Former Member
0 Likes
1,017

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.

Read only

Former Member
0 Likes
1,017

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....

Read only

0 Likes
1,017

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"

Read only

Former Member
0 Likes
1,018

PLEASE HELP.............!!!!

Read only

0 Likes
1,017

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.

Read only

Former Member
0 Likes
1,017

ALL i need is to sum my NETPR feild and get the total on the script output..

Read only

Former Member
0 Likes
1,017

thanx my friend.... u really solved my probs.....

thanx once again..