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

script

Former Member
0 Likes
737

can u plz explain below code

perform <subroutinename>

using <var>

changing<var>

endperform.

how Using will work and how changing will work plz explain clearly

what will we do with "Using" ,and"Changing". explain clearly with comments

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
697

Hi Rajesh,

Check this link. It has prciesely what you need.

http://help.sap.com/saphelp_46c/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm

Regards,

Ravi

7 REPLIES 7
Read only

Former Member
0 Likes
698

Hi Rajesh,

Check this link. It has prciesely what you need.

http://help.sap.com/saphelp_46c/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm

Regards,

Ravi

Read only

Former Member
0 Likes
697

Hi Rajesh,

When ever we required some more data with is not coming from the driver program need to be printed on the Script then we will use this....

Here the Using variable are to get the required data based on the values of this variable.. Means based on these using variable the required data will be retrived.

The changing variable are used to stored the required data and the same variables are used to print on the Script.

The correct format of the perform is as below.

perform <subroutinename> in program <prog>

using <var>

changing<var>

endperform.

Regards,

Satya.

Read only

Former Member
0 Likes
697

Hi,

/: PERFORM FORM IN PROGRAM Z_Program

/: USING &INVAR1& " This, we will send the value to Program

/: USING &INVAR2& " " This, we will send the value to Program

/: CHANGING &OUTVAR1& " " This, we will Get the value from Program

/: CHANGING &OUTVAR2& " This, we will Get the value from Program

/: ENDPERFORM

In the Z_program , you need to write

FORM

TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.

...
ENDFORM.


Exampel:

Definition in the SAPscript form:

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

/ &BARCODE&

 

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.

Read only

Former Member
0 Likes
697
Read only

Former Member
0 Likes
697

Rajeshreddy,

Basically both these parameters (using and changing)that are used in a sub-routine are to pass values to the Subroutine from a main program.

While Using parameter doesnt fetch back any value from the subroutine, changing parameter allows us to fetch a value back through the same parameter, after an operation has been performed in the subroutine..

Hope u will find the solution useful...

Reward points if found useful..

Read only

Former Member
0 Likes
697

Hi Rajesh,

see this document

i hope this is helpful for u.

<b>Calling ABAP Subroutines: PERFORM </b>

You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.

PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.

The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.

Syntax in a form window:

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.

OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.

The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:

FORM <form> TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

...

ENDFORM.

The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.

The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.

From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (‘First page’, ‘Next page’, ‘Last page’) is printed as local variable symbol.

Definition in the SAPscript form:

/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO

/: USING &PAGE&

/: USING &NEXTPAGE&

/: CHANGING &BARCODE&

/: ENDPERFORM

/

/ &BARCODE&

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.

Reward points if useful.

Read only

0 Likes
697

thanks lot