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: 

IF...............................ENDIF

ninad18
Explorer
0 Kudos

Error

Incorrect nesting: Before the statement "FORM", the control structure introduced by "IF" must be closed by "ENDIF".

Below is the Code.

IF sy-subrc = 0.<br>    if gwa_invdata-werks = '4200' OR gwa_invdata-werks = '4210'.<br>         gwa_output-add_tracking_number_req_mt-tracking-pol_name = ''.<br>      ELSE.<br><br>      gwa_output-add_tracking_number_req_mt-tracking-pol_name =<br>      gwa_plntorg-post_code1.<br>    ENDIF.<br><br>* For Partner Function zip code<br>    READ TABLE git_partfunc INTO DATA(gwa_partfunc) WITH KEY<br>    vbeln = gwa_invdata-vbeln BINARY SEARCH.<br>   IF sy-subrc = 0.<br>      if gwa_invdata-werks = '4200' OR gwa_invdata-werks = '4210'.<br>         gwa_output-add_tracking_number_req_mt-tracking-pod_name = ''.<br>        ELSE.<br>         gwa_output-add_tracking_number_req_mt-tracking-pod_name =<br>         gwa_partfunc-post_code1.<br>      ENDIF.<br><br>* EOC - Ended by Tapas dtd 14.09.2023<br><br>    READ TABLE git_gocotrack INTO DATA(gwa_gocotrack) WITH KEY<br>    vbeln = gwa_invdata-vbeln.<br>    IF sy-subrc = 4.<br>      TRY.<br>          CLEAR gwa_input.<br>          CALL METHOD me->add_tracking_number_ob_si<br>            EXPORTING<br>              output = gwa_output<br>            IMPORTING<br>              input  = gwa_input.<br><br>        CATCH cx_ai_system_fault INTO lcl_ref_fault.<br>          IF lcl_ref_fault IS NOT INITIAL.<br>            ELSE.<br>              COMMIT WORK.<br>            ENDIF.<br>      ENDTRY.<br><br>      IF gwa_input IS NOT INITIAL AND<br>        gwa_input-add_tracking_number_res_mt-status NE 'failure'.<br>        gwa_logtab-tracking_id =<br>        gwa_input-add_tracking_number_res_mt-tracking_id.<br>        gwa_logtab-code       = gwa_input-add_tracking_number_res_mt-code.<br>        gwa_logtab-messages   = gwa_input-add_tracking_number_res_mt-message.<br>        CONCATENATE gwa_logtab-messages<br>        gv_message INTO gwa_logtab-messages SEPARATED BY space.<br>        gwa_logtab-status     = gwa_input-add_tracking_number_res_mt-status.<br>        gwa_logtab-token      = gwa_token-token.<br>        gwa_logtab-vbeln      = gwa_invdata-vbeln.<br>        gwa_logtab-created_by = sy-uname.<br>        gwa_logtab-created_on = sy-uzeit.<br>        gwa_logtab-created_at = sy-datum.<br>        gwa_logtab-bukrs      = gwa_invdata-bukrs.<br>        gwa_logtab-sta        = 'C'.<br>        APPEND gwa_logtab TO git_logtab.<br>        MODIFY zacg_gocotrackdt FROM gwa_logtab.<br>        IF sy-subrc = 0.<br>          COMMIT WORK.<br>        ENDIF.<br>        CLEAR: gwa_logtab,gwa_input.<br><br>      ELSE.<br><br>        lwa_elogtab-tracking_id =<br>        gwa_input-add_tracking_number_res_mt-tracking_id.<br>        lwa_elogtab-code        =<br>        gwa_input-add_tracking_number_res_mt-code.<br><br>        IF gwa_input-add_tracking_number_res_mt-message<br>        IS NOT INITIAL.<br>          lwa_elogtab-messages  =<br>          gwa_input-add_tracking_number_res_mt-message.<br>        ELSE.<br>          lwa_elogtab-messages  = TEXT-015.<br>        ENDIF.<br><br>        CONCATENATE lwa_elogtab-messages<br>        gv_message INTO lwa_elogtab-messages SEPARATED BY space.<br>        lwa_elogtab-status      =<br>        gwa_input-add_tracking_number_res_mt-status.<br>        lwa_elogtab-token       = gwa_token-token.<br>        lwa_elogtab-vbeln       = gwa_invdata-vbeln.<br>        lwa_elogtab-created_by  = sy-uname.<br>        lwa_elogtab-created_on  = sy-uzeit.<br>        lwa_elogtab-created_at  = sy-datum.<br>        lwa_elogtab-bukrs       = gwa_invdata-bukrs.<br>        MOVE-CORRESPONDING lwa_elogtab TO gwa_logtab.<br>        APPEND gwa_logtab TO git_logtab.<br>        INSERT zacg_errtrackdt FROM lwa_elogtab.<br>        IF sy-subrc = 0.<br>          COMMIT WORK.<br>          CLEAR lwa_elogtab.<br>        ENDIF.<br>      ENDIF.<br>    ENDIF.<br><br>    CLEAR:<br>      gwa_output-add_tracking_number_req_mt-tracking-container_numbers,<br>      gwa_output-add_tracking_number_req_mt-tracking,gwa_output,<br>      gwa_input,gwa_logtab,lv_tdname,lv_veh_no,gwa_plntorg,gwa_partfunc.<br><br>    REFRESH<br>    gwa_output-add_tracking_number_req_mt-tracking-container_numbers.<br>  ENDIF.<br>ENDIF.
3 REPLIES 3

Eduardo-CE
Active Participant
0 Kudos

Use pretty print to see where you might be missing something

Sandra_Rossi
Active Contributor
0 Kudos

Could you reformat your question please? Lots of <br> in your code. Thanks.

xiswanto
Active Participant
0 Kudos

I think I just counted 1 extra ENDIF 😕