Skip to Content
Technical Articles
Author's profile photo Sheeraz Akhtar

Data Consistency in AMDP between two Clients

I am grateful to share a concept as my first blog. A concept where data inconsistency was fixed within a AMDP Class. So, I have gathered information and shared this Blog which would be helpful to resolve this issue with a single shot and precise solution.

Providing a useful Reference Link for ABAP related development (ADT) to be installed in Eclipse.

Link: Enter path as- ADT –¬† http://tools.hana.ondemand.com/neon ¬†Replace word neon with the eclipse you are downloading Mars, Kepler, Oxygen etc.

Description:

This post will show you how to resolve Data Consistency in AMDP Class when executed between two different Clients.

Introduction:

In this Blog Code references has been attached that helps to make solution easier and with the precise fix for achieving Data Consistency in AMDP Class even if the Client is different.

When we created a AMDP Class we experienced correct data not being fetched from say, Client 100 and Client 200 for the same set of queries. Hence, a quick and precise fix has been presented to fix the issue.

Data Inconsistency between two Clients for data being fetched from AMDP Class can be avoided and corrected by including MANDT field in SELECT queries. MANDT should be also included in Internal Table and if there’s any INNER JOIN; include MANDT in INNER JOIN ON~ Conditions.

Let’s dive in the practical scenario with Solution explained below where I came across and faced the issued.

 

Below Code can be referred which is extracting values from tables CRHD, AFVC, CRTX.

MANDT Field inclusion has been done to avoid the Data Inconsistency irrespective of Client it is being executed in.

CLASS zptdcl DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

* Marker interface for Database Procedures
INTERFACES: if_amdp_marker_hdb.

* Types Declaration
TYPES :BEGIN OF gty_ty_info,
mandt TYPE crhd-mandt,
objid TYPE crhd-objid,
arbpl TYPE crhd-arbpl,
sortb TYPE crhd-sortb,
arbid TYPE afvc-arbid,
aufpl TYPE afvc-aufpl,
vornr TYPE afvc-vornr,
objnr TYPE afvc-objnr,
ltxa1 TYPE afvc-ltxa1,
ktsch TYPE afvc-ktsch,
steus TYPE afvc-steus,
ktext TYPE crtx-ktext,
END OF gty_ty_info,
gty_info TYPE STANDARD TABLE OF gty_ty_info.

CLASS-METHODS get_oprn_details
IMPORTING
VALUE(im_mandt) TYPE sy-mandt
VALUE(im_plant) TYPE string
VALUE(im_wc) TYPE string
VALUE(iv_tvarvc_1) TYPE string
VALUE(iv_tvarvc_2) TYPE string
EXPORTING
VALUE(et_info) TYPE gty_info

PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zptdcl IMPLEMENTATION.

METHOD get_oprn_details BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING crhd .

gty_info = SELECT
a.mandt,
a.objid, a.arbpl, a.sortb, b.arbid, b.aufpl, b.vornr, b.objnr, b.ltxa1, b.ktsch, b.steus, d.ktext
FROM crhd AS a
INNER JOIN afvc AS b
ON a.objid = b.arbid
AND a.mandt = b.mandt
INNER JOIN crtx AS d
ON a.objid = d.objid
AND a.mandt = d.mandt
WHERE a.mandt = :im_mandt
AND a.werks = :im_plant
AND a.arbpl = :im_wc
AND a.objty = 'A'
ORDER BY aufpl ;

et_info = APPLY_FILTER (:gty_info, :iv_tvarvc_1);

ENDMETHOD.

ENDCLASS.

Conclusion:

To avoid Error, you need to insert the MANDT Field.

 

Finally We are done!!!

If you have any question, please leave your comment. Thank you.

Kindly provide your valuable Feedback on this blog.

 

Profile username- @sheeraza_akhtar

More HANA related blogs will be updated soon.

 

Hope its helpful,

Sheeraz Akhtar.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Satheesh Sambandamurthy
      Satheesh Sambandamurthy

      I will save you a parameter in AMDP method.

      You don't need a importing parameter for client value to be passed instead it can be accessed as below inside the procedure.

      where mandt = Session_context('CLIENT')