cancel
Showing results for 
Search instead for 
Did you mean: 

Calling subrouting in smart forms

Former Member
0 Kudos

Hi all,

I defined the subroutine in form routine of smart forms, but why not to call the subroutine in program line.

Anyone could tell me how to definite and how to call.

and i try the following way, but it is not good choice.

Perform xxxxxxxxxxx

in program xxxxx

using xxx

changing xxxx.

Thank you very much in advance,

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kevin.

In Smartforms, you declare a form which you want to be called in Form Routines, and then you call that form in the Initialization tab.

For eg. : In Initialization you say :

Perform get_text using value_1 changing value_2.

Then in form routines, you MUST have a form GET_TEXT :

Form GET_TEXT using value_1 changing value_2.

...

ENDFORM.

Also, in Form routines, you cannot access global data. So you need to pass it explicitly via USING/CHANGING.

Hope it is clear.

Regards.

Samant

Former Member
0 Kudos

To: Baburaj

Your answer is good , I will try this way.

But i wanna know other solution.

To: Samant

If i wanna call the subroutine in program line.

How to do.

Thank you.

Cheers

Kevin

Former Member
0 Kudos

Hi Kevin,

Your requirement is not clear. Why do you want to call a subroutine .

In Program lines node you can write any ABAP code and call external subroutine as well in the way -

Perform xxxxxxxxxxx

in program xxxxx

using xxx

changing xxxx.

You can also define subroutines inside a smartform Global definition ( the way you define in normal programs ). These routines can be called from program lines from anywhere in the smartform as an internal routines ( the way you do in normal programs ).

What Baburaj has suggested was for SAPSCRIPTS . I am not sure if it works in smartforms ( have never tried) . With smartforms you have a lot more flexibility and can directly call an external subroutine from program lines.

Cheers

( Dont forget to reward if answers were helpful )

Former Member
0 Kudos

hi, Sanjay

You can also define subroutines inside a smartform Global definition ( the way you define in normal programs ). These routines can be called from program lines from anywhere in the smartform as an internal routines ( the way you do in normal programs ).

I can't , are you sure.

And if i write abap code , so many redundant code is not necessary

Kevin

Former Member
0 Kudos

Sorry, Sanjay

Your answer is very good.

Thank you very much.

I solved it.

Kevin

Former Member
0 Kudos

Hi Kevin,

I can do it on WAS 620 . I am sure it is possible on 46C as well . You can define local data also here and change global data . Whatever you can do in a noraml program you can do in a subroutine in Smartform.

I am again not sure what exactly is your requirement to write a subroutine.

Cheers

I saw your problem is solved . Dont forget to reward if answers were helpful.

Message was edited by: Sanjay Sinha

Answers (2)

Answers (2)

Former Member
0 Kudos

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.

Example:

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.

You can use the above syntax for calling the Subroutine from a Form.

Regards,

Baburaj

Former Member
0 Kudos

Consider the instance,

If you want to do some proceesing like addition at the form level. You can use a subroutine called from the form.

If you call the subroutine from the Program, you will not able to meet the scenario exists in the form.

Regards,

Baburaj

Former Member
0 Kudos

Baburaj,

Sorry, I can not catch what you said,

Could you please give me a instance?

Thank you

Kevin