Application Development 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: 

Update a field in program A from program B

Former Member
0 Kudos

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

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Is one calling the other? If so, I think you can do this with field symbols.

Regards,

Rich Heilman

Former Member
0 Kudos

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

suresh_datti
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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