04-25-2008 5:01 PM
An option to pulll a variable into a user exit that otherwise would be out of reach is detailed [here|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/208811b0-00b2-2910-c5ac-dd2c7c50c8e8]
Can a similar approach involving field symbols or otherwise, be used to pull in the attributes of a class into the exit? For now, I'm trying to access the A_FRONTEND_INDEX attribute of the class CL_HRXSS_REM.
any ideas?
~Suresh
04-26-2008 2:29 PM
Hi,
Have you already tried (PROGRAM)(OBJECT)->A_FRONTEND_INDEX in your code? I prepared small testing scenario with two programs and it works.
REPORT zmv_test1.
FORM test.
FIELD-SYMBOLS: <fs> TYPE ANY.
ASSIGN '(ZMV_TEST2)zip->crc32_map' TO <fs>.
IF sy-subrc EQ 0.
<fs> = 'Test'.
ENDIF.
ENDFORM. "test
REPORT zmv_test2.
DATA: zip TYPE REF TO cl_abap_zip.
START-OF-SELECTION.
CREATE OBJECT zip.
PERFORM test IN PROGRAM zmv_test1.
Cheers,
04-26-2008 2:29 PM
Hi,
Have you already tried (PROGRAM)(OBJECT)->A_FRONTEND_INDEX in your code? I prepared small testing scenario with two programs and it works.
REPORT zmv_test1.
FORM test.
FIELD-SYMBOLS: <fs> TYPE ANY.
ASSIGN '(ZMV_TEST2)zip->crc32_map' TO <fs>.
IF sy-subrc EQ 0.
<fs> = 'Test'.
ENDIF.
ENDFORM. "test
REPORT zmv_test2.
DATA: zip TYPE REF TO cl_abap_zip.
START-OF-SELECTION.
CREATE OBJECT zip.
PERFORM test IN PROGRAM zmv_test1.
Cheers,
04-26-2008 8:50 PM
It works fine in the classical programs.. I need to use a similar concept in the OO context.. ie access a variable ( attribute) of a Class..
~Suresh
04-26-2008 11:35 PM
I knew that it had to be something different. I had similar problem while ago. I think it is impossible. I found this pdf.
[url]https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15[url]
There are some restrictions when you work inside the class. One of these restrictions is:
Memory Accesses - No access to memory outside a data object.
Cheers
04-28-2008 2:42 PM
Impossible? I'm leaving this thread open hoping for a workaround..
~Suresh
04-28-2008 3:02 PM
This is interesting, because when discovering the field symbols trick to access a variable in the call stack, I was super excited. The reason was it allowed me to do some very nice things in order entry without too much of an issue. But at the same time, I kind of felt bad about it. Why? Because I should not have been allowed to do it. I then saw this as a weakness in ABAP, and of course only used it when I abolutly had to. That said, you have to realize that ABAP Objects was introduced to "fix" these types of weaknesses. OO by design, encapulates your data, and specific sections(public, private, and protected) and are only exposed(by the developer) if he really wants you to have access to it. Otherwise you would access it by some GET/SET method. With that said, if you were allowed to access this same attribute using a field symbol, anywhere in the call stack, then there would be absolutly no sense in using the OO concept to begin with. Right?
Regards,
Rich Heilman
04-29-2008 6:33 AM
Hello Suresh
I tried to apply the same trick I previously described in [Accessing the Inacessible - Local Classes within Global Classes|https://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses].
However, while this trick works for public attributes it fails for private attributes which is a relief with respect to Rich's remarks.
Regards
Uwe
04-29-2008 9:50 AM
You can use the enhancement concept, however, to create getter and setter methods which retrieve and set private/protected attributes.
matt
04-29-2008 1:11 PM
@ Rich, Uwe & Matt: Thanks for your valuable inputs..
I got lucky in this particular instance.. I was able to EXPORT the the variable to memory from a BAdI & IMPORT it inside a routine in a SMARTFORM.. the reqt was to use a different logo on the paystub based on the company (an employee is in for the pay period in question..)
Anyway, it is good to know what is 'private' remains so, after all..
~Suresh