cancel
Showing results for 
Search instead for 
Did you mean: 

subroutines in scripts

Former Member
0 Kudos

Hi friends,

can any one tell me hw to call subroutines in scripts for:

Find Invoice amount based on:

REGUP-BUKRS (Company code) = BSAK-BUKRS

REGUP-BELNR (Document No) = BSAK-BELNR

REGUP-GJAHR (fiscal year) = BSAK-BELNR

REGUP-BUZEI (line item id) = BSAK-BUZEI

and the table bsak-wrbtr...

wot to write in forms n what to write in form n where???

can ant one help me plz..very urgent................

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member624107
Contributor
0 Kudos

Calling ABAP Subroutines: PERFORM

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.

**********************************************

zprogram used for running dunning (for including reference number)...

&----


*& Report ZDUNN *

*& *

&----


*& *

*& *

&----


REPORT ZDUNN .

data:refno like bkpf-xblnr.

*perform getref using '1800004444'

  • changing ref_no.

FORM getref TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

data: l_belnr type MHND-BELNR,

l_belnr_ret type mhnd-belnr.

read table in_tab index 1.

l_belnr = in_tab-value.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = in_tab-value

IMPORTING

OUTPUT = l_belnr

.

select single xblnr from bkpf

into l_belnr_ret

where belnr = l_belnr.

read table out_tab index 1.

out_tab-value = l_belnr_ret.

modify out_tab index 1.

ENDFORM.

*data begin of in_tab occurs 0. "Using Parameters

  • include structure itcsy.

  • data end of in_tab.

*

*data begin of out_tab occurs 0. "Changing Parameters

  • include structure itcsy.

*data end of out_tab.

*

*

*

*FORM GETREF using in_tab

  • changing out_tab .

*

    • read table in_tab index 1.

*

    • select xblnr from bkpf

    • into out_tab

    • where belnr = in_tab-belnr.

*

*

*endform.