‎2009 Mar 24 3:14 PM
Hi,
I'm trying to get a reference to a table which was passed to a user-exit function module (EXIT_SAPLMCI1_001, btw). The table is needed in a FORM routine and should be modified there.
Currently I'm using the following code:
FIELD-SYMBOLS:
<fs_tab> TYPE standard table
.
DATA:
ref TYPE REF TO data
.
CREATE DATA ref LIKE i_mcipmb.
GET REFERENCE OF i_mcipmb[] INTO ref.
ASSIGN ref->* TO <fs_tab>.
which works fine so far. Field symbol <fs_tab> now has got the passed records from table i_mcipmb.
Now I'm trying this coding:
LOOP AT <fs_tab> where supkz = '2'.
ENDLOOP.
which fails because it doesn't recognize <fs_tab> as a structure. The same applies when using coding like this:
READ TABLE <fs_tab> INTO wa_mcipmb WITH KEY SUPKZ ='2'.
Is it possible at all to get this running? If so how can I solve this?
Thanks,
Michael
‎2009 Mar 24 6:15 PM
Here is something that may work, which is very similar to your original idea:
FIELD-SYMBOLS:
<fs_tab> like i_mcipmb[]. " Table structure must be defined
DATA:
ref TYPE REF TO data.
CREATE DATA ref LIKE i_mcipmb.
GET REFERENCE OF i_mcipmb[] INTO ref.
ASSIGN ref->* TO <fs_tab>.
followed by
FIELD-SYMBOLS: <fs_row>.
LOOP AT <fs_tab> assigning <fs_row> where supkz = '2'.
ENDLOOP.
best wishes
Ed
‎2009 Mar 24 3:20 PM
I am not sure but have a try when you are trying to looping in the field-symbol, use a work area, as you have defined it as standard table, so I am assuming there is no header line is there for this field-symbols.
Kuntal
‎2009 Mar 24 3:34 PM
Kuntal,
yes, you are correct, there is no header line and I cannot add one to the field symbol at all.
Using this additional coding
DATA:
wa TYPE mcipmb
.
LOOP AT <fs_tab> INTO wa.
IF wa-supkz = '2'.
EXIT.
ENDIF.
ENDLOOP.
works of course, but results in some extra coding like this one and much more at some other places in the user exit.
I would prefer something like this:
READ TABLE <fs_tab> WITH KEY supkz = '2'.Btw, the purpose of this coding is that I can modify the table data of i_mcipmb without doing too much copying from the source tables to an internal tables and vice versa inside the numerous FORM routines I would like implement. I'm searching for a solution to work on the original table data which was passed in.
‎2009 Mar 24 3:40 PM
‎2009 Mar 24 3:26 PM
FIELD-SYMBOLS <t_mci> LIKE i_mcipmb.
loop at <t_mci> where supkz = '2'.
endloop.
‎2009 Mar 24 3:38 PM
J@Y,
this will not work either since <t_mci> is not defined as an internal table and without any reference to the original table i_mcipmb it wouldn't contain any original records.
‎2009 Mar 24 3:42 PM
>
> J@Y,
>
> this will not work either since <t_mci> is not defined as an internal table and without any reference to the original table i_mcipmb it wouldn't contain any original records.
I tired a similar thing before in ZXBPFCU01 in EXIT_SAPLBPFC_001. ( well I am using a line of it though)
FIELD-SYMBOLS <t_mail_receivers> LIKE LINE OF t_mail_receivers.
LOOP AT t_mail_receivers ASSIGNING <t_mail_receivers>.
..
..
enloop.
‎2009 Mar 24 3:53 PM
J@Y,
I tired a similar thing before in ZXBPFCU01 in EXIT_SAPLBPFC_001. ( well I am using a line of it though)
Yes, this will work if your loop is inside include ZXBPFCU01, as I had before (in include ZXMCIU01), however we constantly added coding to this exit and it got a little bit complex after a while. So we decided to use FORMs in one of the available customer includes (ZXMCIZZZ).
Unfortunately you cannot use FORM routines between (the user exit) FUNCTION and ENDFUNCTION, so we had to move them into separate includes. Now we need access to the passed function parameters of course and that's why I'm posting here, searching for a solution.
‎2009 Mar 24 4:01 PM
I did not test it..
*&---------------------------------------------------------------------*
*& Include ZXMCIU01
*&---------------------------------------------------------------------*
PERFORM fr_change TABLES i_mcipmb. " can add using and changing parameters as wellFORM fr_change TABLES p_mcipmb STRUCTURE mcipmb. " can pull using and changing parameters
FIELD-SYMBOLS: <fs> TYPE mcipmb.
LOOP AT p_mcipmb ASSIGNING <fs>.
ENDLOOP.
ENDFORM. " FR_CHANGEHope this helps..
‎2009 Mar 24 3:31 PM
LOOP AT <fs_tab> assigning <wa_tab>.
assign component 'SUPKZ' of structure <wa_tab> to <fs1>.
if <fs1> eq '2'.
" do validation
endif.
ENDLOOP.
a®
‎2009 Mar 24 3:46 PM
a®s
LOOP AT <fs_tab> assigning <wa_tab>. assign component 'SUPKZ' of structure <wa_tab> to <fs1>. if <fs1> eq '2'. " do validation endif. ENDLOOP.
This would certainly do the job but I need to modify some more fields in table i_mcipmb, and believe me there are plenty of them. Accessing those fields, using your proposed coding, is a little bit overhead.
Thanks for your suggestion!
‎2009 Mar 24 6:15 PM
Here is something that may work, which is very similar to your original idea:
FIELD-SYMBOLS:
<fs_tab> like i_mcipmb[]. " Table structure must be defined
DATA:
ref TYPE REF TO data.
CREATE DATA ref LIKE i_mcipmb.
GET REFERENCE OF i_mcipmb[] INTO ref.
ASSIGN ref->* TO <fs_tab>.
followed by
FIELD-SYMBOLS: <fs_row>.
LOOP AT <fs_tab> assigning <fs_row> where supkz = '2'.
ENDLOOP.
best wishes
Ed
‎2009 Mar 24 6:25 PM
FIELD-SYMBOLS: <fs_row>. LOOP AT <fs_tab> assigning <fs_row> where supkz = '2'. ENDLOOP.
Ed,
I think while activating it may get an error that SUPKZ not found or not defined. due to will be defined only on runtime
Am I wrong please correct me.
a®
‎2009 Mar 24 6:41 PM
Hi! Thanks for your comment. The following example using the same pattern activates and runs OK...
report zsdn_example.
data: begin of gt_sflight occurs 0.
include structure sflight.
data: end of gt_sflight,
gs_sflight type sflight,
ref type ref to data.
field-symbols:
<fs_row> type sflight,
<fs_tab> like gt_sflight[].
select * from sflight client specified into table gt_sflight.
create data ref like gt_sflight[].
get reference of gt_sflight[] into ref.
assign ref->* to <fs_tab>.
loop at <fs_tab> assigning <fs_row> where carrid = 'AA'.
write:
/ <fs_row>-carrid.
endloop.
best wishes
Ed
‎2009 Mar 24 6:47 PM
Ed, You are right
create data ref like gt_sflight[].
get reference of gt_sflight[] into ref.
Here ref pointing to standard table this will work
Thanks for example
a®
‎2009 Mar 25 8:01 AM
Ed,
thanks for your coding and assistance! Your example works exactly the way I wanted to.
@all, thanks for reading and commenting.