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

Converting ABAP code's case programaticaly

former_member282968
Contributor
0 Likes
1,719

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,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,573

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

11 REPLIES 11
Read only

Former Member
0 Likes
1,573

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.

Read only

Former Member
0 Likes
1,573

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

Read only

0 Likes
1,573

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,

Read only

0 Likes
1,573

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

Read only

0 Likes
1,573

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

Read only

Former Member
0 Likes
1,574

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

Read only

0 Likes
1,573

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,

Read only

Former Member
0 Likes
1,573

Hello Naveen,

You can use the following syntax for reading, validating and creating a report.

  • READ REPORT prog INTO itab
  • SYNTAX-CHECK FOR itab MESSAGE mess
  • INSERT REPORT prog FROM itab

regards,

Javi

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,573

There is a function module PRETTY_PRINTER which is documented. Please have a look.

Is this a business requirement ?

Read only

Clemenss
Active Contributor
0 Likes
1,573

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

Read only

0 Likes
1,573

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.