on 02-19-2008 12:55 PM
hi experts,
in scripts, we have a command "perform". so with this we can call a subroutine.
i want to know where we will write the form ...... endform for that subroutine. do we write in driver program? or in script itself?
can anyone plz help me in this aspect. give me the complete details of subroutines in scripts, how to define them, where to define them. give me the clear procedure.
thanks in advance for ur responce.
We can write the FORMS in the driver program or can create a new include itself for them and just mention their name with the PERFORM statement.
Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mytri,
The Sub-Routine pool gives us a option of fetching values inside the SAP Script that needs to be used in the form.
The Correct way of giving the PERFORM (Inside SAP Script) for sub-routine pool is given below:
In the following example i have to fetch the distance and time reading for the Equipment number.
/: PERFORM ODOMETER_READING IN PROGRAM ZPMN2_NOTIFICATION
/: USING &VIQMEL-EQUNR&
/: CHANGING &PV_DISTANCE&
/: CHANGING &PV_TIME&.
/: ENDPERFORM.
Create a sub routine pool in the Se38 with program name ZPMN2_NOTIFICATION.
Inside the Program, give the form as follows.
FORM odometer_reading TABLES in_tab STRUCTURE itcsy out_tab STRUCTURE itcsy.
Here the structure itcsy will have two fields:
1) Name
2) Value
Initially the OUT_TAB Internal table will be filled as shown below: These names are nothing but the variables that has been passed from the scripts.
Name
PV_DISTANCE
PV_TIME
After fetching the distance and time readings, follow the below code to fill the corresponding value field for the names.
READ TABLE out_tab WITH KEY name = 'PV_DISTANCE'.
IF sy-subrc = 0.
CONDENSE v_distance.
out_tab-value = v_distance. " latest Odometer Reading
MODIFY out_tab INDEX 1 TRANSPORTING value.
ENDIF.
CLEAR out_tab.
READ TABLE out_tab WITH KEY name = 'PV_TIME'.
IF sy-subrc = 0.
CONDENSE v_time.
out_tab-value = v_time. " Passing latest Engine Hours
MODIFY out_tab INDEX 2 TRANSPORTING value.
ENDIF.
These procedures will make the values to be fetched inside the sap script using sub-routine pool.
Plz award points if useful.
Thanks,
Karthik
ENDFORM. "odometer_reading
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you can change the driver program then you dont need to write subroutines at all. we can write subroutines only when we cant change the driver program.
If you are not authorised or not supposed to make changes in driver program then we create a seperate program, in that we can write form routines.
Reward points if useful.
Regards,
Nageswar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.