‎2011 Mar 24 8:03 PM
Hi all,
In transaction VOFM (Data Transfer --> Orders), I have been asked to copy code from one routine (Routine 51) to a new custom routine. Code from source routine 51 has u201CEnhancement pointsu201D in it and there is code inside the u201CEnhancement pointsu201D.
I copied the code from routine 51 onto a note pad and removed the "Enhancement points/spots" but retained the code in it. Then copied this code from notepad to the newly created routine. After activating the routine, running program u201CRV80HGENu201D, updating the index of Main program (SAPFV45C), I got syntax error because code inside ehancement has a structures which are not recognized by the program.
Then I copied all the code from routine 51 to the new routine, without making any changes. I clicked save, it pops up a box asking information about "Enhancements". I do not know what the impact of processing this pop up screen is. I do not have much experience with "Enhancements" except putting some code in it. Does anyone have any experience with similar situation and what do I do to copy code from an existing routine?
Any help is greatly appreciated. Thanks for your help!
‎2011 Mar 28 9:25 PM
Hello Sandra,
Thanks for your quick response. I am sorry I have not been very clear.
Yes all these enhancements (OI0_COMMON_SAPFV45C, ECO_HBS_SAPFV45C, and OIA_SAPFV45C) are active.
The first thing I did was just like you had suggested. I copied only the active code without copying lines ENHANCEMENT-POINT and ENHANCEMENT-SECTION. After copying when I did syntax check, I got syntax error that u201Coic_pipeu201D and u201Coid_exu201D is unknown. It is not declared in data statement.
Then I removed all the code from the new routine 951 and made it blank. Then I copied all the code from routine 51 and pasted it to new routine 951 u2013 including lines with ENHANCEMENT-POINT and ENHANCEMENT-SECTION. When I clicked save, it displayed a screen u201CChange Enhancement Optionu201D .
I hope this is clear now.
‎2011 Mar 24 9:54 PM
Hi Vince,
when you want to copy standard code which contains enhancement option implemented, into a custom code, I advise you to copy the whole active code without copying lines ENHANCEMENT-POINT and ENHANCEMENT-SECTION, but retain the code of active implementations. I think it's what you did.
Here are the rules how the system knows if an implementation or code is active, I hope there's no error (otherwise, tell me so that I can correct it) :
An enhancement spot and an implementation can both be linked to a switch, you'll see that switch in their "attributes" panel (SE18 or SE19 transaction, or double-click from ABAP editor).
1) If the enhancement spot is switched off, its implementations are not active.
2) If the enhancement spot is switched on, its implementations are active only if they are switched on
3) If an enhancement section has its enhancement spot active, and at least one of its implementations is active, then the code inside the enhancement section is deactivated.
Example :
ENHANCEMENT-POINT z_point SPOTS z_es.
*$*$-Start: Z_POINT-----------------------------------------------------------------------------$*$*
ENHANCEMENT 1 Z_IMPL. "active version
* code 1
ENDENHANCEMENT.
ENHANCEMENT 2 Z_IMPL2. "active version
* code 2
ENDENHANCEMENT.
*$*$-End: Z_POINT-----------------------------------------------------------------------------$*$*
ENHANCEMENT-SECTION z_section SPOTS z_es.
* code 3
END-ENHANCEMENT-SECTION.
*$*$-Start: Z_SECTION---------------------------------------------------------------------------$*$*
ENHANCEMENT 3 Z_IMPL3. "active version
* code 4
ENDENHANCEMENT.
*$*$-End: Z_SECTION---------------------------------------------------------------------------$*$*
If z_es is switched off, no code is active
If z_es is switched on, and only z_impl is switched on, only "code1" and "code 3" are active
If z_es is switched on, and only z_impl3 is switched on, only "code 4" is active
I got syntax error because code inside ehancement has a structures which are not recognized by the program
Could you tell us more about it, I don't understand, I think you have made a little error (show the message, and the related pieces of code).
BR
Sandra
‎2011 Mar 28 5:32 PM
Hello Sandra,
Thanks very much for your response. You are really very knowledgeable.
Here is the code that I have in source routine (T-code ïƒ VOFM ïƒ Data Transfer --> Ordersïƒ Routine 51 ). I have to copy it to the newly created target routine named 951 . Enhancement spot u201CES_SAPFV45Cu201D is active.
Begin of source code **************************
FORM DATEN_KOPIEREN_051.
IF CVBAK-VBELN IS INITIAL.
MESSAGE A247 WITH '051'.
ENDIF.
VBAK-PS_PSP_PNR = CVBAK-PS_PSP_PNR.
VBAK-GWLDT = CVBAK-GWLDT.
VBAK-SUBMI = CVBAK-SUBMI.
IF VBAK-LIFSK IS INITIAL.
VBAK-LIFSK = CVBAK-LIFSK.
ENDIF.
VBAK-AUGRU = CVBAK-AUGRU.
ENHANCEMENT-POINT DATEN_KOPIEREN_051_10 SPOTS ES_SAPFV45C.
$$-Start: DATEN_KOPIEREN_051_10----
$$
ENHANCEMENT 1 OI0_COMMON_SAPFV45C. "active version
IS-Oil enhancement "SO3K000495
Addition of pipeline fields (MAP) for defaulting header data
between sales orders. Also copies time pricing field (time) - MAP
MOVE-CORRESPONDING CVBAK TO OIC_PIPE. "so3k120207
MOVE-CORRESPONDING CVBAK TO OID_EX. "so3k120207
MOVE-CORRESPONDING OIC_PIPE TO VBAK. "so3k120207
MOVE-CORRESPONDING OID_EX TO VBAK. "so3k120207
VBAK-OICHEADOFF = CVBAK-OICHEADOFF. "SO3K115387 AWH
ENDENHANCEMENT.
$$-End: DATEN_KOPIEREN_051_10----
$$
IF VBAK-FAKSK = SPACE.
VBAK-FAKSK = CVBAK-FAKSK.
ENDIF.
VBAK-WAERK = CVBAK-WAERK.
IF TVAK-VBTYP = CHARB OR " Angebot
TVAK-VBTYP = CHARE OR " Lieferplan
TVAK-VBTYP = CHARF OR " Kontrakt
TVAK-VBTYP = CHARG. " Kontrakt
VBAK-GUEBG = CVBAK-GUEBG.
VBAK-GUEEN = CVBAK-GUEEN.
ENDIF.
VBAK-AUTLF = CVBAK-AUTLF.
IF NOT CVBAK-VDATU IS INITIAL
AND VBAK-VBTYP CN VBTYP_RETOUR
AND VBAK-VBTYP CN VBTYP_ANFO.
VBAK-VPRGR = CVBAK-VPRGR.
VBAK-VDATU = CVBAK-VDATU.
ENDIF.
Pick-up date set for delivery orders (MAIS)
IF TVAK-VBKLT EQ VBKLT_AUSL_AUFT.
IF NOT CVBAK-VDATU IS INITIAL AND
CVBAK-VPRGR EQ CHAR1.
VBAK-ABHOD = CVBAK-ABHOD.
VBAK-ABHOV = CVBAK-ABHOV.
VBAK-ABHOB = CVBAK-ABHOB.
VBAK-VDATU = CVBAK-VDATU.
VBAK-VPRGR = CVBAK-VPRGR.
ENDIF.
Proposed time set from Pick-up time
IF NOT CVBAK-ABHOV IS INITIAL.
VBAK-VZEIT = CVBAK-ABHOV.
ENDIF.
ENDIF.
VBAK-KVGR1 = CVBAK-KVGR1.
VBAK-KVGR2 = CVBAK-KVGR2.
VBAK-KVGR3 = CVBAK-KVGR3.
VBAK-KVGR4 = CVBAK-KVGR4.
VBAK-KVGR5 = CVBAK-KVGR5.
VBAK-XBLNR = CVBAK-XBLNR.
VBAK-ZUONR = CVBAK-ZUONR.
VBAK-TAXK1 = CVBAK-TAXK1.
VBAK-TAXK2 = CVBAK-TAXK2.
VBAK-TAXK3 = CVBAK-TAXK3.
VBAK-TAXK4 = CVBAK-TAXK4.
VBAK-TAXK5 = CVBAK-TAXK5.
VBAK-TAXK6 = CVBAK-TAXK6.
VBAK-TAXK7 = CVBAK-TAXK7.
VBAK-TAXK8 = CVBAK-TAXK8.
VBAK-TAXK9 = CVBAK-TAXK9.
VBAK-XEGDR = CVBAK-XEGDR.
VBAK-LANDTX = CVBAK-LANDTX.
VBAK-STCEG_L = CVBAK-STCEG_L.
VBAK-ABRVW = CVBAK-ABRVW.
if cl_ops_switch_check=>ops_sfws_sc_advret1( ) eq charx.
if gr_msr_sales is bound.
if vbak-vbtyp eq vbtyp_ganf and
cvbak-vbtyp eq vbtyp_reto.
vbak-msr_id = cvbak-msr_id.
endif.
endif.
endif.
ENHANCEMENT-POINT DATEN_KOPIEREN_051_01 SPOTS ES_SAPFV45C.
$$-Start: DATEN_KOPIEREN_051_01----
$$
ENHANCEMENT 1 ECO_HBS_SAPFV45C. "active version
IS A&D/E&C - RE-SCM: Copy Real Estate Object Data
vbak-swenr = cvbak-swenr.
vbak-smenr = cvbak-smenr.
ENDENHANCEMENT.
$$-End: DATEN_KOPIEREN_051_01----
$$
ENHANCEMENT-POINT DATEN_KOPIEREN_051_11 SPOTS ES_SAPFV45C.
$$-Start: DATEN_KOPIEREN_051_11----
$$
ENHANCEMENT 1 OIA_SAPFV45C. "active version
Copy Exchange Details, if required "SO3K015696
if TVAK-VBTYP = 'G' and cvbak-oiexgnum ne space. "SP2 KH
PERFORM OIA_COPY_EXCHANGE_VBAK. "SO3K015696
endif. "more readable/less perform.improve/same check in FORM SP2 KH
ENDENHANCEMENT.
$$-End: DATEN_KOPIEREN_051_11----
$$
ENDFORM.
End of source code *****************************************************************
I did two things. First I did just like what you have mentioned. I copied all the code except for lines ENHANCEMENT-POINT and ENHANCEMENT-SECTION. When I do syntax check I got error that u201Coic_pipeu201D and u201Coid_exu201D is unknown. It is not declared in data statement.
Then I removed the code and copied the code from source routine u2013 exactly as shown above. When I clicked u201CSaveu201D button , I got a screen u201CChange Enhancement optionu201D
I do not know
- which buttons to select and what its Impact would be.
- Enhance Point name = u201CDATEN_KOPIEREN_051_10u201D . But this name is tied to the source routine 51. Do I re-name it ?
‎2011 Mar 28 5:40 PM
Hello Sandra,
I am re-posting this because the above post is garbled up.
Thanks very much for your response. You are really very knowledgeable.
Here is the code that I have in source routine (T-code -->VOFM --> Data Transfer --> Orders --> Routine 51 ).
I have to copy it to the newly created target routine named 951 . Enhancement spot u201CES_SAPFV45Cu201D is active.
Begin of code from source routine 51 ********************************
FORM DATEN_KOPIEREN_051.
IF CVBAK-VBELN IS INITIAL.
MESSAGE A247 WITH '051'.
ENDIF.
VBAK-PS_PSP_PNR = CVBAK-PS_PSP_PNR.
VBAK-GWLDT = CVBAK-GWLDT.
VBAK-SUBMI = CVBAK-SUBMI.
IF VBAK-LIFSK IS INITIAL.
VBAK-LIFSK = CVBAK-LIFSK.
ENDIF.
VBAK-AUGRU = CVBAK-AUGRU.
ENHANCEMENT-POINT DATEN_KOPIEREN_051_10 SPOTS ES_SAPFV45C.
$$-Start: DATEN_KOPIEREN_051_10----
$$
ENHANCEMENT 1 OI0_COMMON_SAPFV45C. "active version
IS-Oil enhancement "SO3K000495
Addition of pipeline fields (MAP) for defaulting header data
between sales orders. Also copies time pricing field (time) - MAP
MOVE-CORRESPONDING CVBAK TO OIC_PIPE. "so3k120207
MOVE-CORRESPONDING CVBAK TO OID_EX. "so3k120207
MOVE-CORRESPONDING OIC_PIPE TO VBAK. "so3k120207
MOVE-CORRESPONDING OID_EX TO VBAK. "so3k120207
VBAK-OICHEADOFF = CVBAK-OICHEADOFF. "SO3K115387 AWH
ENDENHANCEMENT.
$$-End: DATEN_KOPIEREN_051_10----
$$
IF VBAK-FAKSK = SPACE.
VBAK-FAKSK = CVBAK-FAKSK.
ENDIF.
VBAK-WAERK = CVBAK-WAERK.
IF TVAK-VBTYP = CHARB OR " Angebot
TVAK-VBTYP = CHARE OR " Lieferplan
TVAK-VBTYP = CHARF OR " Kontrakt
TVAK-VBTYP = CHARG. " Kontrakt
VBAK-GUEBG = CVBAK-GUEBG.
VBAK-GUEEN = CVBAK-GUEEN.
ENDIF.
VBAK-AUTLF = CVBAK-AUTLF.
IF NOT CVBAK-VDATU IS INITIAL
AND VBAK-VBTYP CN VBTYP_RETOUR
AND VBAK-VBTYP CN VBTYP_ANFO.
VBAK-VPRGR = CVBAK-VPRGR.
VBAK-VDATU = CVBAK-VDATU.
ENDIF.
Pick-up date set for delivery orders (MAIS)
IF TVAK-VBKLT EQ VBKLT_AUSL_AUFT.
IF NOT CVBAK-VDATU IS INITIAL AND
CVBAK-VPRGR EQ CHAR1.
VBAK-ABHOD = CVBAK-ABHOD.
VBAK-ABHOV = CVBAK-ABHOV.
VBAK-ABHOB = CVBAK-ABHOB.
VBAK-VDATU = CVBAK-VDATU.
VBAK-VPRGR = CVBAK-VPRGR.
ENDIF.
Proposed time set from Pick-up time
IF NOT CVBAK-ABHOV IS INITIAL.
VBAK-VZEIT = CVBAK-ABHOV.
ENDIF.
ENDIF.
VBAK-KVGR1 = CVBAK-KVGR1.
VBAK-KVGR2 = CVBAK-KVGR2.
VBAK-KVGR3 = CVBAK-KVGR3.
VBAK-KVGR4 = CVBAK-KVGR4.
VBAK-KVGR5 = CVBAK-KVGR5.
VBAK-XBLNR = CVBAK-XBLNR.
VBAK-ZUONR = CVBAK-ZUONR.
VBAK-TAXK1 = CVBAK-TAXK1.
VBAK-TAXK2 = CVBAK-TAXK2.
VBAK-TAXK3 = CVBAK-TAXK3.
VBAK-TAXK4 = CVBAK-TAXK4.
VBAK-TAXK5 = CVBAK-TAXK5.
VBAK-TAXK6 = CVBAK-TAXK6.
VBAK-TAXK7 = CVBAK-TAXK7.
VBAK-TAXK8 = CVBAK-TAXK8.
VBAK-TAXK9 = CVBAK-TAXK9.
VBAK-XEGDR = CVBAK-XEGDR.
VBAK-LANDTX = CVBAK-LANDTX.
VBAK-STCEG_L = CVBAK-STCEG_L.
VBAK-ABRVW = CVBAK-ABRVW.
if cl_ops_switch_check=>ops_sfws_sc_advret1( ) eq charx.
if gr_msr_sales is bound.
if vbak-vbtyp eq vbtyp_ganf and
cvbak-vbtyp eq vbtyp_reto.
vbak-msr_id = cvbak-msr_id.
endif.
endif.
endif.
ENHANCEMENT-POINT DATEN_KOPIEREN_051_01 SPOTS ES_SAPFV45C.
$$-Start: DATEN_KOPIEREN_051_01----
$$
ENHANCEMENT 1 ECO_HBS_SAPFV45C. "active version
IS A&D/E&C - RE-SCM: Copy Real Estate Object Data
vbak-swenr = cvbak-swenr.
vbak-smenr = cvbak-smenr.
ENDENHANCEMENT.
$$-End: DATEN_KOPIEREN_051_01----
$$
ENHANCEMENT-POINT DATEN_KOPIEREN_051_11 SPOTS ES_SAPFV45C.
$$-Start: DATEN_KOPIEREN_051_11----
$$
ENHANCEMENT 1 OIA_SAPFV45C. "active version
Copy Exchange Details, if required "SO3K015696
if TVAK-VBTYP = 'G' and cvbak-oiexgnum ne space. "SP2 KH
PERFORM OIA_COPY_EXCHANGE_VBAK. "SO3K015696
endif. "more readable/less perform.improve/same check in FORM SP2 KH
ENDENHANCEMENT.
$$-End: DATEN_KOPIEREN_051_11----
$$
ENDFORM.
End of code from source routine 51 ********************************
I did two things. First I did just like what you have mentioned. I copied all the code except for lines ENHANCEMENT-POINT and ENHANCEMENT-SECTION. When I do syntax check I got error that u201Coic_pipeu201D and u201Coid_exu201D is unknown. It is not declared in data statement.
When above method did not work, I copied the code from source routine u2013 exactly as shown above. When I clicked u201CSaveu201D button , I got a screen u201CChange Enhancement optionu201D
- I do not know - which buttons to select and what its Impact would be.
- In theis pop-up screen Enhancement Point name = u201CDATEN_KOPIEREN_051_10u201D . But this name is tied to the source routine 51. Do I re-name it ?
Basically how do I go about copying the code ?
‎2011 Mar 28 8:24 PM
Hi Vince,
Enhancement spot u201CES_SAPFV45Cu201D is active.
It is one of the requirements but it isn't sufficient to know what code is to be copied. Check what I said above : You must also check if the enhancements are active (OI0_COMMON_SAPFV45C, ECO_HBS_SAPFV45C, and OIA_SAPFV45C) to know if you have to copy the code inside them.
When I do syntax check I got error that u201Coic_pipeu201D and u201Coid_exu201D is unknown. It is not declared in data statement.
As OIC_PIPE and OID_EX exist in OI0_COMMON_SAPFV45C enhancement, this one is probably not active.
Then I removed the code and copied the code from source routine u2013 exactly as shown above. When I clicked u201CSaveu201D button , I got a screen u201CChange Enhancement optionu201D.
I do not know
- which buttons to select and what its Impact would be.
- Enhance Point name = u201CDATEN_KOPIEREN_051_10u201D . But this name is tied to the source routine 51. Do I re-name it ?
Which code did you remove? I hope neither the one of routine 051, nor the one of the existing standard enhancements.
Well, I don't understand what you did exactly, but it seems you copied the "ENHANCEMENT-OPTION ... SPOTS ..." lines. Do not copy them.
Do as I said in my first answer. Tell me if it's not clear (and of course what is not clear and why).
Sandra
‎2011 Mar 28 9:08 PM
By the way, copying standard code is basically not a good idea as future corrections to the standard code cannot be reported automatically to the copied code. Think twice, if it's worth calling the existing routine from yours, make a modification of the standard (at least, a modification would be automatically detected during upgrade or patch, while a copy is not), or do the copy.
‎2011 Mar 28 9:25 PM
Hello Sandra,
Thanks for your quick response. I am sorry I have not been very clear.
Yes all these enhancements (OI0_COMMON_SAPFV45C, ECO_HBS_SAPFV45C, and OIA_SAPFV45C) are active.
The first thing I did was just like you had suggested. I copied only the active code without copying lines ENHANCEMENT-POINT and ENHANCEMENT-SECTION. After copying when I did syntax check, I got syntax error that u201Coic_pipeu201D and u201Coid_exu201D is unknown. It is not declared in data statement.
Then I removed all the code from the new routine 951 and made it blank. Then I copied all the code from routine 51 and pasted it to new routine 951 u2013 including lines with ENHANCEMENT-POINT and ENHANCEMENT-SECTION. When I clicked save, it displayed a screen u201CChange Enhancement Optionu201D .
I hope this is clear now.
‎2011 Mar 28 10:54 PM
very clear, Vince
In the standard code, these 2 structures are defined globally, or I understand nothing at all ! These variables are probably in another enhancement. Find them, and make sure your routine is positioned after these variables.
By the way, "active enhancement" means that the enhancement has either no switch, or the switch is on.
Something else, maybe there's a bug in the enhancement framework (or maybe the switch framework), so check the notes. Maybe you'll have to open a customer message.
Sandra
‎2011 Mar 30 5:24 PM
Hi Vince,
I checked my ECC 6.0 system, and could find that the 3 enhancements above are linked to switches OI0_COMMON_DS, ECO_HBS, OIA_EXCHANGES, which are all swtched off by default.
So, if yours are also switched off, don't copy these enhancements.
Note: if you think that one day, these switches could be switched on, then you'd better create new enhancements based on these switches... But calling the standard routine from your code, or do a little modification of the standard, is maybe a better solution.
BR
Sandra
‎2011 Mar 30 11:32 PM
Hello Sandra,
You indeed are right. Switches are turned off in my system too.
I copied all the code except the lines with Enhancements and the code inside it. Now I do not have any syntax error or any knid of box popping up.
I have tested my changes and it works.
I am quite impressed by your knowledge and appreciate your help very much ( this thing had really started bothering me ) . I have awarded you max points I could .
Could you please recommend something to read on this topic ? In past I have put code inside an existing enhancmenet point but I want to learn about the Enahncement spot/point/section /switch etc.
‎2011 Mar 30 11:49 PM
Hi Vince,
you're welcome. I recommend you to read the blogs of Thomas Weiss. You can reach them from the SDN Enhancement home page, or from the wiki http://wiki.sdn.sap.com/wiki/display/ABAP/ThenewEnhancementFrameworkandthenewkernel-basedBAdI
BR
Sandra
‎2011 Apr 01 7:17 PM
‎2012 Jul 25 3:34 PM
Hi all,
Why not just call the original routine in the copy? Like this:
FORM bedingung_pruefen_904.
PERFORM bedingung_pruefen_018.
<INSERT CODE HERE>
ENDFORM.
Regards!