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

Issue related to EXIT statement

Hi,

I have a issue related <b>EXIT</b> statement.

Actually my code is as follows:


                  LOOP AT i_resb.

* POPULATE VALUES FOR BAPI CALL
                    i_mvtit-material      = wa_mdfa-matnr.
                    i_mvtit-plant         = i_resb-werks.
                    i_mvtit-spec_stock    = c_q.
                    i_mvtit-stge_loc      = c_zwip.
                    i_mvtit-stge_type     = i_resb-lgtyp.
                    i_mvtit-batch         = i_resb-charg.
                    i_mvtit-orderid       = i_resb-aufnr.
                    i_mvtit-spec_stock    = i_resb-sobkz.
                    i_mvtit-entry_qnt     = i_resb-enmng.
                    i_mvtit-entry_uom     = i_resb-erfme.
                    i_mvtit-entry_uom_iso = i_resb-meins.
                    i_mvtit-wbs_elem      = v_frwbs.
                    i_mvtit-move_type     = c_262.
                    i_mvtit-xstob         = c_x.
                    i_mvtit-gr_rcpt       = i_resb-aufnr.
                    i_mvtit-reserv_no     = i_resb-rsnum.
                    i_mvtit-res_item      = i_resb-rspos.

                    APPEND i_mvtit.
                    CLEAR i_mvtit.

* HEADER ELEMENTS
                    k_gmvt_code-gm_code    = c_03.
                    k_gmvt_head-pstng_date = sy-datum.
                    k_gmvt_head-doc_date   = sy-datum.

* CREATE GOODS MOVEMENTS
                    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
                      EXPORTING
                        goodsmvt_header = k_gmvt_head
                        goodsmvt_code   = k_gmvt_code
                      TABLES
                        goodsmvt_item   = i_mvtit
                        return          = i_return.

                    READ TABLE i_return WITH KEY type = c_e.

                    IF sy-subrc EQ 0.

* Format error Message
                      CLEAR v_error_message.
                      PERFORM f_format_error USING p_wa_data_in
                                                   c_e
                                                   c_error_number0
                                                   text-024
                                          CHANGING v_error_message.

                      <b>EXIT.</b>

                    ELSE.

                      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                        EXPORTING
                          wait = c_x.

* Write the appropriate fields to table zpsi7603_01
                      CLEAR:   i_zpsi7603_01.
                      REFRESH: i_zpsi7603_01.

                      MOVE i_resb-aufnr  TO i_zpsi7603_01-aufnr.
                      MOVE i_resb-rsnum  TO i_zpsi7603_01-rsnum.
                      MOVE i_resb-rspos  TO i_zpsi7603_01-rspos.
                      MOVE wa_mdfa-matnr TO i_zpsi7603_01-matnr.
                      MOVE i_resb-bdmng  TO i_zpsi7603_01-bdmng.
                      MOVE v_frwbs       TO i_zpsi7603_01-pspnr.

                      APPEND i_zpsi7603_01.
                      CLEAR  i_zpsi7603_01.

                      MODIFY zpsi7603_01 FROM TABLE i_zpsi7603_01.

                      IF sy-subrc EQ 0.
                        CLEAR:   i_zpsi7603_01.
                        REFRESH: i_zpsi7603_01.
                      ENDIF.

                    ENDIF.

                  ENDLOOP.

                  v_aufnr = l_aufnr .

* BDC Process for updating fields in CO02
                  PERFORM f_bdc_process_co02 USING p_wa_data_in.


In the above code when there is error in <b>'BAPI_GOODSMVT_CREATE'</b> it will call <b>f_format_error</b> then because it has given error it should skip the nex part of the code that calling<b> BDC</b> for <b>CO02</b>.

The following statement should not be called.

<b>PERFORM f_bdc_process_co02 USING p_wa_data_in.</b>

so what i can do instead of EXIT which statement i can make use so that my code skips past

<b>PERFORM f_bdc_process_co02 USING p_wa_data_in.</b>

Can anybody solve my issue.

Thanks in advance.

Thanks & Regards,

Rayeez.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2006 at 05:21 AM

    Hi shaik,

    1. Simple

    2. For that we can use one simple flag variable.

    3. data : flag type c.

    4. If error occurs,

    ie.

    if sy-subrc <> 0.

    <b> flag = 'X'.</b>

    endif.

    5. Later on,

    call your FORM/PERFORM

    only when flag is initial.

    *----


    • BDC Process for updating fields in CO02

    <b> IF FLAG IS INITIAL.</b>

    PERFORM f_bdc_process_co02 USING p_wa_data_in.

    <b> ENDIF.</b>

    Regards,

    amit m.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI Shahik,

      Suppose if you have 3 entries in I_RESB

      and got error from BAPI then i think you need to process CO02 BDC part fro the remaining entries ..

      thats why i suggested you to use CONTINUE and not EXIT..

      regards

      satesh

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2006 at 05:40 AM

    Hi Shahik,

    if you want the entire operation for all the values of it_resb

    then you shud use <b>CONTINUE</b>

    EXIT throws you out of the loop.

    while CONTINUE skips the rest of the code and goes back to the start of the loop..

    READ TABLE i_return WITH KEY type = c_e.
            IF sy-subrc EQ 0.
                          CLEAR v_error_message.
                          PERFORM f_format_error USING p_wa_data_in  c_e
    c_error_number0
    text-024
    CHANGING v_error_message.
    CONTINUE.
    ENDIF.

    regards

    satesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2006 at 12:19 PM

    try out check it might work

    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.