Sunday, February 5, 2017

How to transfer values between two different Abap programs/applications

Often in Abap applications, there are needs to transfer values between two programs, especially when it comes to transferring data between user-exits and BADIs. When we use abap memory methods, there are often issues as it could be different instances and other system related issues.
One of the novel ways is to by using EXPORT IMPORT techniques with help of index keys.

One can use the below pseudo code in the two programs to see the results:

Program to transmit data:
                DATA: indxkey1 TYPE indx-srtfd, 
              zlikp TYPE  STANDARD TABLE OF LIKP.
               indxkey 'YCHECKID39'.
                                        EXPORT zlikp FROM zlikp TO DATABASE indx(za)
ID indxkey1.

Program to receive data:

                 DATA: indxkey1 TYPE indx-srtfd,
               zlikp TYPE  STANDARD TABLE OF LIKP.
                              Indxkey1 'YCHECKID39'.
                                        IMPORT zlikp TO zlikp FROM DATABASE indx(za)
ID indxkey1.

The declarations are not specific on one program. The variables need to be declared in both programs. The receiving variable can be altered to something different. The index value, i.e. "za" can be changed into any other value. The same index value can be used for multiple values. In that case, the index key needs to be altered. Also index key needs to have same value in both programs. As seen above in pseudo code, we are using the value ‘YCHECKID39’. There is no declaration required for the value “za”.  Using this method, variables, table types and internal tables can be transferred.

In some cases, “free memory” keyword can be used to clear any memory variables.
Why this method is one of the best methods:
This approach makes use of both database storage retrieval  and memory techniques(SET GET techniques). SET GET often does not work due to value not being transmitted or Abap memory related issues. We tried this method to transfer data between user-exit and BADI and it worked wonderfully, while other memory techniques failed.

No comments:

Post a Comment