Search This Blog

Search This Blog

AT USER-COMMAND

REPORT  ZCLASS_G13.

TABLES VBAK.

SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.

RANGES R_VBELN FOR VBAK-VBELN.

DATA: BEGIN OF IT_VBAK OCCURS 0,
        VBELN LIKE VBAK-VBELN,
        ERDAT LIKE VBAK-ERDAT,
        KUNNR LIKE VBAK-KUNNR,
      END OF IT_VBAK.

DATA: BEGIN OF IT_VBAP OCCURS 0,
        VBELN LIKE VBAP-VBELN,
        POSNR LIKE VBAP-POSNR,
        MATNR LIKE VBAP-MATNR,
        NETWR LIKE VBAP-NETWR,
      END OF IT_VBAP.


DATA G_CHK(1) TYPE C.

START-OF-SELECTION.

  SELECT VBELN
         ERDAT
         KUNNR INTO TABLE IT_VBAK
               FROM VBAK
               WHERE VBELN IN S_VBELN.

END-OF-SELECTION.

  SET PF-STATUS 'ZG13'.

  LOOP AT IT_VBAK.

    WRITE:/ G_CHK AS CHECKBOX,
            IT_VBAK-VBELN,
            IT_VBAK-ERDAT,
            IT_VBAK-KUNNR.

  ENDLOOP.


******************************************************************************
AT USER-COMMAND.

  DATA G_VBELN(10) TYPE N.

  REFRESH R_VBELN[].

  IF SY-UCOMM EQ 'VBAP'.

    DO.

      READ LINE SY-INDEX FIELD VALUE G_CHK IT_VBAK-VBELN INTO G_VBELN.

      IF SY-SUBRC NE 0.

        EXIT.

      ELSEIF G_CHK EQ 'X'.
        R_VBELN-SIGN = 'I'.
        R_VBELN-OPTION = 'EQ'.
        R_VBELN-LOW = G_VBELN.

        APPEND R_VBELN.

      ENDIF.

    ENDDO.


    IF NOT R_VBELN[] IS INITIAL.
      SELECT VBELN
             POSNR
             MATNR
             NETWR INTO TABLE IT_VBAP
                   FROM VBAP
                   WHERE VBELN IN R_VBELN.


      LOOP AT IT_VBAP.
        WRITE:/ IT_VBAP-VBELN, IT_VBAP-POSNR, IT_VBAP-MATNR, IT_VBAP-NETWR.
      ENDLOOP.

    ENDIF.
  ENDIF.