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

Any Function module or any other way to update/change the Function module's fields ?

ankur_sharma16
Active Participant
0 Likes
8,952

Hello Experts,

I want to update/change fields of function module, say import or export parameter etc. So is there any FM available and if not any way of doing so ?

I am trying to see in debug mode how the change happens, but not getting anything.

Please suggest.

Regards,

Ankur Sharma.

1 ACCEPTED SOLUTION
Read only

ankur_sharma16
Active Participant
0 Likes
8,370

Hello Rüdiger Plantiko ,

Actually what i want is to make a report, in it if user gives old name and new name, then report should replace all the data element used in a FM by new name.

And that too with dark functionality, i.e. with no screen.

So i debugged the SAP's method for that and came to know about this class and method, but when i use it, its not updating the FM in which the named DE is used.

Regards,

Ankur Sharma

64 REPLIES 64
Read only

yogendra_bhaskar
Contributor
0 Likes
4,338

Hi Ankur ,

I think what you need can't be done through any FM .

You certainly have two choices :

1 > Enhancement in FM

2 > create you own Z .

regards ,

Yogendra Bhaskar

Read only

0 Likes
4,336

Am asking about custom FMs.

There must be a way, am searching for that way. Else i can make a new copy and replace it.

Read only

Former Member
0 Likes
4,336

Hi,

  You can do it by Enhancement.There is a option in Menu Function Module -> Enhance Interface.

Regards

Ajit

Read only

ankur_sharma16
Active Participant
0 Likes
4,336

i got the class and its method name, i.e. CL_FUNCTION_BUILDER and method is UPDATE_PARAMETER.

CALL METHOD obj1->update_parameter

   EXPORTING

     parameter      =  par_name

     line           =  '1'

     parameter_type =  'I'

   changing

     param_table    =  it_or

     param_docu     =  it_doc1

     modparam       =  it_ch

     moddocu        =  it_doc

   EXCEPTIONS

     ERROR          = 1

     others         = 2

         .

IF sy-subrc <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  else. WRITE: 'TEST'.

ENDIF.

But getting confused in their parameters.

PLEASE SUGGEST.


Read only

ankur_sharma16
Active Participant
0 Likes
4,336

Experts please suggest.

Read only

ankur_sharma16
Active Participant
0 Likes
4,336

I dont know from where to fetch the data of FM's parameters. Please suggest something.

Read only

0 Likes
4,336

i must say...please elaborate your requirement.

why you need to change the parameters of the function module.

come with your exact requirement.

however if it is absolute necessary you can create your own custom function module.

first u need to create a function group in which u will assign that FM.

we will start after Your requirement

Read only

ankur_sharma16
Active Participant
0 Likes
4,336

Hello Abhishek,

My requirement is, I want to rename the DATA ELEMENT used in a Function Module. And i want to do it programatically. This is not good, but i have to do this.

I tried to debug this but could not find much, only that the method update_parameter of class CL_FUNCTION_BUILDER is used, but i am not getting how to use it.

So, if you can suggest anything, than pls help.

Regards,

Ankur Sharma

Read only

0 Likes
4,336

cl_function_builder will only create instance of the function module.

it will not change its parametrs.

why r u not creating your own z function module. custom function module will exactly same parameters.

revert back if problem not solved.

Read only

0 Likes
4,336

Ok i can create Z-FM to update the DE in FM, but from where i will fetch all the data, i mean from which table?

like for tables  DD02l is there, for transport number E070/e071 etc is there, but from which table i will fetch FM's parameters info ?

Read only

0 Likes
4,336

if you dont know how to create FM.

go through this link:

<link to blocked site removed by moderator>

by the way which function module u want to copy?

Message was edited by: Thomas Zloch

Read only

0 Likes
4,336

Abhishek, I know how to create FM, but as you said create own custom FM to update FM parameters, so i was asking what functionality to write in it.

Read only

0 Likes
4,336

ok. tell me which function module to want to change.

write exactly the same functionality.

copy the source code from original function module into ur custom FM.

Read only

0 Likes
4,336

Brother, thats what i exactly i am asking, if there is anyway (FM, class, or anything) by which i can update the data element in some FM.

Read only

0 Likes
4,336

and i am asking  which function module's data element  u want to change ?

there are field exits to changes the data elements.

Read only

0 Likes
4,336

Suppose i have one custom FM whose import parameter is PARA1 and of type ZELEMENT. Now i want to change this ZELEMENT to YELEMENT.

How to do that ?

Read only

0 Likes
4,336

ques1: u want to change the import parameter of custom FM. or Standard Fm.

if this is custom FM-- simply create new data element in se11 and replace zelement with yelement.

elseif this is standard Fm then create yelement and then create new FM say Zfm_local and write yelement in its import parameter.

Read only

0 Likes
4,336

As i have mentioned earlier, i want to UPDATE the CUSTOM FM. And i want to do it PROGRAMATICALLY. User will give the old DE name and new DE name, and that new DE name should reflect into the FM.

Read only

0 Likes
4,336

These dependencies are a real pain, right. How far did you make it by now, 20%, 70%? I'm still sceptical if you get this working for all scenarios.

Please do not forget that people are helping on a voluntary basis, so please reduce the "suggest something" messages.

Thomas

Read only

0 Likes
4,336

Hello Thomas,

Till now i am able to rename DE, and if its used in some structure/table/program/class, i am able to change there also.

But now getting prob in changing the DE in FM. i got the class and method name by debugging, but not being able to change.

I try not to post many suggest request, but after few time if i see no reply, i repost it to keep the post fresh and in hope of getting some reply from all.

Read only

ankur_sharma16
Active Participant
0 Likes
4,336

Please suggest something.

Read only

ankur_sharma16
Active Participant
0 Likes
4,336

Suggest me how to use class CL_FUNCTION_BUILDER and method its UPDATE_PARAMETER.

It shows sy-subrc zero but change is not happening in the FM, i tried commit work also.

Please suggest.



Read only

0 Likes
4,336

Just curious: Why not designing your import parameter PARA1 TYPE ANY - and doing the desired generics with aprropriate field-symbols in the implementation?

Dynamic programming is a powerful option and can save you from the difficult task of generating a function module at run time.

Read only

0 Likes
4,336

If understand correctly, Ankur is building a tool that is supposed to take old and new data element name as input and then crawl through the entire object dependency tree in order to rename it whereever the old name is used.

Ankur, maybe you should explain this in each of your initial posts, to save people from spending time suggesting workarounds or alternative approaches that do not apply to your case.

Thomas

Read only

ankur_sharma16
Active Participant
0 Likes
8,371

Hello Rüdiger Plantiko ,

Actually what i want is to make a report, in it if user gives old name and new name, then report should replace all the data element used in a FM by new name.

And that too with dark functionality, i.e. with no screen.

So i debugged the SAP's method for that and came to know about this class and method, but when i use it, its not updating the FM in which the named DE is used.

Regards,

Ankur Sharma

Read only

0 Likes
4,336

Hi Ankur,

my warnings that you should search for another solution remain unheard. 😞 

  • Suppose it would not be possible to change function modules programmatically, how would you proceed?
  • For what purpose do you want to change the type of the parameter? Can the functionality for which you are trying to do this, be achieved on another, simpler way?
  • Try to use dynamic programming,

You don't want to follow these safe paths, so...

I tried a bit around and was able to change the interface of a function module. The only little problem is that it doesn't change the code template at the beginning of the implementation code of the function module. But this should not really be a problem, since it is commented code for the developers' convenience, not more.

See the following report:

http://pastebin.com/HxC1KTvN

... and use it as starting point. If nothing can stop you on this route ...

Regards,

Rüdiger

Read only

0 Likes
4,338

Thanks Rüdiger, its a big help for me. Thanks a lot sir. Hope to get more help from you as am going for export, change, table and source code also, ie if DE is used anywhere in the FM.

Please do check the post as and when you get time, i will surely need more help from you all, or if i can get email id or something where i can directly contact you.

Regards,

Ankur Sharma.

Read only

0 Likes
4,338

Rüdiger one problem is coming, that in activate method you have passed 'X' but it show error there, and if we don't pass then screen will come to ask for activation place.

Suggestion ?

Read only

0 Likes
4,338

In the test program, replace lo_dark->activate( 'X' ) by this:

lo_dark->activate( exporting suppress_dialog = 'X' exceptions others = 1 ).
   if sy-subrc <> 0.
     message id sy-msgid type 'I' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   endif.

This way, you will see what problem the activation runs on.It should be the same error message that you get in SE37, too, when doing the same steps there (i.e. changing the import parameter type and then hitting "Activate").

In my case, there was no error exception. I changed a local ($TMP) function module, with no dependencies to other code in the function module.

Regards,

Rüdiger

Read only

0 Likes
4,338

Hello Rüdiger,

Same SYNTAX error is coming, " Method "ACTIVATE" does not have parameters " .

Regards,

Ankur Sharma

Read only

0 Likes
4,338

Dear Ankur,

I am afraid I don't the time to write you the complete program you need. The test report will give you the idea. If you need more, expand it yourself.

For example, for changing CHANGING parameters, I would try passing parameter_type = 'C' instead of 'I', and passing lo_fm->interface-change instead of lo_fm->interface-import to param_table.

I am not an expert in CL_FUNCTION_BUILDER, I only explored its functions, like you did.

Regards,

Rüdiger

Read only

0 Likes
4,338

Hello Ankur,

OK, this means that the parameter SUPPRESS_DIALOG has been added in a later release (I am testing on a SAP_BASIS 702 release, SAPKB70211).

Then probably the method FU_ACTIVATE_FUNCTION_INTERNAL of class CL_FUNCTION_BUILDER doesn't have the parameter SUPPRESS_DIALOG either? If it does, replace lo_dark->activate( 'X' ) by lo_fm->fu_activate_function_internal( 'X' ).

If it doesn't, try to call the function module RS_WORKING_OBJECT_ACTIVATE with object = 'FUNC' and object_name = your function module - compare with the way how the activate( ) method calls it internally.

There probably is a completely independent report for activation of workbench objects that you could call at the end of all your changes. (Search it!)

It is a good idea to save all your changes first, and then, at the end, to activate everything at once. If you change the interface of your function module, the source code that calls this function module will become incorrect and probably has to be adapted automatically, too. After having made all this changes, you can activate all the inactive objects of your work list in one step.

Regards,

Rüdiger

Read only

0 Likes
4,338

Hello Rüdiger,

Surely i will try suggested method. And will reply you if i get the solution or not.

Thanks for your help Rüdiger. Hoping to learn from you more and more.

Read only

0 Likes
4,338

Hello Rudiger,

Again one problem. Actually what you told i did and my problem also got solved, import and export parameters are getting changed. But now when am trying to do the same with Changing parameter its not getting changed there. I think prob is short text and long text are not getting passed.

Please help.

loop at lo_fm->interface-change INTO ls_change WHERE structure = p_old.

  if NOT ls_change is INITIAL.

   lv_line = sy-tabix.

   ls_import-STRUCTURE = p_new.

CALL METHOD lo_fm->update_parameter

     EXPORTING

       parameter      = ls_change

       LINE           = lv_line

       parameter_type = 'C'

     CHANGING

       param_table    = lo_fm->interface-change

       param_docu     = lo_fm->interface-paramtext

       modparam       = lo_fm->interface-nparam

       moddocu        = lo_fm->interface-npdocu

     EXCEPTIONS

       error          = 1

       OTHERS         = 2.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

else.

   WRITE: 'No record found'.

ENDIF.

ENDLOOP.

lo_dark->save( ).

COMMIT WORK.

Read only

0 Likes
4,338

ls_import-STRUCTURE = p_new.

Read only

0 Likes
4,338

Thanks, did not notice is and started diving into complex thing. Thanks Rodriger.

Now am working on how to change the source code, if DE is used in source code then i will get the source code into IT and then modify it. Trying to see in debug mode which FM is being used by SAP to update the source code.

Read only

0 Likes
4,338

This is easier, you won't believe it!

For the IT, use data type STRINGTAB (table of string), so you get no problem with length of code lines.

read report LV_REPID into LT_CODE.

[change the code]

insert report LV_REPID from lt_code.

Be careful to keep the program syntactically correct. (There also is a statement SYNTAX-CHECK FOR LT_CODE, so you can check before saving and exit if a syntax error would occur).

Regards,

Rüdiger

Read only

0 Likes
4,338

Earlier, to change the data element used in report what i did is took the code in an IT, searched for the DE and replacedit and then used the FM RS_UPDATE_PROGRAM and then saved and activated it and it worked. So i was trying to see some method or FM in debug mode to modify the source code but you suggested simple way. Will try this and reply you.

Thanks Rudiger.

Read only

0 Likes
4,338

The difference is probably that really only the source code will be saved (in state "active") by the statement INSERT LV_REPID FROM LT_CODE, whereas the RS_... things will do a bit more. E.g. they will add a version to the version management. Also, the where-used navigation indices will be maintained. But I would guess that in your scenario you don't need these versions and where-used lists anyway?