Application Development and Automation 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: 
Read only

Calling sub routines without perform statements

Former Member
0 Likes
2,128

Hi,

I have gone through existing related posts but i couldnt get the

clear answer.

My question is i have seen few subroutines which are being called without perform statement.

How is it possible and if possible then in what are all the cases.

Please tell me.

Thanks,

Ahmed.

10 REPLIES 10
Read only

Former Member
0 Likes
1,579

Nope, you can not call subroutine without PERFORM statement. Like you cannot call a function without CALL FUNCTION statement.

Read only

Former Member
0 Likes
1,579

Hi Ahmed,

Basically PERFORM is a keyword used to declare a subroutine.

And FORM is a keyword used to define a subroutine.

So without declaration we can define right.

Cheers!!

VEnk@

Read only

Former Member
0 Likes
1,579

Hi,

u must have seen those in programs.... like ALV, output control, include programs.....

there are subroutines which are not called from within that programs. but they are called from some other programs....so u dont see that Perform statement...

Read only

Former Member
0 Likes
1,579

Ahmed,

If you have ever accessed NACE tcode...there you will find routines like Entry,Entry_Neu..etc.

In these cases, in the program you just need to have

Form Entry

Endform.

As you are assigning to nace....Perform will be taken care of. This is an example without Perform.

Regards,

Vishwa.

Read only

VikasB
Active Participant
0 Likes
1,579

Hi Ahmed,

There could be chances of dynamic calls to the particular subroutine. For example we can pass event name and form name to function module 'REUSE_ALV_GRID_DISPLAY' or list display with table parameter it_events.

Regards,

Vikas.

Read only

Former Member
0 Likes
1,579

Hi,

Its not possible to call a subroutine without a perform statment, but yes there are some places where you assign a subroutine name and the main program then calls these subroutines dynamically.

With ALV's for example you pass the callback subroutines for setting the pf-status , user_command etc. these are then called using the syntax perform (subroutin_name) in program (program_name) using changing...

Same is the case with the Scripts and EDI processing settings in NACE as mentioned above. they will be called dynamically.

regards,

Advait

Read only

0 Likes
1,579

Hi Advait,

I have found your answer interesting . Can you please send one example.

Thanks, Ahmed

Read only

0 Likes
1,579

In the below code we have given the subroutine name to the input to ALV FM, and that gets called dynimically.

  
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-cprog
      i_grid_title             = text-005
      i_callback_pf_status_set = 'F_SET_PF_STATUS_1'
      i_callback_user_command  = 'F_USER_COMMAND_1'
      is_layout                = e_layout2
      it_fieldcat              = t_fcat2
    TABLES
      t_outtab                 = t_docs2
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.


************
FORM f_user_command_1 USING us_ucomm     LIKE sy-ucomm
                            us_selfield  TYPE slis_selfield.

ENDFORM.

Read only

0 Likes
1,579

Hi ,

Swastik has given you an example for ALV.

So for ourput types, If you goto transaction NACE, Application V3 and take any output type and see the processing routines, you will see the prgoram name and the subroutine(Form)

example :

Output Type RD01 SingleInv.f.InvList

Application V3 Billing

Program FORM routine Form Sm

RVADIN01 ENTRY RVINVOICE01

RVADIN01 ENTRY RVINVOICE01

EDI RSNASTED EDI_PROCESSING

So if you goto program RSNASTED, you will only see the subroutine edi_processing and not the perform statement. This is because the subroutine is called from another program RGJVEDIO dynamically.

PERFORM EDI_PROCESSING(RSNASTED) USING HELP_RETURNC

US_SCREEN.

regards,

Advait

Read only

Former Member
0 Likes
1,579

Hi,

All the ways mention in this thred so far actually USES the key word PERFORM some where in the SAP STANDARD programs to call the subroutine.

I feel you are talking about MACROS and not subroutine becuase for calling them we only type the MACRO name and the variables to be passes.

Macros are defined using DEFINE .. ENDDEFINE. statements.

Regards,

Prakash Pandey