我收到此错误:在程序结束之前嵌套不正确,if引入的结构必须由endif结束


*&---------------------------------------------------------------------*
*& Report  ZFOR_ALL_ENTRYS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  zfor_all_entrys NO STANDARD PAGE HEADING.
TYPES : BEGIN OF ty_likp,
        vbeln TYPE vbeln_vl,
        ernam TYPE ernam,
        erdat TYPE erdat,
        kunnr TYPE kunnr,
        kunag TYPE kunag,
        END OF ty_likp.
TYPES : BEGIN OF ty_lips,
        vbeln TYPE vbeln_vl,
        posnr TYPE posnr_vl,
        pstyv TYPE pstyv_vl,
        matnr TYPE matnr,
        charg TYPE charg_d,
        meins TYPE meins,
        END OF ty_lips.
DATA : it_likp TYPE TABLE OF ty_likp,
       it_lips TYPE TABLE OF ty_lips.
DATA : wa_likp TYPE ty_likp,
       wa_lips TYPE ty_lips.
IF sy-subrc IS INITIAL.
  SELECT vbeln
         ernam
         erdat
         kunnr
         kunag FROM likp
               INTO TABLE it_likp
               WHERE ernam = 'bollinger'.
IF sy-subrc IS INITIAL.
    SELECT vbeln
           posnr
           pstyv
           matnr
           charg
           meins FROM lips
                 INTO TABLE it_lips
                 FOR ALL ENTRIES IN it_likp
                 WHERE vbeln = it_likp-vbeln.
IF sy-subrc IS INITIAL.
      LOOP AT it_likp INTO wa_likp.
        LOOP AT   it_lips INTO wa_lips WHERE vbeln = wa_likp-vbeln.
          WRITE : wa_likp-vbeln,
                  wa_likp-erdat,
                  wa_likp-ernam,
                  wa_likp-kunnr,
                  wa_likp-kunag,
                  wa_lips-posnr,
                  wa_lips-pstyv,
                  wa_lips-matnr,
                  wa_lips-charg,
                  wa_lips-meins.
        ENDLOOP.
      ENDLOOP.
ENDIF.

每个IF语句都需要一个ENDIF。每个IF sy-subrc IS INITIAL.都必须关闭ENDIF

我认为正确的代码如下。

IF sy-subrc IS INITIAL.
  SELECT vbeln
         ernam
         erdat
         kunnr
         kunag FROM likp
               INTO TABLE it_likp
               WHERE ernam = 'bollinger'.
ENDIF.
IF sy-subrc IS INITIAL.
  SELECT vbeln
         posnr
         pstyv
         matnr
         charg
         meins FROM lips
               INTO TABLE it_lips
               FOR ALL ENTRIES IN it_likp
               WHERE vbeln = it_likp-vbeln.
ENDIF.
IF sy-subrc IS INITIAL.
  LOOP AT it_likp INTO wa_likp.
    LOOP AT it_lips INTO wa_lips WHERE vbeln = wa_likp-vbeln.
      WRITE: wa_likp-vbeln,
             wa_likp-erdat,
             wa_likp-ernam,
             wa_likp-kunnr,
             wa_likp-kunag,
             wa_lips-posnr,
             wa_lips-pstyv,
             wa_lips-matnr,
             wa_lips-charg,
             wa_lips-meins.
    ENDLOOP.
  ENDLOOP.
ENDIF.

相关内容

  • 没有找到相关文章

最新更新