cancel
Showing results for 
Search instead for 
Did you mean: 

Use of subroutine in SapScript

Former Member
0 Kudos

Hi Friends,

I am passing two parameters as input from sapscript perform statement and i want one field from database table as output.

In abap editor i have created two internal tables of the type ITCSY for input and output parameters. <b>The name field of the internal table i have created is getting populated but the corresponding value field is not getting populated,</b> so my further logic is not processed and i am not gettin the desired result i.e. it it displaying nothing.

Can you guide me on the same?

Regards,

Nikhil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

sample code for routines in script.

/: PERFORM FORM_TEST IN PROGRAM ZTEST

/: USING &VAR1&

/: USING &VAR2&

/: USING &VAR3&

/: .............

/: USING &VARN&

/: CHANGING &VAR_OUT1&

/: ................

/: CHANGING &VAR_OUTN&

in the program ZTEST...

FORM FORM_TEST tables in_tab structure itcsy

out_tab structure itcsy.

  • Get value of VARN

data: varn like ....

read table in_tab with key name = 'VARN'.

if sy-subrc = 0.

move in_tab-value to varn.

endif.

  • Update the value of VAR_OUTN

read table out_tab with key name = 'VAR_OUTN'.

if sy-subrc = 0.

move <value> to out_tab-value.

modify out_tab index sy-tabix.

endif.

ENDFORM.

check this link too...

http://help.sap.com/saphelp_erp2005/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm

Former Member
0 Kudos

Hi Nikhil,

Have a look at this example.

If this is the perform statement in the SAP scirpt:

PERFORM GET_PRICE_PER_UNIT IN PROGRAM ZTEST

USING &VBDPR-NETWR&

USING &VBDPR-FKIMG&

CHANGING &PRICE_P_U&

ENDPERFORM.

And The Subroutine in program should be this way:

FORM get_price_per_unit TABLES i_intpar STRUCTURE itcsy

i_outpar STRUCTURE itcsy.

The data read should be this way.

READ TABLE i_intpar WITH KEY name = 'VBDPR-NETWR'0.

READ TABLE i_intpar WITH KEY name = 'VBDPR-FKIMG'.

If u r not able to pass the value then just debug the sap script and see whether the value is being populated or not.

Let me know if something else is needed.

Reward points if helpful.

Former Member
0 Kudos

Hi,

My code is as follows in which i have ynbemployeetable in database from which i am taking empname and empgender as input and i want empid as output.

I have written following perform statement in se71.

PERFORM GET_DETAILS IN PROGRAM ZNIK_SSCRIPT_NEW_AS5

USING &YNBEMPLOYEETABLE-EMPNAME&

USING &YNBEMPLOYEETABLE-EMPGENDER&

CHANGING &EMPID&

ENDPERFORM

I have written following form in se38 abap editor. in this the input-value field is not getting populated.

FORM get_details TABLES input STRUCTURE ITCSY

output STRUCTURE ITCSY.

DATA : z_empname LIKE ynbemployeetable-empname,

z_empgender LIKE ynbemployeetable-empgender,

z_empid type i.

READ TABLE input with key 'YNBEMPLOYEETABLE-EMPNAME'.

CHECK sy-subrc = 0.

z_empname = <b>input-value</b>. "Not getting populated

READ TABLE input with key 'YNBEMPLOYEETABLE-EMPGENDER'.

CHECK sy-subrc = 0.

z_empgender = <b>input-value.</b> "Not getting populated

SELECT SINGLE empid FROM ynbemployeetable

INTO z_empid

WHERE empname = z_empname and empgender = z_empgender.

output-name = 'EMPID'.

MOVE z_empid TO output-value.

MODIFY output INDEX 1.

ENDFORM.

Can you help me know why it is not getting populated and what is the mistake?

Former Member
0 Kudos

Hi Nikhil,

The code in the program is correct.

probably the value from sap script is not being populated.

activate the debugger in sapscript and debug the the script to check whether the value is being populated or not.

go to utilities->activate debugger.