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

PERFORM IN SCRIPT

Former Member
0 Likes
625

HAI,

HOW CAN I USE PERFORM IN SAP SCRIPT.

HOW TO RETURN A VALUE FROM SUBROUTINE AND HOW WILL I PRINT IT IN SCRIPT.

EXPLAIN WITH EXAMPLE

THANK YOU

ASHOK KUMAR

3 REPLIES 3
Read only

Former Member
0 Likes
587

Hi,

You can use it in the following way.

In the SAP SCRIPT you can write :

perform get_address using g_adrnr changing a1 a2 a3 a4

p1 'Address1' &a1& " Prnting it on the output form

P1 'Address2' &a2&

P1 'Address3' &a3&

P1 'Address4' &a4&

P1 is the paragraph in the sap script. YOu can use default paragraph if you wish.

" This will send the g_adrnr to the form. The form will accept g_adrnr and do the oprtations and return back a1 a2 a3 and a4.

a1 a2 a3 and a4 could be 4 fields you fetch from say ADRC table.

form get_address will be in the print program for your sapscript.

Please dont foget to reward if you find it useful.

reagrds,

sachin

Read only

Former Member
0 Likes
587

hi

In the sap script you can call a perform as shown below

Perform <perform name> In program <program name>

using &< importing variaable 1>&

changing &<exporting variable 2>&.

In the subroutine pool <program name>

FORM <perform name> TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

*Local Variable declaration

DATA : l_day_name(15) TYPE c,

l_date TYPE sy-datum.

CLEAR in_tab.

  • * note that here i am reading with index 1 as there is one variable i have passed *from sap script.

**for no: of variables passed you can read this in_tab as the variables you are **passing will be present in different rows of the table in_tab.

READ TABLE in_tab INDEX 1.

IF sy-subrc = 0.

logic that needs to be implemented for the importing variable.

and say get the value of the output variable in l_day_name.

and append that to out_tab_value.

  • CLEAR out_tab.

*Pass the dayname to the sapscript.

MOVE l_day_name TO out_tab-value.

out_tab-name = 'L_DAY_NAME'.

MODIFY out_tab INDEX 1.

endif.

ENDFORM.

reward if useful

regards

Mohit

Read only

Former Member
0 Likes
587

Hi

See the below code

/:PERFORM GET_VAL IN PROGRAM ZGET_VAL

/:USING &IT_MARA-MATNR&

/:CHANGING &DESCR&

/:ENDPERFORM

Subroutine code

Form get_val tables in_tab structure itcsy

out_tab structure itcsy.

select * from makt into table it_makt

where matnr = in_tab-value.

data temp(40).

loop at it_makt.

temp = it_makt-maktx.

out_tab-name = 'maktx'.

out_tab-value = temp.

append out_tab.

endloop.

endform.

Reward me if its helpful

Regards

Ravi