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

Sapscript

Anindya
Explorer
0 Likes
562

Hi All,

In the text element of a window there is a perform statement which is given below....

PERFORM GET_BARRIER IN PROGRAM ZLABEL

USING &ZMATNR&

USING &ZBARRIER&

CHANGING &ZBARRIER&

ENDPERFORM

and the from statement is given below....

FORM get_barrier TABLES input_tab STRUCTURE itcsy

output_tab STRUCTURE itcsy.

i cant understand the correspondence between the parameters, which parameter gets copied to which parameter.

BR

Anindya

1 ACCEPTED SOLUTION
Read only

varma_narayana
Active Contributor
0 Likes
534

Hi..

The formal parameters in the FORM statement must be always in this way in case of SAP Script Subroutines.

TABLES input_tab STRUCTURE itcsy

output_tab STRUCTURE itcsy.

Here the input_tab Stores all the USING parameters in the PERFORM

These are READ-ONLY.

Here the Output_tab Stores all the CHANGING parameters in the PERFORM

They can be modified in the Subroutine.

Open the Structure ITCSY you can see 2 fields.

1. Name : Name of the Symbol

2. Value : Value of the Symbol.

Tip: Try to debug the FORM statement code .. you can notice the Data in these internal tables

REWARD IF HELPFUL.

3 REPLIES 3
Read only

Former Member
0 Likes
534

well in input_tab is a table with a element name.

to retrieve your first parameter the code would be:

data: lv_matnr   type mara-matnr.

read table input_tab
with key name = 'ZMATNR'.
if sy-subrc = 0.
  lv_matnr = input_tab-value.
endif.

i hope this is enough to give you an idea

code for your changing parameter would be:

data: lv_barrier  type char20. "(any type works)

read table output_tab
with key name = 'ZBARRIER'.
if sy-subrc = 0.
  output_tab-value = lv_barrier.
  modify output_tab index sy-tabix.
endif.

Read only

messier31
Active Contributor
0 Likes
534

Hi,

We can use the <b>PERFORM</b> 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:

<b>

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM</b>

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:

<b>FORM <form> TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

...

ENDFORM.</b>

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:

<b><b>/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO

/: USING &PAGE&

/: USING &NEXTPAGE&

/: CHANGING &BARCODE&

/: ENDPERFORM

/

/ &BARCODE&</b></b>

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 IN_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.

Hope this helps you.

Enjoy SAP.

Pankaj Singh.

Read only

varma_narayana
Active Contributor
0 Likes
535

Hi..

The formal parameters in the FORM statement must be always in this way in case of SAP Script Subroutines.

TABLES input_tab STRUCTURE itcsy

output_tab STRUCTURE itcsy.

Here the input_tab Stores all the USING parameters in the PERFORM

These are READ-ONLY.

Here the Output_tab Stores all the CHANGING parameters in the PERFORM

They can be modified in the Subroutine.

Open the Structure ITCSY you can see 2 fields.

1. Name : Name of the Symbol

2. Value : Value of the Symbol.

Tip: Try to debug the FORM statement code .. you can notice the Data in these internal tables

REWARD IF HELPFUL.