Application Development 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: 

Add a new column in query

Former Member
0 Kudos

Hi All,

My requirement is to add a new column(local field) to an existing SAP query. I have to add the field in the query and write some logic for fetching the value for that field in the program.

But i dont know how to proceed. Should i add the field (with any name) in SQ02 and generate a user-defined program?(currently existing program is standard). Or should i create 'Z' program separately? If so, how to connect it to my query? I completely dont have any idea. I went through related threads but its not of much help to me. Any suggestions are welcome.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi-

You have to add the field in the infoset through tcode SQ2 and then you have to go to tcode SQ01 and change the query. In that if you want to add the field in between the existing fields,then you have to uncheck the fields and recheck the fields in order. then execute it in background,it will generate a program,the program name you can see in se38,the 1st name after execution in backgroung though SQ01.then copy the program into Z-program and make the changes and incorporate your logic.

Hope it will help.

If any doubt ,let me know

4 REPLIES 4

naveen_inuganti2
Active Contributor
0 Kudos

Why can't you go for the copy of the program.

Copy the program into your zprogram and make the neccessary changes to zprogram.

If it is the program behind the screen(Transaction codes), You can use enhancement spots and do your coding.

--Naveen Inuganti.

Former Member
0 Kudos

Hi Sudharsana,

Here are my answers:

Should i add the field (with any name) in SQ02 and generate a user-defined program?(currently existing program is standard).

 if the required field is not in infoset yes, You will habe to add it under Additional field and also need to write the field coding for the same, right click on field and say "Display Code"

Or should i create 'Z' program separately? If so, how to connect it to my query?

No

Refer this [blog|http://shafiq.us/sap/index.php?view=article&id=54%3Aadhoc-query&option=com_content&Itemid=61] for more information, its quite simple.

Hope this helps!

Regards

Shital

Former Member
0 Kudos

Hello,

You may create an Additional Field in SQ02 and attach the same to one of the existing field groups. Now you can define a code snippet for the definition of the additional field. In SQ01, this field will available in selection as well as in layout screens.

Thanks,

Venu

Former Member
0 Kudos

Hi-

You have to add the field in the infoset through tcode SQ2 and then you have to go to tcode SQ01 and change the query. In that if you want to add the field in between the existing fields,then you have to uncheck the fields and recheck the fields in order. then execute it in background,it will generate a program,the program name you can see in se38,the 1st name after execution in backgroung though SQ01.then copy the program into Z-program and make the changes and incorporate your logic.

Hope it will help.

If any doubt ,let me know