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: 
3 REPLIES 3
Read only

Former Member
0 Likes
537

Hi

Its an Abap prog of type sub routine pool, it is used for calculating certain variables, eg DUE date for an Invoice. You pass the values from the form thru ITCSY structure inthe prgram.

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.

Read only

Former Member
0 Likes
537

Hi,

We use Sub Routine Pool (Program) in Scripts when there is a requirement to extend the functionality of the Standard Print Program. ie., When the existing Print Program does not give you the desired output and you have included some new code in the ZForm, then we write the code in the Sub Routine Pool program in SE38.

From Forms--> Text Editor, we use the following stmt to call the Sub Routine code.

PERFORM Calculate_amount IN PROGRAM Z_SR_FRM001

USING &VAR1&

CHANGING &VAR2&.

(Z_SR_FRM001 is the name of the Sub Routine Pool Program we write in SE38)

In the SE38 Editor, we code as following :

&----


*& Form CALCULATE_AMOUNT

&----


  • text

----


  • --> VAR1 text

  • <-- VAR2 text

----


FORM calculate_amount TABLES in_tab STRUCTURE

itcsy out_tab STRUCTURE itcsy.

...

...

...

ENDFORM.

You have to write the required code in the above Form in order to get the desired result.

Reward if helpful.

Best Regards.