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: 

How can I go to next record in FM

Former Member
0 Kudos
124

There is a function module MATERIAL_UNIT_CONVERSION where I need to go to next record when an exception is raised.

CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'

EXPORTING

INPUT = P_TBL_PLAF_VCAP_GSMNG

IMPORTING

OUTPUT = P_TBL_PLAF_VCAP_GSMNG

EXCEPTIONS

OVERFLOW = 8.

IF SY-SUBRC = 8.

" what should I write here

ENDIF.

8 REPLIES 8

former_member376453
Contributor
0 Kudos
79

If you calling in a loop, then just write "continue". thats it.

Kuntal

Former Member
0 Kudos
79

P_TBL_PLAF_VCAP_GSMNG

Is it a single record?

and where ur fm is? is it in a subroutine?

кu03B1ятu03B9к

Former Member
0 Kudos
79

I guess you need recursive programming here....

Perform f_material_unit.

form f_material_unit_conv.

CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'

EXPORTING

INPUT = P_TBL_PLAF_VCAP_GSMNG

IMPORTING

OUTPUT = P_TBL_PLAF_VCAP_GSMNG

EXCEPTIONS

OVERFLOW = 8.

IF SY-SUBRC = 8.

perform f_material_unit_conv.

ENDIF.

endform.

Never had to do recursive programming in abap before but I think this will work.

Mathews

Former Member
0 Kudos
79

Hi Annapurna,

You need to call FM 'MATERIAL_UNIT_CONVERSION' in LOOP (of Material data?).

If sy-subrc NE 0 Do CONTINUE. so it proceeds to the next record in loop.

Regards

Shital

Former Member
0 Kudos
79

Hi Kartik,

The Function Module is in a Form and it is called multiple times in the program.

Yes it is in Loop endloop ,but in the same loop the Form is called multiple times.

0 Kudos
79

you keep a flag in if- endif. and depending on it do a continue like below:


Loop.
clear v_flag.
Perform " Your perform
If v_flag eq 'X'.
  continue.
endif.
Endloop.

Form " Start of your perform

" Call the FM
if sy-subrc eq 8.
 v_flag = 'X'.
endif.
Endform.

Kuntal

0 Kudos
79

try skip.

Former Member
0 Kudos
79

Hi Annapurna,

is ur program is like this.

loop.

perform mat_unit_conversion.

endloop.

form mat_unit_conversion.

CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'

EXPORTING

INPUT = P_TBL_PLAF_VCAP_GSMNG

IMPORTING

OUTPUT = P_TBL_PLAF_VCAP_GSMNG

EXCEPTIONS

OVERFLOW = 8.

endform.

if it is so.

u can follow the below to skip the loop to process the next record,

loop.

perform mat_unit_conversion.

if v_flag = 'X'.

continue. " it will skip to the next loop.

endloop.

form mat_unit_conversion.

data : v_flag.

CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'

EXPORTING

INPUT = P_TBL_PLAF_VCAP_GSMNG

IMPORTING

OUTPUT = P_TBL_PLAF_VCAP_GSMNG

EXCEPTIONS

OVERFLOW = 8.

if sy-subrc = 8.

v_flag = 'X'.

exit. " it exits from the sub-routine.

endif.

endform.

hope this will help u.

<< Please do not beg for points >>

Guru

Edited by: Rob Burbank on Mar 17, 2009 10:39 PM