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

Dynamic Macro

Former Member
0 Likes
929

Hi all,

is it possible to call in a dynamic way a macro?

thanks

enzo

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
717

hi,

I think it is<b> not</b> possible.

It should be defined before we call it.

Regards,

Sailaja.

4 REPLIES 4
Read only

Former Member
0 Likes
718

hi,

I think it is<b> not</b> possible.

It should be defined before we call it.

Regards,

Sailaja.

Read only

former_member194669
Active Contributor
0 Likes
717

Hi,


Are you looking something like this

* Macro for controling the update tables
  define updatetable.
    if v_eflg ne c_y.
      if not &2[] is initial.
        modify &1 from table &2.
        if sy-subrc ne 0.
          move c_y to v_eflg.
         if not &2[] is initial.
          i_idoc_status-docnum = v_docnum.
          i_idoc_status-status = '51'.
          i_idoc_status-msgty  = 'E'.
          i_idoc_status-msgid  = 'YMAT'.
          i_idoc_status-msgno  = '733'.
          i_idoc_status-msgv1  = &3.
          i_idoc_status-msgv2  = ' '.
          i_idoc_status-msgv3  = ' '.
          i_idoc_status-msgv4  = ' '.
          append i_idoc_status.
         endif.
        else.
          i_idoc_status-docnum = v_docnum.
          i_idoc_status-status = '53'.
          i_idoc_status-msgty  = 'S'.
          i_idoc_status-msgid  = 'YMAT'.
          i_idoc_status-msgno  = '736'.
          i_idoc_status-msgv1  = &3.
          i_idoc_status-msgv2  = ' '.
          i_idoc_status-msgv3  = ' '.
          i_idoc_status-msgv4  = ' '.
          append i_idoc_status.
        endif.
      endif.
    endif.
  end-of-definition.


  updatetable ymatccid    i_yccureid     'YMATCCID'.
  updatetable ymatrplt    i_yccureidt    'YMATRPLT'.

aRs

Read only

Former Member
0 Likes
717

Can you please expand on it please? A macro itself is a block of executable statements. So you cannot really do a macro execution dynamically without writing down the macro name and passing the macor parameter values. If you have something like CALL MACRO ... then you probably can. But there is no such syntax. You can probably write a subroutine that takes the macro name, its parameters as the subroutine parameters and within the subroutine, you can build a CASE statement on macro name and write the actual macro statement there.

But I don't see why you want to do it dynamically.

Read only

suresh_datti
Active Contributor
0 Likes
717

hHw about a Dynamic subroutine instead ? something like

PERFORM (form_name) IN PROGRAM (sy-cprog).

~Suresh