2015 Jul 29 5:36 PM
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.
Which release you are referring to? I know it is not recommended but it sometime serves the purpose.
2015 Jul 29 7:51 PM
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.
2015 Jul 29 8:06 PM
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.
2015 Jul 30 1:48 PM
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.
2015 Jul 30 2:01 PM
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
2015 Jul 30 2:03 PM
2015 Jul 30 2:59 PM
Hi Marc,
Can you see the program : SAPMP56T
Include : MP56TTOP_3000
in this include it is declared.
Regards,
Ramjee M.
2015 Jul 30 3:01 PM
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.
2015 Jul 30 4:39 PM
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
2015 Jul 30 4:51 PM
Note that reading from the stack doesn't always work in recent releases -- I think SAP patched it out as a security concern?
2015 Jul 30 4:56 PM
Which release you are referring to? I know it is not recommended but it sometime serves the purpose.
2015 Jul 30 5:01 PM
Especially, linked blog post: http://www.dataxstream.com/2009/08/use-abap-to-access-any-data-in-memory/
2015 Jul 30 5:17 PM
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
2015 Jul 30 5:31 PM
I guess you are right, if SAP decide to patch up the stack-pointing technique, a lot of programs will stop working
2015 Jul 30 3:23 PM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |