brunch

You can make anything
by writing

C.S.Lewis

by 동네아밥 Nov 11. 2021

배치특성정보 SQL로 선택하기

웬지 FM이 쓰고싶지 않을 때

"배치특성 선택

  APPEND VALUE: #( sign = 'I' option = 'EQ' low = '특성명입력'     ) TO lr_atnam.

  LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<ls_data>).

    lt_obj_list-matnr = <ls_data>-matnr.

    lt_obj_list-charg = <ls_data>-b_charg.

    lt_obj_list-objek = <ls_data>-matnr && <ls_data>-b_charg.

    APPEND lt_obj_list.

    IF p_reel = 'X'.

      lt_obj_list-matnr = <ls_data>-matnr.

      lt_obj_list-charg = <ls_data>-r_charg.

      lt_obj_list-objek = <ls_data>-matnr && <ls_data>-r_charg.

      APPEND lt_obj_list.

    ENDIF.

  ENDLOOP.

  SELECT inob~cuobj,

         inob~objek,

         ausp~atinn,

         cabn~atnam,

         ausp~atwrt

    FROM inob

    JOIN ausp

      ON inob~cuobj EQ ausp~objek

     AND inob~klart EQ ausp~klart

    JOIN cabn

      ON ausp~atinn EQ cabn~atinn

    INTO TABLE @DATA(lt_inob)

     FOR ALL ENTRIES IN @lt_obj_list

   WHERE inob~klart EQ '023'

     AND inob~obtab EQ 'MCH1'

     AND inob~objek EQ @lt_obj_list-objek

     AND ausp~mafid EQ 'O'

     AND cabn~atnam IN @lr_atnam.

  SORT: lt_inob     BY objek atnam.

  SORT: lt_obj_list BY objek.

  LOOP AT lt_obj_list.

    READ TABLE lt_inob WITH KEY objek = lt_obj_list-objek

                                BINARY SEARCH

                                TRANSPORTING NO FIELDS.

    IF sy-subrc EQ 0.

      LOOP AT lt_inob ASSIGNING FIELD-SYMBOL(<ls_inob>) FROM sy-tabix.

        IF lt_obj_list-objek NE <ls_inob>-objek.

          EXIT.

        ENDIF.

        MOVE-CORRESPONDING lt_obj_list TO lt_obj.

        lt_obj-cuobj = <ls_inob>-cuobj.

        lt_obj-atinn = <ls_inob>-atinn.

        lt_obj-atnam = <ls_inob>-atnam.

        lt_obj-atwrt = <ls_inob>-atwrt.

        APPEND lt_obj. CLEAR lt_obj.

      ENDLOOP.

    ENDIF.

  ENDLOOP.

  SORT lt_obj BY objek atnam.

작가의 이전글 복잡한 입력팝업 간단하게 만들기
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari