Use the concept of PERFORMS in script text elements:
See this link:
http://help.sap.com/saphelp_47x200/helpdata/en/d1/80318f454211d189710000e8322d00/frameset.htm
Regards,
Ravi
Create a subroutine pool in se38 and call it in u r script .
<b>Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&</b>
In the textelement of sapscript i am calling subroutine GET_BARCODE present in program QCJPERFO and passing PAGE , NEXTPAGE as input parameters and Barcode as changing parameter (output)
<b>Coding of the calling ABAP program ( Subroutine pool ):</b>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
// Here in_par is table for input parameters is of type itcsy , so contains name and value as fields.
// 1st record of in_par in_par-name = PAGE in_par-value = the current page number
// (eq. 1 or 2 etc ... )
// 2nd record of in_par in_par-name = NEXTPAGE in_par-value = the Next page //number (eq. if page = 1 then next page = 2 etc ... )
// Here out_par is table for changing parameters ( output ) is of type itcsy .
// since i am passing only one changing parameter it contains only one record
// 1st record of out_par out_par-name = BARCODE out_par-value = ...(some value)
READ TABLE IN_PAR WITH KEY PAGE.
// reading the records from in_par where field name is PAGE , so first record is selected from our table
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
// Page number is stored in variable PAGNUM
READ TABLE IN_PAR WITH KEY NEXTPAGE.
// reading the records from in_par where field name is NEXTPAGE , so second record is selected from our table
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
// Next Page number is stored in variable NEXTPAGE
READ TABLE OUT_PAR WITH KEY BARCODE.
// reading the records from out_par where field name is BARCODE , so first record is selected from our table
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
// if the variable PAGNUM value is one then i am storing | in OUT_PAR-VALUE ie, BARCODE
ELSE.
OUT_PAR-VALUE = ||. "Next page
// if the variable PAGNUM value is not one then i am storing || in OUT_PAR-VALUE ie, BARCODE
ENDIF.
IF NEXTPAGE = 0.
// if the variable NEXTPAGE value is Zero then i am storing L in OUT_PAR-VALUE ie, BARCODE
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
// After changing the field value of output table , i am modifying to reflect the changes.
// Now barcode contains the changed value ie, either | or || or L depending on the condition satified
ENDFORM.
That changed value i am printing in sapscript
/ &BARCODE&
Add a comment