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

change data element

Former Member
0 Likes
4,325

Hi all,

I have a requirement, i have to change existing data element (prodh) used in list of programs . i.e 3192 programs. I have to develop a tool, by running which it should find the programs in which (Prodh) data element is used, and replace it with custom data element( one we have created ).

I have wirtten some logic, by which i am able to find out in which all program we are using this (prodh) data element, and further written BDC program to go to t code se38, in change mode, but now i dont understand how to change the data element .

This report should run in background.

Thanks in Advance

1 ACCEPTED SOLUTION
Read only

ipravir
Active Contributor
0 Likes
3,950

Hi,

Please find the below basic program to update complete your requirement.

In the below code is replacing the STRING with CHAR10.

Regrads.

Praveer.

25 REPLIES 25
Read only

ipravir
Active Contributor
0 Likes
3,950

Hi Koushik,

Follow the below link to read the report from the existing SAP system,

and the same can be update through the internal table of information of the report.

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

After reading the program, the information will store into an internal table and then you have to write a

code to replace the data element with the new one and the later you have to update the same.

Regars.

Praveer.


Read only

Former Member
0 Likes
3,950

Thanks very much for your prompt help, i found the editor-call keyword the best suitable, but the thing is after this statement, how can i change the data element, as the program has to run in background, and in debugging mode, when this statement is executed, i have no control over program, once the statement is executed there is no effect of writing the replace statement.

How can i change the string in runtime, is the matter of concern right now.

Thanking you again very much, you really proved tircky for me, but still your help is expected and needed.

Read only

ipravir
Active Contributor
0 Likes
3,950


Hi Kaushik,

By the use of editor Call, you have to change the code manually, so again you have to find the existing Data element.

Try to write a logic, to replace the Existing Data Element with the newly one.

You can use the REPLACE command.

And if any changes happen, then only you have to update the existing Report information with the New one.

Note: As Matthew has Commented do not try to apply this logic to change the Standard Codes, it could be dangerous for other programs.

Regards.

Praveer.

Read only

0 Likes
3,950

Hi Kaushik,

I don't think it is possible to change the programs like this in background. It is not possible to achieve through BDC. You will have to do it manually.

Read only

Former Member
0 Likes
3,950

Thanks Bro, but whats happeing in here is :

   editor-CALL FOR REPORT wa_trdir-name .

   

     When this statement is executed, I have no control over the program flow, it directly displays the program in display mode (foreground), when i press back button, then only this line comes :

    REPLACE ALL OCCURRENCES OF  'PRODH' in wa_trdir-name WITH 'ZZPRODH'.

    Now this line has no effect. Can you please provide some help.

Read only

jrg_wulf
Active Contributor
0 Likes
3,950

Hi,

obviously, this is not a trivial request and should only be performed, if you know EXACTLY what you're doing, which, from your posts is not the case. So i would strongly discourage you from doing so.

It is like giving advice to mess with break-parts on a racing car.

If you don't know how these things work - don't do it. You'll end up with horrible things in your system.

Sorry, but in this case, i will not help and i hope, that no one else will.

BR - Jörg

Read only

Former Member
0 Likes
3,950

Thanks very much for discouraging me. But still can you please come out with some alternative to that. All that i have in my mind is in front of you, which you think is not the way, how it should be performed.

Read only

matt
Active Contributor
0 Likes
3,950

Once again we are presented with a solution to a requirement, not the requirement itself.

Changing the data element is one possible way of meeting the requirement. Whatever the requirement is, it's probably the worst way of achieving it.

Now. What is the business requirement, and are you planning on changing standard SAP code?

Read only

satyabrata_sahoo3
Contributor
0 Likes
3,950

This is not an easy way to change Data elements in all programs using BDC!!

Try some alternatives to meet the business requirement. anyway, PRODH is a structure in ECC 6.0 not Data element..

Read only

0 Likes
3,950

I'd go further. Forget it. You can't do it via BDC. It can be done via READ REPORT and INSERT REPORT; but if you were to do it, the chances of rendering your system unusable would be extremely high.

Again. What is the business requirement?

If you do not answer this question, I will lock this thread.

Read only

0 Likes
3,950

Kindly refer the question once more, try going through it twice, you'll be comfartable enough to understand it. Even if you are not able to understand, i'll try to explain in another manner.

Read only

0 Likes
3,950

Hi,

We all understand what you want to do, the question is "Why". Please explain why PRODH needs to be changed..

Once you do that, I'm sure that better alternatives will immediately become apparent.

cheers

Paul

Read only

0 Likes
3,950

We have nothing to do with it, we are doing what our higher management has said our manager has told us that now we'll be having only one PH, that is what our requirement for the entire project is.

We have already identified all the programs in which we've to change the data element. But now we've been asked to developed a tool which can do this changing part in background. So first i thought of writing a bdc, to change the data element, but by looking into the answers i thought that there will be a better option of doing that.

Now I think that i have answered all the questions, so can anyone help me with the answer..

Thanks again in Advance , Developers.

Read only

0 Likes
3,950

You haven't really explained the business requirement.

Two more questions.

1) Are you changing only custom programs?

2) What are you actually attempting to change within the programs? DATA: myprod TYPE prodh. to DATA: myprof TYPE zprodh. or something similar?

Read only

0 Likes
3,950

kaushik bisht wrote:

Kindly refer the question once more, try going through it twice, you'll be comfartable enough to understand it. Even if you are not able to understand, i'll try to explain in another manner.

That kind of patronising way of addressing people who are actually trying to help you will do you no favours.

As it stands you are attempting to do something which the experienced among us consider extremely dangerous.The reason for all the questions is that there is probably a better way of addressing the business requirement than automatically changing thousands of programs and hoping that you've not forgotten something critical.

Read only

0 Likes
3,950

Customs Programs.

DATA : myprodh TYPE prodh.

Here we've to change prodh(data element), it can also be like table name-field name.

Now, we've to write a program, that can search for prodh and change the data element automatically, though we've to take some measures into consideration before changing, but that logic can be written.

As stated earlier, i tried writing a BDC, to change the ABAP editor and make changes into it, but as replies started to come, i have decided that, it's not the better way.

Can you please help me with a clue, as how to go forward with it.

This requirement is in high priority.

Thanks again, appreciate your help. Those answers by me is just a part of my frustration, as it's getting difficult for me to continue with the development of the program.

Read only

0 Likes
3,950

As I already said

It can be done via READ REPORT and INSERT REPORT;


The fact that you're only covering custom programs is somewhat a relief, but I maintain, as others do, that this project is fundamentally dangerous.

Read only

0 Likes
3,950

"We have nothing to do with it, we are doing what our higher management has said our manager has told us"

I take it this means you don't know the reason 'why'?

You could have just said so...

It can indeed be done (as described above). I recommend running it in test mode first to make sure nothing gets wrecked. Even then, you will probably have to follow up with a LOT of manual fixing.

cheers

Paul

PS Make sure you have this request from your manager in writing.

Read only

ipravir
Active Contributor
0 Likes
3,951

Hi,

Please find the below basic program to update complete your requirement.

In the below code is replacing the STRING with CHAR10.

Regrads.

Praveer.

Read only

matt
Active Contributor
0 Likes
3,950

What if there is a data type called STRING_OF_NUMBERS?

Read only

jrg_wulf
Active Contributor
0 Likes
3,950

Like Matthew (now twice) pointed out, read- and insert report are your only options. The problem however, is to maintain controll. Just finding and replacing a string is easy enough.

The problem starts with countless "what if"s

What if your search-key-word is included as part of another name (like gt_prodh) or something along the line.

What if there are indirect references

What if there are parameters, that require the type of prodh

Again, if i were in your place i wouldn't dare to bite off more than i could probably chew.

No disrespect, but some of your posts show, that you're not too experienced.

I consider myself to be - and still i would do anything to avoid this scenario.

I keep to my disencouragement.

And the question remains - what is your initial objective? Why take the pains, to alter over 3k Programs?

BR - Jörg

Read only

matt
Active Contributor
0 Likes
3,950

Sometimes, even very senior management have to learn how to deal with disappointment. But it's good for them. Character building.

Read only

Former Member
0 Likes
3,950

Yeah ! Thanks dude, It worked, i have no words to thank you. God bless You.

Read only

matt
Active Contributor
0 Likes
3,950

You did read my observation that with the sample code a type such as Z_STRING_OF_NUMBERS will be changed to Z_CHAR10_OF_NUMBERS?

If you have anything containing PRODH, it will be changed to your new data element - so if you have:

DATA prod_hierarchy_handler TYPE REF TO Z_PRODHIERARCHY, that will change to something that is no long syntactically correct. I.e. the solution you've been given is only the very basic formulation - to be absolutely safe, you've got a lot of parsing to do, and need to consider all possibilities.

Another example. Let's say you call a standard function module that expects a parameter of type PRODH. So you have

DATA myparam TYPE prodh.

...

CALL FUNCTION  'SOME_STANDARD_SAP_FM' exporting i_param = myparam.

After your program runs, if you write it naively, you'll get a dump, due to a type mismatch.

Your project will fail if you do not correctly handle all possibilities.

Read only

jrg_wulf
Active Contributor
0 Likes
3,950

Since you seem to be determined to proceed, please read Matts reply again.

And then:

  • Spend a lot of time on analyzing, in what forms the search-key-word might occurr and make sure you only replace those, you intend to replace.

  • Make a copy of each program before actually changing it or at least make sure to draw a version of each program BEFORE changing it. Using read / Insert will not do that for you!
    Because if you don't, you will have difficulties to get back to a previously working version.

  • Make yourself thoroughly aquainted with regular expressions. They might give you at least the best control over your search-results.

  • Make sure, you get a complete list of all changes in a readable form. Don't rely on a list output, but make sure to download the protocol to a file.

  • Do a lot of testing and testing again. Think about every mean combination of your keyword and try the result.

  • Read Matts reply again.

Good luck - Jörg