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: 

Calling a Function Module within a loop in Report Program

Amey-Mogare
Contributor
0 Kudos

Hiii,

I'm calling one function module "Z_get_transaction_details" which returns details of transaction id passed to it.

It returns them by means of some structures...

I am calling this function module within loop statement in a report program. Now what is happening is when i call it in first loop, results returned are correct, but from 2nd loop onwards, output data frm rfc is same even if input parameters are different.

Im clearing worareas, internal tables after each loop, but still problem persists...

And i tested rfc for inputs that are getting passed in report program.. but it is working perfect when i execute RFC !!!

So where is the problem? pls guide me...

regards

Amey

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

clear the work area. i think it will work if you clear the work area after every loop pass

7 REPLIES 7

Former Member
0 Kudos

Hi,

It wd be better if you could give a shot of ur exact code...

Well, first check the position you r clearing ur variables. I mean you said that u r clearing ur variables after the loop. If it is outside the loop then avoid it and place it whithin the loop.

Regards,

Jayadeep

0 Kudos

Yes, i have putten it inside loop only...

Before calling function module, i'm clearing and refreshing all internal tables, workareas related to it..

here is the code:-

I have fetched set of transactions from transaction table, and im looping on it to get its assessment details.

And I have checked that each time input to FM is different..

loop at it_ztfso_bp_tn into wa_ztfso_bp_tn.

refresh it_assessment.

clear wa_assessment.

call function 'Z_ZRFC_GETDET_FS_OPPORTUNITY'

exporting

process_type = l_process_type

transactionid = wa_ztfso_bp_tn-object_id

istatus = l_status

tables

assessment = it_assessment.

if it_assessment is not initial.

loop at it_assessment into wa_assessment.

*Some processing

endloop.

endif.

endloop.

Pls suggest

Amey

0 Kudos

Check the parameters i_status and i_process. How they are being populated and the documentation of the FM if any. Are u sure that these two parameters have the same values for all the run of the loop.

U can try putting the clear stmnts after processing the i_assesment table whithin the loop.

0 Kudos

Hi Jay,

l_status is transaction status and l_process is transaction type..

And throughout the loop i'm retrieving details for list of transaction ids..

In the FM call, inputs status and processtype are constant. but only thing changing is transaction-id and i have checked that each transaction id is different.

And i'm clearing workareas, internal table it_assessment at start of each loop (look at the code)...

i'm debugging code for many days but not gettin any idea abt it...

regards,

Amey

Former Member
0 Kudos

Hi,

You are moving the internal table lines into a work area for each loop pass. You need to clear it every loop pass.

Please try this code.

loop at it_ztfso_bp_tn into wa_ztfso_bp_tn.

refresh it_assessment.

clear wa_assessment.

call function 'Z_ZRFC_GETDET_FS_OPPORTUNITY'

exporting

process_type = l_process_type

transactionid = wa_ztfso_bp_tn-object_id

istatus = l_status

tables

assessment = it_assessment[].

if it_assessment[] is not initial.

loop at it_assessment into wa_assessment.

*Some processing

clear : it_assessment,wa_assessment.

endloop.

endif.

clear : it_ztfso_bp_tn,wa_ztfso_bp_tn.

endloop.

Regards,

Sankar.

Former Member
0 Kudos

Hi,

clear the work area. i think it will work if you clear the work area after every loop pass

0 Kudos

hiiiiii,

Thank you so much for dragging my attention to clearing workarea...

My problem has been resolved.

Thank you so much to you all...

regards,

Amey