cancel
Showing results for 
Search instead for 
Did you mean: 

subroutine in script. REWARDED

Former Member
0 Kudos

Hi All,

Please give me a sample and easy code

for calling subroutine in script

subroutine defination zprogram which is having a select statement.

every helpful answere is rewarded surely.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (3)

Answers (3)

Former Member
0 Kudos

hi priyanka,

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

Regards...

Arun.

Reward points if useful.

Former Member
0 Kudos

hi,

Syntax in a form window:

/: PERFORM

/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/

Coding of the calling ABAP program:

REPORT QCJPERFO. 

FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.

DATA: PAGNUM LIKE SY-TABIX, "page number 
NEXTPAGE LIKE SY-TABIX. "number of next page

READ TABLE IN_PAR WITH KEY ‘PAGE’.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.

READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.

READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = ‘|’. "First page 
ELSE.
OUT_PAR-VALUE = ‘||’. "Next page 
ENDIF.

IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = ‘L’. "Flag: last page

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

 

ENDFORM.

Regards

Sudheer

Former Member
0 Kudos

PERFORM <subroutinename> IN PROGRAM <DRIVER_PGM-NAME>.

Former Member
0 Kudos

In your print (driver) program define any subroutine.

In script call the subroutine using

PERFORM <subroutinename> IN PROGRAM <DRIVER_PGM-NAME>. (Use /: Command)

You can pass parameters also as in normal calls like using ..etc