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: 

Send data from one User Exit to other

Former Member
0 Kudos

Hi,

There are two User Exits in VA01 transaction

1.USEREXIT_MOVE_FIELD_TO_VBEP

2.USEREXIT_SAVE_DOCUMENT

The first Exit will get called for each line item while the second exit will get called at the time of saving.

For ex: According to my requirement I would like to store details of all the items.

Those details will be available only when the control is in EXIT1.And I need to acess all those details in EXIT2.

How we can do this?

Thanks in advance

Swathi

1 ACCEPTED SOLUTION

former_member404244
Active Contributor
0 Kudos

Hi,

I suggest go for second userexit...USEREXIT_SAVE_DOCUMENT..U iwll find the temporary structures like XVBAK,XVBAP,XVBKD like this..where the data is stored...for line items u will get data In XVBAP.so try to use these structures ..

Regards,

Nagaraj

12 REPLIES 12

former_member404244
Active Contributor
0 Kudos

Hi,

I suggest go for second userexit...USEREXIT_SAVE_DOCUMENT..U iwll find the temporary structures like XVBAK,XVBAP,XVBKD like this..where the data is stored...for line items u will get data In XVBAP.so try to use these structures ..

Regards,

Nagaraj

Former Member
0 Kudos

Hi ,

In the Second exit you will have all the details of order table XVBAK,XVBAP ,XVBEP ,XVBUK ETC ,everything .

Yoiu can use that to do ur calcuations so the second exit has everything available.

Please reward if useful.

Former Member
0 Kudos

Dear Swathi,

Assuming that you're referring to the same document (same LUW) then you can use ABAP memory to store your data.

Please refer to SAP Help for keyword EXPORT / IMPORT

Ps: Do not forget to free the memory after you import and make sure that you create a unique key to identify your data.

Dian

Former Member
0 Kudos

Hi,

Usually you will have the data available in the second exit. In case it is not available, you can make use of EXPORT/IMPORT statements.

In the first exit, use EXPORT data TO memarea.

In the second exit, use IMPORT data FROM memareaa

Please refere F1 help for exact syntax.

Rewards, if helpful!!!

Thanks,

Basav

Former Member
0 Kudos

Swathi,

If you are trying to pass less amount of data ( say a date or may be a Qty) , IMPORT/EXPORT FROM/TO MEMORY is a good option.

But , as these are the Sub routine Exits, and get called frequently( even on Enter in the Sales Order Schedule line screens), I will suggest you to use Function Group and Function Modules for exchanging data.

You create a Function Group, inside that create two Function Modules. From both the exits you can pass the data to the Function group ( you can always create a Top Include and declare some global data across the function modules ). So you can create your own internal tables for storing the data of XVBEP, XVBAK and XVBAP. This will be simpler and error free.

Hope it helps.

Former Member
0 Kudos

Hi

Thanku,

I need details from XVBKD which are not acessible in second Exit.

0 Kudos

then you can go for IMPORT/EXPORT.

EXPORT XVBKD TO MEMORY ID 'Z_XVBKD_EXP'.

and then do an import of the same in the second Exit-

data : T_MEM LIKE xvbkd OCCURS 0.

IMPORT t_mem FROM MEMORY ID 'Z_XVBKD_EXP'.

0 Kudos

You can do that this way using IMPORT/EXPORT.

data : t_all LIKE xvbkd OCCURS 0.

From the first exist where you can capture XVBKD , do this -

data : t_all like XVBKD occurs 0.

IMPORT t_all FROM MEMORY ID 'Z_XVBKD_EXP'.

IF SY_SUBRC EQ 0.

  • Means we have existing data there. gr8.

ENDIF.

  • Now append existing XVBKDs to t_all.

APPEND lines of XVBKD to t_all.

*We are exporting updated data there.

EXPORT t_all TO MEMORY ID 'Z_XVBKD_EXP'.

Where you dont have the XVBKD.Simply IMPORT the memory data

data : t_get like XVBKD occurs 0.

IMPORT t_mem FROM MEMORY ID 'Z_XVBKD_EXP'.

This will take care of all the data records.

But I would suggest you to go for Function groups - As you are playing with internal table records - There is a chance that this Export and Import might fail. Its much safer to go for Function grp/FM combination - it will be much safer.

Former Member
0 Kudos

Hi,

But that will not suffice my requirement..

My req is like we need to append records to Memory ID..

for ex: lets take an internal table itab1 this we can export to MID

but second time this internal table itab1 will have some other records & those records should get appended to MID.

Thanks

Swathi

0 Kudos

HI SKC,

Thanks a lot..

But can u plz. brief abt Function grp/FM...

Regards

Swathi

0 Kudos

Yes.

All the Function Modules belonging to the same function group can share common data between them.

For example - In a function group , when you create a Top Include and declare some internal table, all the function modules can access that data. Refer to Function group V45A. You can see that all the function mdoules are can access VBAPD VBAPD* etc.

Likewise - We can create a function Group( using Se80), inside that we will create a Top include. In that include we can declare an Internal table like XVBKD.

Then we will create a Function module in the Func grp just created, which will take an Internal table in the Table parameter. In the code of this FM - we will simply append the passed table contents to the global internal table we have declared in the TOP INCLUDE. Right ? in that way the Function group will hold all the XVBKD contents.

Now create the second FM that just returns this internal table of the TOP include and your trick is done.

So in the process, we are calling the First FM that feeds the global Internal table of the function group and we access the total content of it using the second FM.

At the same time , the function group itself takes care of the Instance related Refresh of the global internal table - something that u dont need to bother about.

Hope I have been able to explain it properly.

0 Kudos

Thanks a lot