‎2012 Jul 20 8:21 AM
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.
‎2012 Jul 24 1:44 PM
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
‎2012 Jul 20 8:47 AM
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
‎2012 Jul 20 9:34 AM
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.
‎2012 Jul 20 9:37 AM
Hi,
You can do it by Enhancement.There is a option in Menu Function Module -> Enhance Interface.
Regards
Ajit
‎2012 Jul 20 12:38 PM
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.
‎2012 Jul 23 5:30 AM
‎2012 Jul 23 6:49 AM
I dont know from where to fetch the data of FM's parameters. Please suggest something.
‎2012 Jul 23 8:06 AM
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
‎2012 Jul 23 8:18 AM
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
‎2012 Jul 23 10:22 AM
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.
‎2012 Jul 23 10:29 AM
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 ?
‎2012 Jul 23 10:37 AM
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
‎2012 Jul 23 10:42 AM
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.
‎2012 Jul 23 10:48 AM
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.
‎2012 Jul 23 10:58 AM
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.
‎2012 Jul 23 11:11 AM
and i am asking which function module's data element u want to change ?
there are field exits to changes the data elements.
‎2012 Jul 23 11:19 AM
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 ?
‎2012 Jul 23 11:27 AM
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.
‎2012 Jul 23 11:33 AM
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.
‎2012 Jul 23 11:40 AM
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
‎2012 Jul 23 12:04 PM
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.
‎2012 Jul 23 10:13 AM
‎2012 Jul 24 1:01 PM
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.
‎2012 Jul 24 1:35 PM
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.
‎2012 Jul 24 1:44 PM
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
‎2012 Jul 24 1:44 PM
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
‎2012 Jul 24 3:50 PM
Hi Ankur,
my warnings that you should search for another solution remain unheard. 😞
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:
... and use it as starting point. If nothing can stop you on this route ...
Regards,
Rüdiger
‎2012 Jul 25 6:56 AM
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.
‎2012 Jul 25 6:58 AM
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 ?
‎2012 Jul 25 8:22 AM
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
‎2012 Jul 25 8:30 AM
Hello Rüdiger,
Same SYNTAX error is coming, " Method "ACTIVATE" does not have parameters " .
Regards,
Ankur Sharma
‎2012 Jul 25 8:31 AM
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
‎2012 Jul 25 9:11 AM
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
‎2012 Jul 25 9:48 AM
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.
‎2012 Jul 25 12:25 PM
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.
‎2012 Jul 25 1:43 PM
‎2012 Jul 25 2:17 PM
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.
‎2012 Jul 25 2:23 PM
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
‎2012 Jul 25 2:33 PM
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.
‎2012 Jul 25 3:25 PM
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?