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: 

Automatically update the ZTABLE

former_member806481
Participant
0 Kudos
746

I have created a z table which contains the users validity date.

my requirement is whenever i change this validity date in SU01 transaction the value in the z table should also be changed automatically.

Thank you,

1 ACCEPTED SOLUTION

former_member806481
Participant
0 Kudos
658

Actually i figured it out my self

I created a report and exectued it as a background job for every 1 min (because i wanted to test it quickly).

Here is the code that i have written.

DATA : lt_appid TYPE TABLE OF ztptp_w01_cde_v.
DATA : lt_subappid TYPE TABLE OF ztptp_w01_cde_v.
DATA : ls_appid TYPE ztptp_w01_cde_v.
DATA : ls_subappid TYPE ztptp_w01_cde_v.

*& Main Approver------------------------------------------------------*
SELECT * FROM ztptp_w01_cde_v INTO CORRESPONDING FIELDS OF TABLE @lt_appid.
LOOP AT lt_appid INTO ls_appid.
SELECT SINGLE gltgv,
gltgb
FROM usr02
INTO @DATA(ls_usr02)
WHERE bname = @ls_appid-zappuid.
*
IF ls_usr02-gltgv <> ls_appid-vsdate.
CLEAR ls_appid-vsdate.
ls_appid-vsdate = ls_usr02-gltgv.
APPEND ls_appid TO lt_appid.
MODIFY ztptp_w01_cde_v FROM TABLE lt_appid.
ENDIF.
IF ls_usr02-gltgb <> ls_appid-vedate.
CLEAR ls_appid-vedate.
ls_appid-vedate = ls_usr02-gltgb.
APPEND ls_appid TO lt_appid.
MODIFY ztptp_w01_cde_v FROM TABLE lt_appid.
ENDIF.

ENDLOOP.
*&---------------------------------------------------------------------*

*& Substitute Approver-------------------------------------------------*
SELECT * FROM ztptp_w01_cde_v INTO CORRESPONDING FIELDS OF TABLE @lt_subappid.
LOOP AT lt_subappid INTO ls_subappid.
SELECT SINGLE gltgv,
gltgb
FROM usr02
INTO @DATA(ls_usr02_01)
WHERE bname = @ls_subappid-zsubappid.
*
IF ls_usr02_01-gltgv <> ls_subappid-zvsdate.
CLEAR ls_subappid-zvsdate.
ls_subappid-zvsdate = ls_usr02_01-gltgv.
APPEND ls_subappid TO lt_subappid.
UPDATE ztptp_w01_cde_v FROM TABLE lt_subappid.
ENDIF.
IF ls_usr02_01-gltgb <> ls_subappid-zvedate.
CLEAR ls_subappid-zvedate.
ls_subappid-zvedate = ls_usr02_01-gltgb.
APPEND ls_subappid TO lt_subappid.
UPDATE ztptp_w01_cde_v FROM TABLE lt_subappid.
ENDIF.
ENDLOOP.
*&---------------------------------------------------------------------*

Following is the screenshot of the Ztable i have created

RESULT : Whenever someone will change my validity date in SU01 transaction that date will be reflected in my table and i will not need not change it manually.

Also thank you for responding to my questions taking your time out.

6 REPLIES 6

FredericGirod
Active Contributor
658

So strange, you have the information, but you want the same information in another table ....

former_member806481
Participant
0 Kudos
658

yes but that z table has multiple different field from multiple different tables so ............

lets say the current validity date is 01-01-2022 in the SU01 and also in the ZTABLE

now if i go to SU01 and change the date to 01-01-2021 then my z table should be automatiacally updated with the new value

FredericGirod
Active Contributor
0 Kudos
658

What about a CDS view melting all your different data ?

former_member806481
Participant
0 Kudos
658

no need for CDS 🙂

matt
Active Contributor
658

Holding the same data in two tables indicates a design problem. Either use a view, CDS or otherwise, or have the program that reads from ZTABLE get the information directly from USR02.

I cannot think of a single reason why you'd need to do what you want to do. Often people say "I have this requirement", when they mean "this is my solution to my requirement, how can I do it".

What is your end goal? What are you trying to achieve overall? (And please don't reiterate your question - we understand that).

former_member806481
Participant
0 Kudos
659

Actually i figured it out my self

I created a report and exectued it as a background job for every 1 min (because i wanted to test it quickly).

Here is the code that i have written.

DATA : lt_appid TYPE TABLE OF ztptp_w01_cde_v.
DATA : lt_subappid TYPE TABLE OF ztptp_w01_cde_v.
DATA : ls_appid TYPE ztptp_w01_cde_v.
DATA : ls_subappid TYPE ztptp_w01_cde_v.

*& Main Approver------------------------------------------------------*
SELECT * FROM ztptp_w01_cde_v INTO CORRESPONDING FIELDS OF TABLE @lt_appid.
LOOP AT lt_appid INTO ls_appid.
SELECT SINGLE gltgv,
gltgb
FROM usr02
INTO @DATA(ls_usr02)
WHERE bname = @ls_appid-zappuid.
*
IF ls_usr02-gltgv <> ls_appid-vsdate.
CLEAR ls_appid-vsdate.
ls_appid-vsdate = ls_usr02-gltgv.
APPEND ls_appid TO lt_appid.
MODIFY ztptp_w01_cde_v FROM TABLE lt_appid.
ENDIF.
IF ls_usr02-gltgb <> ls_appid-vedate.
CLEAR ls_appid-vedate.
ls_appid-vedate = ls_usr02-gltgb.
APPEND ls_appid TO lt_appid.
MODIFY ztptp_w01_cde_v FROM TABLE lt_appid.
ENDIF.

ENDLOOP.
*&---------------------------------------------------------------------*

*& Substitute Approver-------------------------------------------------*
SELECT * FROM ztptp_w01_cde_v INTO CORRESPONDING FIELDS OF TABLE @lt_subappid.
LOOP AT lt_subappid INTO ls_subappid.
SELECT SINGLE gltgv,
gltgb
FROM usr02
INTO @DATA(ls_usr02_01)
WHERE bname = @ls_subappid-zsubappid.
*
IF ls_usr02_01-gltgv <> ls_subappid-zvsdate.
CLEAR ls_subappid-zvsdate.
ls_subappid-zvsdate = ls_usr02_01-gltgv.
APPEND ls_subappid TO lt_subappid.
UPDATE ztptp_w01_cde_v FROM TABLE lt_subappid.
ENDIF.
IF ls_usr02_01-gltgb <> ls_subappid-zvedate.
CLEAR ls_subappid-zvedate.
ls_subappid-zvedate = ls_usr02_01-gltgb.
APPEND ls_subappid TO lt_subappid.
UPDATE ztptp_w01_cde_v FROM TABLE lt_subappid.
ENDIF.
ENDLOOP.
*&---------------------------------------------------------------------*

Following is the screenshot of the Ztable i have created

RESULT : Whenever someone will change my validity date in SU01 transaction that date will be reflected in my table and i will not need not change it manually.

Also thank you for responding to my questions taking your time out.