‎2012 Jul 24 11:35 AM
Dear All,
I need to convert entire ABAP source code into either upper case or lower case but not mixed.
It has to be done programaticaly without using pretty printer option.
Please suggest me the possible way of achiveing this.
With regards,
‎2012 Jul 24 11:44 AM
Hi Naveen,
You can use the syntax READ REPORT to read the contents into a internal table.
READ REPORT <report name> INTO <internal table>. This will put the code in an internal table.
Loop through the internal table. Use the TRANSLATE syntax to convert to UPPER CASE. Modify the internal table.
Loop at itab.
translate itab to UPPER CASE.
modify itab.
endloop.
Use the INSERT REPORT to insert the internal to code.
Syntax: INSERT REPORT <program name> from <internal table>.
Cheers
~Niranjan
‎2012 Jul 24 11:43 AM
Hi,
I think you can do it by going to utilities->Settings->under ABAP Editor tab -> Pretty Printer and adjust the settings as per your requirement.
‎2012 Jul 24 11:43 AM
Hi Naveen,
How do you plan to change this?
Are you taking a Program name as input and changing that to Upper or lower case?
Can you use READ REPORT to read the report source, translate and use INSERT REPORT to replace?
Thanks,
Shambu
‎2012 Jul 24 11:58 AM
Dear Shambu,
My requirement is actually to convert part of the code in a custom Function module which has native SQL statements. Because Native SQL compiler cant recognize the statments if the statements are mixed cases and will give a dump.
I need make either upper case or lower case programatically WITHOUT USING PRETTY PRINTER only to statements having native SQL query.
With regards,
‎2012 Jul 24 12:13 PM
So you need to make changes to a custom FM; Can you try giving the FM include name in the READ REPORT keyword and see if this works.
Thanks,
Shambu
‎2012 Jul 24 1:27 PM
Also, you could look at CL_FUNCTION_BUILDER, method CHANGE.
In that there is a parameter PRETTY_PRINTED, maybe you could check that out..
Thanks,
Shambu
‎2012 Jul 24 11:44 AM
Hi Naveen,
You can use the syntax READ REPORT to read the contents into a internal table.
READ REPORT <report name> INTO <internal table>. This will put the code in an internal table.
Loop through the internal table. Use the TRANSLATE syntax to convert to UPPER CASE. Modify the internal table.
Loop at itab.
translate itab to UPPER CASE.
modify itab.
endloop.
Use the INSERT REPORT to insert the internal to code.
Syntax: INSERT REPORT <program name> from <internal table>.
Cheers
~Niranjan
‎2012 Jul 26 11:34 AM
Hi,
This will work in case of report.
I found that if I have to convert the case in function module this wont work.
With regards,
‎2012 Jul 24 11:54 AM
Hello Naveen,
You can use the following syntax for reading, validating and creating a report.
regards,
Javi
‎2012 Jul 24 12:46 PM
There is a function module PRETTY_PRINTER which is documented. Please have a look.
Is this a business requirement ?
‎2012 Jul 24 2:31 PM
Hi Naveen Srinivasa,
in editor, user keys Ctrl-A, Ctrl-U. Save.
Even if you have 100 includes, this will cost you less time than anything else.
Regards,
Clemens
‎2012 Jul 24 5:05 PM
Hi,
The problem with solution like changing code manually or programmatically to lower/upper case is that someone can come by later and use pretty printer to mess things up.
One way to guaranty that you only pass upper case to SQL layer is to put all native SQL commands in variables and then use TRANSLATE TO UPPER before calling the actual commands. This way you have control programmatically of what you pass. I did not check if this is possible.
But worth checking out.