Skip to Content

STOP LOOPING_table control

iam having following sytax....

in my pai module...

PROCESS AFTER INPUT.

LOOP AT ITAB.

CHAIN.

FIELD ITAB-filed1.

FIELD ITAB-field2.

FIELD ITAB-field3.

FIELD ITAB-SELKZ Module ON_SELECT on request.

endchain.

ENDLOOP.

MODULE LOAN_USER_COMMAND.

.....so in above coding... ithink you can under stand that SELKZ is for to selct the table control row.... so if you selct the table control row then it will go into the module followed by...SELKZ,

and here now iam modifiying above coding like this.....

PROCESS AFTER INPUT.

LOOP AT ITAB.

CHAIN.

FIELD ITAB-filed1.

FIELD ITAB-field2.

FIELD ITAB-field3.

FIELD ITAB-SELKZ.

endchain.

ENDLOOP.

Module ON_SELECT on request.

MODULE LOAN_USER_COMMAND.

.......it was also properly working but....the thing is...

in first coding the loop is partially running before gointo this module....but in second part the loop is completing....so because if this iam facing trouble inthe caluculation part which is in that module and linked with the entries of the field1 and filed2....

so now my quetio is...

i want to stop that...

loop in second..... one when one perticuler value is met.....but if i write if condition,...it was showing error like...if is not defined....

please answer...

Thank you,

Naveen.....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 12:09 PM

    I believe you need type of syntax for the select row

      loop at IT_WK.
        chain.
          field WK_REC-SPNUM.
        endchain.
        field WK_REC-SEL "<== This is the selecti field that was added to the table
          module TBLCLT_MAIN_mark on request.
      endloop.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 08:03 AM

    Hi,

    we can't stop loop without giving error message.so erroe msg only will stop loop in PAI event. my succession is , do some validation outside the loop like itab one row to another row comparetion.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2008 at 06:19 AM

    I think you may need to read up a little on the "on request" functionality...

    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabbd35c111d1829f0000e829fbfe/content.htm

    So basically the logic you first had was saying

    loop around my table control
    " inside loop
      if the value in field SELKZ is changed (i.e. selected / deselected) 
        then run module ON_SELECT
      endif
    endloop
    

    but you have changed it to say

    loop around my table control
    endloop
    " after loop
    if the value in field SELKZ is changed (i.e. selected / deselected) then run module ON_SELECT
    

    If I understand your requirement correctly, then what you might want to do is something like

    LOOP AT ITAB.
    CHAIN.
      FIELD ITAB-filed1.
      FIELD ITAB-field2.
      FIELD ITAB-field3.
      FIELD ITAB-SELKZ Module ON_SELECT on request. "do logic in ON_SELECT
    endchain.
    ENDLOOP.
    

    then inside your ON_SELECT module you need to flag that you've done the work required

    module on_select input.
    " Flag we've been here this loop
    break-point.  "so you can bebug your code - i.e. check you reach here
      if itab-SELKZ is initial.  "row was un-selected
        g_marked = space.
        clear: g_result.
      endif.
      if g_marked = 'X'. "already marked - so exit as we don't process any lines after the first one selected
        exit. "leave the module so no calc done on this loop
      endif.
      g_marked = 'X'.   "remember to clear this global in the PBO
      g_result = itab-field1 * itab-field2.  "or whatever your calc is
    endmodule
    

    This will mean you are able to tell in the loan_user_command whether any line was selected (from g_marked being "X"), and g_result can hold the answer to the calculation on the selected row.

    Jonathan

    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.