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

read memory doesn't work with badi ??

Former Member
0 Likes
1,045

I had a sollution in an user exit for goods movement to read the memory of the screen since I had to check the changed data before saving.

it works perfectly so now I thought I could also use it in a badi but somehow it doesn't work and it can't read the programm memory .

this was my code from the user exit of IW42


data: global_field_name(100).
data: artikel type structure occurs 0 with header line .

DATA: BEGIN OF gt_comp OCCURS 0.
        INCLUDE STRUCTURE cowb_comp.
DATA: END OF gt_comp.

field-symbols : <fs> type any table,
                <wa> type any.



clear global_field_name.
move '(SAPLCOWB)GT_COMP[]'  to global_field_name.
assign (global_field_name) to <fs>.


* functie moet alleen werken indien het element alwaar terugmelding op gemaakt wordt een serviceorder is
* en via totale terugmelding IW42 wordt ingevoerd
if caufvd_tab-aufnr is not initial and sy-tcode EQ 'IW42'.

loop at <fs> assigning <wa>.
move <wa> to gt_comp.
if gt_comp-rsnum eq '0'.
    message ID 'ZCS' type 'E' number '001'.
endif.
endloop.

which works fantastic

now I tried to translate it to the badi and it doesn't work at all. the error <fs> is not assigned is raised. somehow the trick is differently in a badi or in a method to read something from memory

the purpose is that I only need to perform the check when the status is set to AFSL

so I try to read the structure CNJ_STAT from memory which is the programm SAPLCJWB


data: h_error type string.

data: global_field_name(100).
data: gt_cnj_stat type table of cnj_stat.

field-symbols : <fs> type any table,
                <wa> type any.



clear global_field_name.
move '(SAPLCJWB)gt_CNJ_STAT[]'  to global_field_name.
assign (global_field_name) to <fs>.

if <fs> is not initial.
loop at <fs> assigning <wa>.
move <wa> to gt_cnj_stat.
endloop.
endif.

anybody got a clue what is wrong which the assignment ?

kind regards

arthur de smidt

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
897

Give the name of the TAB in the Upper Case. Try like:


move '(SAPLCJWB)GT_CNJ_STAT[]'  to global_field_name.

Regards,

Naimesh Patel

I had a sollution in an user exit for goods movement to read the memory of the screen since I had to check the changed data before saving.

it works perfectly so now I thought I could also use it in a badi but somehow it doesn't work and it can't read the programm memory .

this was my code from the user exit of IW42


data: global_field_name(100).
data: artikel type structure occurs 0 with header line .

DATA: BEGIN OF gt_comp OCCURS 0.
        INCLUDE STRUCTURE cowb_comp.
DATA: END OF gt_comp.

field-symbols : <fs> type any table,
                <wa> type any.



clear global_field_name.
move '(SAPLCOWB)GT_COMP[]'  to global_field_name.
assign (global_field_name) to <fs>.


* functie moet alleen werken indien het element alwaar terugmelding op gemaakt wordt een serviceorder is
* en via totale terugmelding IW42 wordt ingevoerd
if caufvd_tab-aufnr is not initial and sy-tcode EQ 'IW42'.

loop at <fs> assigning <wa>.
move <wa> to gt_comp.
if gt_comp-rsnum eq '0'.
    message ID 'ZCS' type 'E' number '001'.
endif.
endloop.

which works fantastic

now I tried to translate it to the badi and it doesn't work at all. the error <fs> is not assigned is raised. somehow the trick is differently in a badi or in a method to read something from memory

the purpose is that I only need to perform the check when the status is set to AFSL

so I try to read the structure CNJ_STAT from memory which is the programm SAPLCJWB


data: h_error type string.

data: global_field_name(100).
data: gt_cnj_stat type table of cnj_stat.

field-symbols : <fs> type any table,
                <wa> type any.



clear global_field_name.
move '(SAPLCJWB)gt_CNJ_STAT[]'  to global_field_name.
assign (global_field_name) to <fs>.

if <fs> is not initial.
loop at <fs> assigning <wa>.
move <wa> to gt_cnj_stat.
endloop.
endif.

anybody got a clue what is wrong which the assignment ?

kind regards

arthur de smidt

5 REPLIES 5
Read only

naimesh_patel
Active Contributor
0 Likes
898

Give the name of the TAB in the Upper Case. Try like:


move '(SAPLCJWB)GT_CNJ_STAT[]'  to global_field_name.

Regards,

Naimesh Patel

Read only

0 Likes
897

nop that didn't work.

but I figured it out finally since I saw in debugging the global vars and the values of CNJ_STAT I saw that the defenition was a flat structure although I would have thouught a table would be the case.

so with this coding it works now



field-symbols : <fs> type any table,
                <wa> type any.



clear global_field_name.
move '(SAPLCJWB)CNJ_STAT'  to global_field_name.
assign (global_field_name) to <wa>.

thanks for the input

arthur

Read only

Former Member
0 Likes
897

i can see here one

'(SAPLCJWB)gt_CNJ_STAT[]'

Try this way.use all caps.

'(SAPLCJWB)GT_CNJ_STAT[]'

Read only

Former Member
0 Likes
897

Hi,

Please do it in this way.


FIELD-SYMBOLS: <FS> TYPE ANY.
ASSIGN(')SAPLCTJDW)PSTAB') TO <FS>.

Thanks,

Chidanand

Read only

0 Likes
897

why is that the way to do it Chidanand Chauhan ? is there a reference somewhere where the recomended coding is described ??

kind regards

arthur de smidt