cancel
Showing results for 
Search instead for 
Did you mean: 

What's the init within the exit function?

former_member187400
Active Contributor
0 Kudos

Dear All,

Could you help me to explain me regarding the init within exit function?

I have read already in it's sample: UPFX but i still don't understand :(. And i also read from the documentation, but still don't get the meaning .

Could anybody help me what's the purpose for this init function? Do you have some document explaining for init for exit function ??

Really need your help..

Regards,

Niel .

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

One more point to note is that the init FM runs only once per execution of the function, while the main FM runs once for every data block.

Edited by: Mayank Gupta on Jun 13, 2008

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

When exit function is executed, first it executes init function, then goes to the exact function module.

Purpose of init is that if we dont have any record as per the level selections, init function generates dummy records, and the exit function will be executed. If init is not there, if there are no exitsting records, exit function wont run at all.

We generally write all select statements, populate internal tables and read variable values in init funcion and write the original logic in exit funciton.

Another way is if we have one exit for file upload functionality, the code to browse the file from desktop is written in init and the code to upload it will be written in original function module.

Bindu

former_member187400
Active Contributor
0 Kudos

Dear Mayank,

Tks a lot for your response...

Dear Bindu,

Tks a lot too for your response ..

You said that within Init function usually we do for selecting the data, populating internal table, and reading variable's values.

My questions is:

If we read variable's value or populate internal table (get data from other tables and fill the values to internal table), how can i read those value either variable's value or internal table from exit function ???

How can we transfer the value from init to exit function?

Do you have the sample's code for either read variable, populate internal table or fetch data where it's done at init function ?

And how the exit function use it (the result that is proceeded by init function)??

If you don't mind could you share it to me ???

Best regards,

Niel.

Former Member
0 Kudos

Hi,

Create both init FM and original exit FM in the same function group. Declare the internal tables and global variables in the the TOP include. Fill those tables and globally declared variables in init function. You can directly access the data from these tables in the exit FM because they are globally declared in the TOP include.

The code is the simple select statements for filling internal tables which depends on the logic.

For reading bps variable values, you have to some function calls.

Bindu

former_member187400
Active Contributor
0 Kudos

Dear Bindu,

Thanks an abundant for your help ..

I got your points.

In your preceding posting, the init function has these objectives:

Purpose of init is that if we dont have any record as per the level selections, init function generates dummy records, and the exit function will be executed. If init is not there, if there are no exitsting records, exit function wont run at all.

Actually i still don't understand ,

If you don't mind, could you kindly clear up me again about this ??

Perhaps, you could deliver the sample code :p.

And ..

Could init function get the xth_data values ??

/ modify xth_data values ??

Still need your helps ..

Tks a lot

Bindu ..

Former Member
0 Kudos

Hi,

The meaning of my above post is given as below.

Init function module is to initialize the planning function. This function module is optional. It is only required if new transaction data records are to be generated in the planning function. The keys for these new transaction data records are delivered by the function module in the table ETO_CHAS. The keys are supplemented by the keys of the transaction data that already exist. These transaction data records are then passed on to the second function module.

This is the sap help for init FM.

Hope this is clear to you.

There is no need to access xth_data in init. We do all manipulations on xth_data in original FM only.

Bindu

former_member187400
Active Contributor
0 Kudos

Hi Bindu,

Really-really thanks for your responses.

Am i correct regarding the conclusion i got from your preceding posting ..

You mean, it's needed if we're going to create new record for the planning by exit function.

Then we need the value in eto_chas as the key ..

Am i right ??

If you don't mind, could you attach a sample code for that ..

Thanks a lot Bindu for your kindness.

Best regards,

Niel.

Former Member
0 Kudos

Hi,

I didnt face this requirement as such so cant give you sample code.. Just got to know from sap help..

May be some one else can help you..

Bindu