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: 

Export and import data between 2 screen of same program thorugh field exit

former_member435556
Participant
0 Kudos

Hi.

I have requirement  to export and import data between 2 screen of same program, Actually I have T.code FI01  in this When I entered Bank key e.g 23 it moves to the next screen. I want to display the bank name on to the next screen  corresponding to bank key, let suppose bank key 23  which have bank name  'national bank' must be displayed to the next screen field of bank name, I am using field exit to tackle this problem, first I am using bank key fierld which have data element of  BANKK   OF FIELD= BNKA-BANKL,

Code of bank key field is this.

FUNCTION FIELD_EXIT_BANKK_1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(INPUT)
*"  EXPORTING
*"     REFERENCE(OUTPUT)
*"----------------------------------------------------------------------
DATA: BANK_DETAIL  LIKE  BNKA_BF.


if sy-Tcode = 'FI01'.

Data it-bank type BNKA-BANKL.
it-bank = input.
export it-bank from it-bank to MEMORY id 'MY ID'.

ENDIF.
  ENDFUNCTION


First Screen:-


Field Exit of Bank name.which is on next screen,

Actually I importing the bank key into this field exit so on the basis of this i would get the accurate value of corresponding bank  name to display automatically on bank name screen, but it not importing the field actually.



FUNCTION FIELD_EXIT_BANKA.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(INPUT)
*"  EXPORTING
*"     REFERENCE(OUTPUT)
*"----------------------------------------------------------------------

Data it-bank type BNKA-BANKA.
import it-bank = it-bank from MEMORY id ' MY ID '.

IT-BANK = IT-BANK.

ENDFUNCTION.



Next screen :-





Kindly help me in this regard as I am new to sap abap

Thanks

6 REPLIES 6

nmkarthikeya
Active Participant
0 Kudos

Hi Amir,

If I am not wrong inside function modules you can't use import export statements.

You can try creating a Z table, in first exit you can store the value and in next read it.

Regards,

Karthikeya

0 Kudos

Hi,

There are no such restrictions for import/export. Also, its a bad approach to create a z table to just store a runtime value( there are other better approaches like static attributes in classes,singleton classes etc )

@OP - Field exits are obsolete and is an old enhancement technology. If there is any possibility to help you, I will let you know once I have access to the system.

Former Member
0 Kudos

Hi Amir,

Since they are two screens of the same program you don't have to do anything nearly this complicated.  Just have a global field defined in the main program that holds the bank name and add that field to both screens using the screen painter.

PS - you can definitely use IMPORT/EXPORT within a function module; but it's not the right approach in this case.

Jim

0 Kudos

Hi jim

thanks for your reply , actually I am using field exit approach on both the fields, and want to pass field value to another field exit, thats why I choose Import Export approach, but its not working please help me make this possible through field exit, kindly guide me in this regard.

0 Kudos

Hi Amir,

Well I can't say that I've done anything with field exits in at least the last decade so I'm not very expert about that. 

Although I think IMPORT/EXPORT ought to work, you could replace IMPORT/EXPORT by creating a global class in SE24 and define public static GET_BANKA and SET_BANKA methods in the class.  You could use the SET_BANKA method in one field exit (in place of EXPORT) and GET_BANKA method in the other (in place of IMPORT).  In the SET method you store the received value in a static attribute and in the GET method you just return it. 

Or stick with IMPORT/EXPORT - I think it ought to work.  Just add a line in your field exit codes like BREAK youruserid and use debugging to figure out what's going wrong.

By the way, it's poor programming practice to use a hyphen in a variable name in ABAP.  Instead of IT-BANK you should name your variable IT_BANK or something like that (although many people might think that the "IT_" prefix might be a convention meaning that it is an importing parameter table rather than a local variable).  You might want to see if your installation has any standards about naming variables; but at least avoid the hyphen.  If you do an syntax check (or maybe only on extended syntax check) you will get a warning about that.

Jim

Former Member
0 Kudos

Amir,

The main program is the same. So a global field in the main program will just do. Pass the bank key to the global field on PAI of screen 1. Then on PBO of screen2, use the the same global field to fetch the bank name.

Also, never use IMPORT or EXPORT. The reason being, it becomes difficult for other developers to understand where the data comes from and where the data goes to.

In other place where you need some data to be in the memory so another process (in the same LUW) can use this data, instead of import/export, use a FM. The FM will do nothing more than putting the data into a global field (TOP include). You can call this FM again (in place of IMPORT) and use the TOP include variable. This way when you perform a  where used list, you or any other developer will know where the data is exported from and where its imported to.

Thanks,

Vikram.M