cancel
Showing results for 
Search instead for 
Did you mean: 

Perform Statement in SAP Script

Former Member
0 Kudos

how can i use Perform Statement in SAP Script?

i want to pass one value from Script to a subroutine in another program and to receive one result back?

pls tell me the solution.........

<MOVED TO CORRECT FORUM BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 9:25 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Babu,

You can do this :

Code to be written in the Form Editor:

/:DEFINE &CUST& = '00000021'.

/:PERFORM GET_NAME IN PROGRAM Z_BC460_EX4_HF

/: USING &CUST&

/: CHANGING &NAME&

/:ENDPERFORM.

Code to be written in the Program :

REPORT Z_HENRIKF_SCRIPT_FORM .

TABLES scustom.

FORM get_name tables in_tab structure itcsy out_tab structure itcsy.

read table in_tab index 1.

select single * from scustom

where id = in_tab-value.

if sy-subrc = 0.

read table out_tab index 1.

move scustom-name to out_tab-value.

modify out_tab index sy-tabix.

else.

read table out_tab index 1.

move 'No name' to out_tab-value.

modify out_tab index sy-tabix.

endif.

    • You could also fill the ouput parameter table this way

  • READ TABLE out_par WITH KEY 'NAME1'.

  • out_par-value = l_name1.

  • MODIFY out_par INDEX sy-tabix.

ENDFORM.

reward points if usefull.

Regards,

Najmuddin

Answers (3)

Answers (3)

former_member188685
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Babu,

Please check this link

http://help.sap.com/saphelp_40b/helpdata/en/d1/803279454211d189710000e8322d00/content.htm

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.

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 (u2018First pageu2019, u2018Next pageu2019, u2018Last pageu2019) 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 u2018PAGEu2019.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.

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

READ TABLE IN_PAR WITH KEY u2018BARCODEu2019.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = u2018|u2019. "First page 
ELSE.
OUT_PAR-VALUE = u2018||u2019. "Next page 
ENDIF.

IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = u2018Lu2019. "Flag: last page

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

 

ENDFORM.

Best regards,

raam

valter_oliveira
Active Contributor
0 Kudos

Hello.

You have a simply but detailed descrption in this link:

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

Regards

Valter Oliveira.