05-10-2006 3:23 PM
Hi,
Can this be done, I can read the value of a field in program A from program B using field symbols, but I need to update it.
Thanks
Martin
05-10-2006 3:26 PM
05-10-2006 3:27 PM
Martin,
As you have assigned the variable to a field symbols, you assign a new value to the field symbols, the same will reflect in the variable.
however, the variable should be active in memory else the ASSIGN to field symbols will fail
Regards,
Ravi
Note : please mark the helpful answers
05-10-2006 3:29 PM
Hi,
Basically, the program needs to be executed to update a value.. so you can SUBMIT Program A from Program B.. Do an F1 on SUBMIT and there are a bunch of options with this statement..
Regards,
Suresh Datti
05-10-2006 3:36 PM
I'm testing this and it is not working.
Program 1.
report zrich_0001 .
data: this_value(10) type c.
start-of-selection.
submit zrich_0002 and return.
write:/ this_value.
Program 2
report zrich_0002 .
field-symbols: <fs>.
data: field(30) type c.
start-of-selection.
field = '(ZRICH_0001)this_value'.
assign (field) to <fs>.
<fs> = 'A Value'.
Regards,
Rich Heilman
05-10-2006 3:56 PM
You may be able to do something like this. It is working for me.
Program 1
report zrich_0001 .
data: val(10) type c value '1234'.
start-of-selection.
export val = val to memory id 'ZRICH_TEST'.
submit zrich_0002 and return.
import val = val from memory id 'ZRICH_TEST'.
write:/ val.
Program 2
report zrich_0002 .
data: val(10) type c.
start-of-selection.
import val = val from memory id 'ZRICH_TEST'.
val = 'New Value'.
export val = val to memory id 'ZRICH_TEST'.
Regards,
Rich Heilman
05-11-2006 8:37 AM
In my case though program 2 is a standard SAP program. Also it is actuall an object I am changing not a field.
Thanks
Martin
05-11-2006 8:41 AM
Hai Martin
1)
Defining a Field Symbol
FIELD-SYMBOLS <FS>.
Variable for later use
DATA FIELD VALUE 'X'.
Assigning a field to a Field Symbol
ASSIGN FIELD TO <FS>.
Using a Field Symbol which has an assigned field
WRITE <FS>.
2)
DATA: EXTERNAL_RECORD(4000),
POSITION TYPE I,
LENGTH TYPE N.
FIELD-SYMBOLS <ENTRY>.
EXTERNAL_RECORD = '0005Smith0007Edwards0005Young'.
DO.
LENGTH = EXTERNAL_RECORD+POSITION(4).
IF LENGTH = 0.
EXIT.
ENDIF.
ADD 4 TO POSITION.
ASSIGN EXTERNAL_RECORD+POSITION(LENGTH) TO <ENTRY>.
WRITE <ENTRY>.
ADD LENGTH TO POSITION.
IF POSITION >= 4000.
EXIT.
ENDIF.
ENDDO.
3)
Table work area for later use
TABLES CUSTOMERS.
Defining a Field Symbol
FIELD-SYMBOLS <OUTPUT>.
Displaying all fields of all table entries
SELECT * FROM CUSTOMERS.
NEW-LINE.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE CUSTOMERS TO <OUTPUT>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE <OUTPUT>.
ENDDO.
ENDSELECT.
Thanks & Regards
Sreenivasulu P