Skip to Content
author's profile photo Former Member
Former Member

EXIT from the loop in PAI of MODULEPOOL

Hi All,

I am working on the module pool porgram.In module pool programming i have LOOP-ENDLOOP in PAI section, I have to exit from this loop with condition.

can anyone suggest any options in apab to do this.??

Quick response is appreciated.

Thanks ,

Sridhar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 20, 2007 at 08:08 PM

    You can use the EXIT:

    LOOP AT ITAB.
      IF ITAB-MATNR IS INITIAL.
         EXIT.   " << to exit from loop
      ENDIF.
    ENDLOOP.

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Are you talking of a LOOP / ENDLOOP in the flow logic (e.g. one around a table control), or one in the module pool around an internal table? If the former, then it will always loop as many times are there are lines showing in the table control on the screen, but you can prevent any logic being executed for lines after an exception is found by setting a global flag field e.g. something along the following idea:

      " PBO
      process before output.
        module d9999_initialise.
      
      " PAI flow logic for screen 9999.
      process after input.
        loop with control tc_9999.
          module d9999_tc_pai.
        endloop.

      & then

      module d9999_initialise output.
        clear: g_hit_empty_line. "reset the bad data flag
      endmodule.
      
      module d9999_tc_pai input.
      
        if g_hit_empty_line = 'X'.
          exit.  "perform no checks until next PBO
        endif.
      
        if some condition I want to test for is true.
          g_hit_empty_line = 'X'.  "process no more TC rows this PAI
          exit.
        endif.
      
      * logic here for good lines until a bad one found
        
      endmodule.

      Jonathan

      p.s. btw I wouldn't normally put any code in the modules except "performs" - I reckon it's a lot tidier having all your code in subroutines, not the modules.

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 10:13 AM

    hai,

    try this

    u need to write like this

    loop at itab where......[condition]

    ......

    endloop

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.