cancel
Showing results for 
Search instead for 
Did you mean: 

routine-issue

Former Member
0 Kudos

Hi,

I need to code for a subroutine in a smartform, I need to go for form routines option to declare it and call it in INITIALIZATIOB TAB by perform keyword. The syntax for subroutine is exactly given below as per requirements.

perform sub1 using &mara-matnr& &mara-mtart& changing &var1&.

Can anyone say how provide import and export parameters in initialization tab regarding this subroutine and also in FORM ROUTINES by a sample example like above.

Accepted Solutions (1)

Accepted Solutions (1)

MarcinPciak
Active Contributor
0 Kudos

Hi,

In FORM ROUTINES tab just create your desired subroutine, like normally in ABAP.


FORM sub1 USING mara-matnr type "give a type here
                              mara-mtart type "and here 
                              changing var1 type "....
...
ENDFORM.

Then in INITIALIZATION tab just invoke your subroutine.


PERFORM sub1 USING ...

I hope it will help you

Marcin

Former Member
0 Kudos

Hi,

Thank you very much for your kind response.Can you say how to implement the 'IF' condition in accordance with subroutine, sothat that particular subroutine should be called based on if condition.

MarcinPciak
Active Contributor
0 Kudos

In in INITIALIZATION tab:


If condition1 = true.
  PERFORM sub1.
elseif condition2 = true.
  PERFORM sub2.
endif.

Thank you for your points and regards

Marcin

Former Member
0 Kudos

Hi Marcin,

I have a small extra requirement here.I need to print the value of changing parameter passed to subroutine in a window.

Can u please say how to do that. Waiting for ur reply.

Thanks,

G sandeep Kumar.

MarcinPciak
Active Contributor
0 Kudos

- Define a global variable in Global definitions i.e. g_my_var

- in INITIALIZATION tab write it as INPUT and OUTPUT parameter.

- then call your subroutine with this variable

PERFORM sub CHANGING g_my_var.

It will change content of this global variable, thus you will be able to use this changed variable in your window:)

Cheers

Marcin

Former Member
0 Kudos

Hi Marcin,

Thank you again.I request to see carefully the perform stmt I've posted.

The i/p variablesfor subroutine which're in the 'using ' paranthesis are like &mara-matnr& &mara-mtart& coming from a subroutine-pool program which is being implemented in sapscript.

Now the requirement is to create smartform in which I need to implement this logic of subroutine using those &mara-matnr& varaiables in the 'using' Paranthesis.

can u plz post the solution for this exactly. Please do reply me.Waiting for ur reply.

Thanks,

G Sandeep Kumar.

MarcinPciak
Active Contributor
0 Kudos

perform sub1 using &mara-matnr& &mara-mtart& changing &var1&.

I guess you want this changing i/p be visible in the window right? and all using params only visible inside routine?

As they are not typed you can create such routine:


FORM sub USING matnr mtart mtart CHANGING g_var1.
"here you just use your using params. which are implicitly of type any
"here also change g_var1 
ENFORM.

In INTIALIZATION tab use your globally declared variable (as I said before) and assing what you have in your &var1& to it.


g_var = var1.
"Then perform your routine
PERFORM &mara-matnr& &mara-mtart& changing g_var.

Is that what you meant?

Former Member
0 Kudos

Hi Marcin,

Thank you very much for all ur support. I just have 2 more doubts remaining.

1)Actually the values for i/p parameters in 'using' paranthesis i.e.,&mara-matnr& &mara-mtart& comes from the Driver Program in case of the script.

Now in the SMARTFORM if I declare like this in Initialization tab,

perform sub1 using &mara-matnr& &mara-mtart& changing &var1&.

will the values pass to &mara-matnr& from Driver Program, I just want to know.If it's the case I want to know what I have to type exactly in the i/p o/p parameters of the Initialization tab with regard to them.

I'm very new to these smartforms. So, please do reply me as of I need ur assistance.Thank you once again.

Regards.,

G Sandeep Kumar.

MarcinPciak
Active Contributor
0 Kudos

Providing you know these parameters at smartform's start you will have to pass all using params to i/p of initialization and all changing params (in your case only one) both for i/p and o/p.

I am not familiar with SAP Script, thus I don't know where you call it and whether these variables will be passed at smartform's runtime

In order to pass them to Smarform itself use Import tab in Form interface, but as I told you: I don't know where you call your Driver Program.

Answers (3)

Answers (3)

Former Member
0 Kudos

as

Former Member
0 Kudos

Needed some modification in the posted solution.

Former Member
0 Kudos

Hi , dont and the & in the variables in the smartform coding area. write the code as you write in the abap editor.

Thanks.

Regards,

Jey