cancel
Showing results for 
Search instead for 
Did you mean: 

​RAP: is it possible to immediately change the value of non-editable field with determination?

ajmartins1
Explorer
0 Kudos

RAP: is it possible to immediately change the value of non-editable screen field with determination?

I am following the learning (https://learning.sap.com/learning-journey/acquire-core-abap-skills/adding-abap-logic_eb483817-4954-44a6-9551-c3214778b5d1), and i noted that the screen value of non-editable fields do not change after determination call, even on determination on save or on modify. (only change after save).

Is there a way to do that? if yes, i aprreciate know how ..

code1:

determination GetCities1 on modify { field AirportFromID, AirportToID; }

side effects

{

field AirportFromID affects field CityFrom, field CountryFrom;

}

code2:

GetCities1 FOR DETERMINE ON MODIFY

IMPORTING keys FOR Connection~GetCities1.

...

METHOD GetCities1.

"Determine the Cities and Countries

"Read the user input using an EML READ ENTITIES statement. Read the fields AirportFromID and AirportToID.

READ ENTITIES OF z_r_ajm_conn IN LOCAL MODE

ENTITY Connection

FIELDS ( AirportFromID AirportToID )

WITH CORRESPONDING #( keys )

RESULT DATA(connections).

LOOP AT connections INTO DATA(connection).

CLEAR: connection-CityFrom, connection-CountryFrom.

CLEAR: connection-CityTo, connection-CountryTo.

SELECT SINGLE

FROM /DMO/I_Airport

FIELDS city, CountryCode

WHERE AirportID = @connection-AirportFromID

INTO ( @connection-CityFrom, @connection-CountryFrom ).

SELECT SINGLE

FROM /DMO/I_Airport

FIELDS city, CountryCode

WHERE AirportID = @connection-AirportToID

INTO ( @connection-CityTo, @connection-CountryTo ).

MODIFY connections FROM connection.

ENDLOOP.

DATA connections_upd TYPE TABLE FOR UPDATE z_r_ajm_conn.

connections_upd = CORRESPONDING #( connections ).

MODIFY ENTITIES OF z_r_ajm_conn IN LOCAL MODE

ENTITY Connection

UPDATE

FIELDS ( CityFrom CountryFrom CityTo CountryTo )

WITH connections_upd

REPORTED DATA(reported_records).

reported-connection = CORRESPONDING #( reported_records-connection ).

ENDMETHOD.

View Entire Topic
JessieCheah
Product and Topic Expert
Product and Topic Expert

Hi Anderson,

can you try using side effects? Something like

side effects {
    field AirportFromID affects field CityFrom, field CountryFrom;
  }

You can find an example here https://github.com/SAP-samples/abap-platform-fiori-feature-showcase/wiki/Feature-Showcase-App-Guide#...

Regards,

Jessie

ajmartins1
Explorer
0 Kudos

i tried, but did not work...

Do i have to use some specific code on determination ?

take a look on my code:

...

determination GetCities1 on modify { field AirportFromID, AirportToID; }

side effects

{

field AirportFromID affects field CityFrom, field CountryFrom;

}

...

and

...

,

GetCities1 FOR DETERMINE ON MODIFY

IMPORTING keys FOR Connection~GetCities1

...

METHOD GetCities1.

"Read the user input using an EML READ ENTITIES statement. Read the fields AirportFromID and AirportToID.

READ ENTITIES OF z_r_ajm_conn IN LOCAL MODE

ENTITY Connection

FIELDS ( AirportFromID AirportToID )

WITH CORRESPONDING #( keys )

RESULT DATA(connections).

LOOP AT connections INTO DATA(connection).

CLEAR: connection-CityFrom, connection-CountryFrom.

CLEAR: connection-CityTo, connection-CountryTo.

SELECT SINGLE

FROM /DMO/I_Airport

FIELDS city, CountryCode

WHERE AirportID = @connection-AirportFromID

INTO ( @connection-CityFrom, @connection-CountryFrom ).

SELECT SINGLE

FROM /DMO/I_Airport

FIELDS city, CountryCode

WHERE AirportID = @connection-AirportToID

INTO ( @connection-CityTo, @connection-CountryTo ).

MODIFY connections FROM connection.

ENDLOOP.

DATA connections_upd TYPE TABLE FOR UPDATE z_r_ajm_conn.

connections_upd = CORRESPONDING #( connections ).

MODIFY ENTITIES OF z_r_ajm_conn IN LOCAL MODE

ENTITY Connection

UPDATE

FIELDS ( CityFrom CountryFrom CityTo CountryTo )

WITH connections_upd

REPORTED DATA(reported_records).

reported-connection = CORRESPONDING #( reported_records-connection ).

ENDMETHOD.

BR

AndersonJM

JessieCheah
Product and Topic Expert
Product and Topic Expert

Hi Anderson,

sorry for the late reply, I had to play around internally to find out what works and not.

Well, if you have a determination on save, side effects will not work at all, since determination will only be triggered when you click save.

However since you have a determination on modify, side effects should be fired when you click on another field or tab out.

Do you have a projection layer/view? Then in your projection BDEF you would also need to add the following at the top, after keywords projection; and/or strict;

use side effects;

Regards,

Jessie

ajmartins1
Explorer

Tks Jessie! Now it works !!

BR!

AndersonJM