on 10-23-2023 3:09 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
73 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.