cancel
Showing results for 
Search instead for 
Did you mean: 

Why Subroutines in SAP Scripts???????

Former Member
0 Kudos

Hi all,

When i want to display some fields from tables that are not used in "print program" i generally write subroutine which will fetch and display in the form. Now my question is whether we can use function module in place of subroutine? If not why?

Thanks

Rakesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

We can not use the Function module sin teh SCRIPTS directly,

Why sub routines, we can write the ABAP code without changing the print program, SAPSCRIPT allows you to write the SUBROUTINES using a program to write teh ABAP code in that program

Regards

Sudheer

Answers (2)

Answers (2)

former_member196280
Active Contributor
0 Kudos

Let me tell what is the advantage of sub-routine... if your driver program is not in your control(I mean you are using standard print program) then you cannot fetch the values that are not existing in the print program.. to overcome this we call sub-routines inside our form and fetch the data in external program and pass it back to the form...(note: you cannot write Select statement inside form/ call function module inside form) but you can use functions inside your sub-rotines and pass back the value to script..

I guess the concept is clear to you... anyhow for clear picture I am giving sub-routine example...

Ex.

/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>

/:USING &<field name>&

/:CHANGING &<field name1&

/:ENDPERFORM

Then create subroutine pool program and you have to write the code.

FORM ><subroutine name> tables int_cond structure itcsy

outt_cond structure itcsy.

data : value(20), value1(20). "do your own declarations

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.

Just rough idea given above.

Regards,

SaiRam

Former Member
0 Kudos

Hi

You can't use the function modules instead of subroutines in scripts

This facility allows us without modifying the Std driver program of the script we can fetch the external data that is needed from other tables and incorpoarte in the script

<b>Reward points for useful Answers</b>

Regards

Anji