Application Development 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: 

sapscript: PERFORM USAGE

Former Member
0 Kudos
/: DEFINE &VAR1& = 2
/: DEFINE &VAR2& = 3
/*
/: PERFORM SUB1 IN PROGRAM PROG1
/: USING &VAR1&
/: USING &VAR2&
/: CHANGING &TOTAL&
/: ENDPERFORM
/*
* &TOTAL&

-


If I will add &VAR1& and &VAR2& in the called program PROG1 and stored the sum on &TOTAL&, should I expect the value 5 printed on my report? <b>thanks for the help.</b>

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

It should print.

<b>plz reward points if helpful or if it solves ur query.</b>

Thanks

Chinmay

6 REPLIES 6

Former Member
0 Kudos

Hi,

It should print.

<b>plz reward points if helpful or if it solves ur query.</b>

Thanks

Chinmay

Former Member
0 Kudos

Hi!

Exactly, you're right.

Here's an example for the coding:



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.

Regards

Tamá

Former Member
0 Kudos

Hi

There is no need of external subroutine t do such calculations

/: DEFINE &VAR1& = 2

/: DEFINE &VAR2& = 3

/: DEFINE &VAR3&

You can write as

&VAR3& = &VAR1& + &VAR2&.

and print &VAR3&.

this will print 5.

Only use subroutine when you are fetching from different tables and useing it in the script.

Reward points if useful

Regards

Anji

Former Member
0 Kudos

Try in the same command line...

/: PERFORM SUB1 IN PROGRAM PROG1 USING &VAR1& &VAR2&

= CHANGING &TOTAL&

I think it will wrok fine than .... I have not tried your's way....

Regards,

Jayant Sahu.

Please award if help ful.

Former Member
0 Kudos

HI,

I will Prin 5 in the output

You need to write the below code

FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.

DATA: NUM1 type i,
          NUM2 type i,
          total type i.
         
READ TABLE IN_PAR WITH KEY ‘VAR1’.
CHECK SY-SUBRC = 0.
NUM1 = IN_PAR-VALUE.

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

TOTAL = NUM1 + NUM2.

READ TABLE OUT_PAR WITH KEY ‘TOTAL’.
CHECK SY-SUBRC = 0.
OUT_PAR-VALUE = TOTAL.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM

.

Regards

Sudheer

Former Member
0 Kudos

wow that was a lightspeed reply! I wonder what you people do on your desk. hehehe.

anyway, THANKS FOR ALL THE REPLY. <b>i gave points!</b>