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

Implicit enhancement access to standard program variables

Former Member
0 Likes
5,337

Hi Experts,

I have created implicit enhancement for one of the my requirement.

So my requirement is i need to use the index LINE(Shown below in red colour) from the standard code of the program, in debugging it is showing the correct index but when i am going to use same index  it is  showing the error like "LINE is unknown".

Please refer attached screenshot for your reference.

ENHANCEMENT 1  ZENH_VIEWED_INDICATOR.    "active version

data : lv_pernr    type PTP00-PERNR,

         lv_REINR type ptp00-REINR,

        wa_PTRV_SREC TYPE PTRV_SREC,

        wa_beleg TYPE ptk03,

        lv_line TYPE i .

  CLEAR: wa_ptrv_srec,

         wa_beleg,

         lv_line,

         lv_cursor_field_1301.

*  lv_line = Line.

*READ TABLE beleg INTO wa_beleg INDEX lv_line.

  select *

    FROM PTRV_SREC

    into wa_ptrv_srec

   where pernr eq ptp00-pernr

     and reinr eq ptp00-reinr.

  ENDSELECT.

    IF sy-subrc eq 0.

      wa_ptrv_srec-viewed = 'X'.

      UPDATE PTRV_SREC SET viewed  = 'X'

       WHERE pernr eq ptp00-pernr

         and reinr eq ptp00-reinr.

    ENDIF.

Please help me out from this issue.

Thanks in advance.

Regards,

Ramjee M.

I guess you are right, if SAP decide to patch up the stack-pointing technique, a lot of programs will stop working

14 REPLIES 14
Read only

Former Member
0 Likes
4,198

Hey. Just check the work area type and see if it is compatible. Also, if the index (LINE) is less than the idx no. of the entry in the table being read or the Index (LINE) is null (0). The command will fail. Please validate it will work.

Read only

Former Member
0 Likes
4,198

Ramjee,

I guess its probably because of where you have placed your enhancement object.

In the example below, you can add you enhancement at 2 places.

1. Just before the endform

2. After the endform statement.

If you add your enhancement after the the endform statement (the one marked as '2'), you will not have access to the variables that were local to the form. On the other hand if you create your enhancement at the first place, you will have access to local variables of the routine.

V.

Read only

Former Member
0 Likes
4,198

Hi vikram,

Thanks for the reply.

I am using like below

when i am going to use index LINE ,i am getting the error LINE is Unknown ,but in debugging i am getting the correct index

Regards,

Ramjee M.

Read only

0 Likes
4,198

I wonder how you are debugging your implicit enhancement code without getting rid of syntax error and activating your code first.

The "LINE" variable may not be in the scope of your class lcl_arc_display.

It would be easier to know if you would give us some more details like where the method is called, where you are seeing the "LINE" variable etc.

R

Read only

Former Member
0 Likes
4,198

Where is the variable LINE defined?

Read only

Former Member
0 Likes
4,198

Hi Marc,

Can you see the program : SAPMP56T

Include                           : MP56TTOP_3000

in this include it is declared.

Regards,

Ramjee M.

Read only

Former Member
0 Likes
4,198

Hi rudra,

It is activated but in this particular screenshot i have uncommented LV_line = line which is in yellow colour,in this case when i am going to activate it showing the error like " LINE is unknown"

Regards,

Ramjee M.

Read only

0 Likes
4,198

As I said and couple of others already said, it is a problem with scope of the variable . Unfortunately that cannot be changed.

So only option could be read it from stack.

Search in internet and you will find lots of example on how to read variable from stack.

e.g :

field-symbols : <f1> type any.

assign '(SAPMP56T)LINE' to <f1>.


if <f1> IS ASSIGNED.

lv_line = <f1>.

endif.


Check if it works.


R

Read only

0 Likes
4,198

Note that reading from the stack doesn't always work in recent releases -- I think SAP patched it out as a security concern?

Read only

0 Likes
4,198

Which release you are referring to? I know it is not recommended but it sometime serves the purpose.

Read only

0 Likes
4,198

See this old post:

Especially, linked blog post: http://www.dataxstream.com/2009/08/use-abap-to-access-any-data-in-memory/

Read only

0 Likes
4,198

Thanks for sharing.

But these are not released notes. As I said already it is not recommended specially when you change the variable .

The first link case is different to this case.

and the second one if you are referring to the comment by Thomas Jung. I agree with him. He is saying the same thing that I am saying. Again it is not recommended.

The reason I am arguing, there are lots of places in the entire globe where people have used this technique already as there were no other options available

But yes I agree, implement enhancement spot can be a better alternative if you can use it. But sometimes you can't use it . E.G. MODULE code in Dialogue programming.

R

Read only

0 Likes
4,198

I guess you are right, if SAP decide to patch up the stack-pointing technique, a lot of programs will stop working

Read only

Former Member
0 Likes
4,198

Essentially this is an issue of scope. You are trying to call a variable from inside the method call that is not seen within the enhancement. Can you show us where the method is called?

You may be able to create an enhancement before the method call to export the variable LINE to memory.

You can then import the variable from memory inside the method call.

Reading Data Objects from Memory - ABAP Programming (BC-ABA) - SAP Library