Skip to Content
0
Jun 07, 2022 at 09:06 AM

Better approach for READing the latest record Date-wise using ABAP 7.4 or any other syntaxes.

59 Views

capture.png

Hello ABAP Gurus,

With reference to the screenshot attached. Relationship between ITAB1 and ITAB2 is established using the Association ITAB1~ARC_DOC_ID = ITAB2~DOCID.

Now the requirement here is for each ITAB1~OBJECT_ID we can have multiple records in ITAB2 based on the above Association. In case multiple records are there in ITAB2 for an ITAB1~ OBJECT_ID we need only to pick the latest one from ITAB2 using the CDATE and CTIME columns.

My approach I have created a new Internal Table combining the ITAB1 and ITAB2 with below fields:

1. OBJECT_ID ( ITAB1)

2. ARC_DOC_ID (common between ITAB1 and ITAB2)

3. Timestamp (Combined ITAB2~CDATE and ITAB2~CTIME)

Now am sorting the Internal Table Ascending based on OBJECT_ID and Descending Timestamp and finally reading the Record based on passing the OBJECT_ID and it will get me the first record.

Is there any other better approach for this using ABAP 7.4 syntax. Tried think using REDUCE but am not able to come out with a logic.

Helpful suggestions much appreciated.

Thanks,

Sijin

Attachments

capture.png (718.7 kB)