on 10-11-2005 9:43 AM
Hi All,
With ASSIGN COMPONENT it's possible to do a 'horizontal' read from a structure. I'm looking for a solution to put back (the changed) value in the 'source' field.
Example :
LOOP AT itab.
DO x TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_structure TO <f1>.
IF sy-subrc ne 0. continue. ENDIF.
new_value = <f1> + 1.
how to get this changed value back in original source field (wa_structure-field_x)
...
ENDDO.
ENDLOOP.
Thanks,
Rob Makelaar
The Netherlands
How simple can it be !
Thank you, Max and Svetlin. I'll devide the points between the two of you.
Once again thank you.
Rob Makelaar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
See my code for the real problem :
LOOP AT tab.
MOVE-CORRESPONDING tab TO wa_convert.
DO 13 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_convert TO <f1>.
IF sy-subrc NE 0.
EXIT.
ELSE.
<b>value_in = <f1>.</b> CLEAR value_out.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = tab-matnr
i_in_me = tab-meins
i_out_me = 'KG'
i_menge = value_in
IMPORTING
e_menge = <b>value_out</b>
EXCEPTIONS
error_in_application = 1
error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
I can't do a call of a FM with a field-symbol, so i must transfer it to a 'help' variable. At this point i'm loosing track of the source field. Any suggestions ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
LOOP AT tab.
MOVE-CORRESPONDING tab TO wa_convert.
DO 13 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_convert TO <f1>.
IF sy-subrc NE 0.
EXIT.
ELSE.
value_in = <f1>. CLEAR value_out.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = tab-matnr
i_in_me = tab-meins
i_out_me = 'KG'
i_menge = value_in
IMPORTING
e_menge = value_out
EXCEPTIONS
error_in_application = 1
error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
<i><f1> = value_out.
enddo.
MODIFY tab FROM wa_convert.
endloop.</i>
or
declare the field symbol as
field-symbols <F1> type EKPO-MENGE.
Svetlin
P.S. Please assign reward points for helpful answers.
Message was edited by: Svetlin Rusev
DATA: VALUE_IN LIKE EKPO-MENGE,
VALUE_OUT LIKE EKPO-MENGE.
LOOP AT TAB.
MOVE-CORRESPONDING TAB TO WA_CONVERT.
DO 13 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE WA_CONVERT TO <F1>.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
VALUE_IN = <F1>. CLEAR VALUE_OUT.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
I_MATNR = TAB-MATNR
I_IN_ME = TAB-MEINS
I_OUT_ME = 'KG'
I_MENGE = VALUE_IN
IMPORTING
E_MENGE = VALUE_OUT
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
MOVE VALUE_OUT TO <F1>.
ENDIF.
ENDDO.
ENDLOOP.
If you're sure the field (assigned to field-symbol) is always like EKPO-MENGE, you can try to do this:
FIELD-SYMBOLS: <FS_MENGE> LIKE EKPO-MENGE.
LOOP AT TAB.
MOVE-CORRESPONDING TAB TO WA_CONVERT.
DO 13 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE WA_CONVERT TO <FS_MENGE>.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
I_MATNR = TAB-MATNR
I_IN_ME = TAB-MEINS
I_OUT_ME = 'KG'
I_MENGE = <FS_MENGE>
IMPORTING
E_MENGE = <FS_MENGE>
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDDO.
ENDLOOP.
Max
Message was edited by: max bianchi
Stephan,
Here's the problem : I have a structure with 100 values. For 40 of them, i must do a conversion to KG's with a function module. 40 times a call with 'hard-coded' the name of the field is a possibility. But with assign component its much smaller.
Regards,
Rob Makelaar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hI rOB?
Why just don't you do
<fs1> = <fs1> + 1 .
is that what you ask...
regards,
If you find my answer rellevant, please don't forget the reward
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.