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

Code insert in ABAP program

Former Member
0 Likes
4,286

Hi all,

How can i insert a single line of code in background? This needs to be done for thousands of objects. Also, we need to capture all the changes in a single TR. Is there is any automation program available to update these objects.

Thanks,

Stanley

Moderator warning - Please be aware of the potential danger such a solution can pose.

Message was edited by: Suhas Saha

15 REPLIES 15
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
3,013

Hi Stanley

Why do you need to change thousands of objects. Can you please provide us the background/issue you are facing ?

Nabheet

Read only

0 Likes
3,013

Hi Nabheet,

I got a requirement to include same piece of code for list of objects. Instead of doing it manually, it will be better to update via automation program. Is it possible? If so, how this can be done?

Thanks,

Stanley

Read only

GirieshM
Active Contributor
0 Likes
3,013

Hi Stanley,

Please clarify me, why you need to change the code in thousand objects? If you tell your sceanrio the experts may help you to guide you in a proper way to acheive your requirement. Is that a standard Object?

With Regards,

Giriesh M

Read only

0 Likes
3,013

Hi Stanley

We do have options available where we can create/edit/read program lines for read report do an F1 and check. But the question that remains is how will you identify at what place the change is needed in each program?

Nabheet

Read only

ThangaPrakash
Active Contributor
0 Likes
3,013

Hello Stanley,

When I look into your question, it reminds me of correction instructions in SAP notes during the implementation.

In the correction instruction we have a Insert block and delete block for all programs under the correction instruction.

As I know, only SAP can create correction instructions and release it as notes.

Regards,

Thanga

Read only

Former Member
0 Likes
3,013

Hi Stanley,

If you are able to tell at which place in code you need to add the extra line i can try for solution.

Regards,

Vineesh.

Read only

Former Member
0 Likes
3,013

Hi Stanley,

Though there are statements related to adding the lines of code to a program, it is quite a BIG RISK to have them automated. For each and every program you need to know at which place you need to do add/remove piece of code.

Thanks in Advance.

Regards,

Rajesh

Read only

0 Likes
3,013

Hi all,

I want to insert my code exactly after the initialization event. All are custom objects.

Thanks,

Stanley

Read only

0 Likes
3,013

Stanley by using statements read report and insert report you can add in you initilaization event.

http://help.sap.com/abapdocu_70/en/ABAPINSERT_REPORT.htm

http://help.sap.com/abapdocu_702/en/abapread_report.htm

First from 2nd link read the code into internal table.

loop the itab into wa.

append wa to itab_temp.

if wa_line eq 'initialization'.

append the required code to itab_temp.

endif.

endloop.

now after having the code(pgm+required line) in itab_temp.

Insert it by using 1st link.

By this you can add required line to your code

Regards,

Vineesh.

Read only

0 Likes
3,013

You can then create a small proof of concept with read/insert report by modifying your code. I would suggest you if is something which is going to be reused then you can create a function module/ global class static method so that going further you can simply modify it in future

Nabheet

Read only

0 Likes
3,013

I too implemented the same technique which Vineesh proposed. But the problem is, i want to capture all the changes in Transport Request. Is it possible to handle those changes in TR? If so, how that can be done?

Read only

0 Likes
3,013

Quoting ABAP Help

"If you use INSERT REPORT to create a new program, this program is not assigned to a package, so that it is not connected to the correction or transport systems. You must either assign the program to a package in the ABAP Workbench or it is only suitable for temporary tasks in the current system."

Nabheet

Read only

0 Likes
3,013

Someone had posted a code that had insert report, plus extra FM calls to take care of activation, assignment to package and transport.  AFAIR, it was reported abuse because it's dangerous.

It would be best for OP to use trace to figure out the method.

If community helps, it will be partly responsible if the system gets damaged beyond repair.

Read only

0 Likes
3,013

Hi Stanley,

For this tr will not be generated.

If you want to get tr then u need to manually change it.

Read only

matt
Active Contributor
0 Likes
3,013

There are a number of statements available for dynamic programming that permit you to read programs into an internal table, change the internal table and write the programs back. You only need to read the ABAP help to find them.

You must ensure safety and that you test on a sandbox system first. A program such as you suggest must never be available in production. It must be coded to prevent changes being made to any program outside the customer namespace.


There are various function modules, easily found, that will allow the changes to be stored in a transport.

A common requirement is to add code to all programs that gives information about their use. Such a requirement is easily met by the source code coverage analyser (SCOV) which has a counterpart (UPL or something, or SCOV-lite) that can be run in production without affecting performance.

If this isn't your requirement, then perhaps if you shared it, we'd be able to come up with a solution that doesn't require automatic code replacement and all the risk that entails.