2008 Aug 04 6:54 PM
Hey Gurus,
How do I get a variable, or object from ABAP STACK.
Example: I start my FM. I can see in the ABAP STACK the variable I need. I can see the object; I could use to get my variable. I need to use it in my FM; however I need to reference it in the run time. How do I do that?
Is there a method I can use for reading ABAP STACK?
Do I just use command: get reference of u2026?
Does anyone have an example code?
Basis version 7
Thanks in advance
Martin
2008 Aug 04 7:09 PM
Have you checked fm SYSTEM_CALLSTACK ?
You can find few threads in the forum related to this. please make a search in SYSTEM_CALLSTACK
a®
2008 Aug 04 7:09 PM
Have you checked fm SYSTEM_CALLSTACK ?
You can find few threads in the forum related to this. please make a search in SYSTEM_CALLSTACK
a®
2008 Aug 04 7:15 PM
Ah, you mean you want to access a variable from another program in the call stack, yes? You can do this using field symbols, but please don't try to change a value while doing this, it could really screw things up.
this example, is using two programs, where the second is accessing variables of the first program. Basically just notice that we are using the program name and the variable name when assigning the field symbol.
report zrich_0006 .
tables: mara.
parameters: p_matnr type mara-matnr..
data: matnr type mara-matnr.
data: imarc type table of marc with header line.
matnr = p_matnr.
select * from marc into table imarc up to 10 rows
where matnr = p_matnr.
perform in in program zrich_0007.
report zrich_0007 .
*---------------------------------------------------------------------*
* FORM in *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form in.
data: field(50).
data: xmarc type marc.
field-symbols: <matnr>.
field-symbols: <imarc> type marc_upl_tt.
* Assign an individual variable
field = '(ZRICH_0006)matnr'.
assign (field) to <matnr>.
* Assign an internal table
field = '(ZRICH_0006)IMARC[]'.
assign (field) to <imarc>.
* Write out your data
write <matnr>.
loop at <imarc> into xmarc.
write: / xmarc-werks.
endloop.
endform.
Regards,
Rich Heilman
2008 Aug 04 7:28 PM
Rich,
I have question for you please.
if IN form is in a function group, then whether if we called
perform in in program zrich. " Function group main program
Whether it will work?
a®
2008 Aug 04 7:37 PM
I think it would since I have done something simular in the past. For example, there was a user exit, and of course the implementation was in an INCLUDE which was inside of a function module, I needed access to some variable at a higher level function call, so I used this same thing and pointed to the variable of the main program of the function group.
Regards,
Rich Heilman
2008 Aug 04 8:25 PM
Hey Gurus
Thanks for the quick response.
I see I did not write everything. Sorry.
To explain my problem:
This is a BW object call InfoSpoke. The InfoSpoke collects data from BW and places them in a csv on the file system. There is no way to create the file name dynamically in the InfoSpoke self. You can assign a logical file, but for each InfoSpoke one u2013 and imagine I have 200+ of them. So I am trying to create the file name dynamically by a FM. The FM u2018justu2019 needs to find which InfoSpoke called the FM and return the name of it.
This FM, which I use is a customer exit for logical file /TX: FILE/.
During debug I found that right after the PAI module an object is created, which is used during the entire process of data retrieval and save.
Now I either reference the object self and then use one of the methods available, or I directly reference one of the variables.
But I do not know how to assign/reference the object/variable.
Rich, the assignment you are using. Well, you know that the ZRICH_0006 calls the ZRICH_0007 and thus can assign ZRICH_0006 variables in the ZRICH_0007. However I do not, as the program is generated at run time.
I need to define a variable/object, which will be known at run time. Then I need to assign the values in call stack to this variable/object.
aRs, the SYSTEM_CALLSTACK returns the list of methods, but I need the variable/object which is used in side these methods. The list of the used methods, does not help much.
Martin
2008 Aug 04 9:05 PM
Martin,
I think you have 2 options
1. Try to use EXPORT/IMPORT
http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3bde358411d1829f0000e829fbfe/content.htm
2. Write the dynamic file name in a custom table with unique in the userexit and read it whenever you need using infospoke id.
( I will not suggest for second option)
a®
2008 Aug 05 1:03 PM
a®s,
How do I IMPORT from ABAP STACK, please?
Example:
I have the method: CL_RSB_... The method has a variable: lv_var.
I cannot add an EXPORT to ID 'XXX' to the method.
Thanks
Martin
Thursday
Thank you for the constructive and valuable instructions. Works well!
2008 Aug 07 12:21 PM