Search This Blog

Search This Blog

AT LINE-SELECTION ( GET CURSOR )

REPORT  ZCLASS_G11 NO STANDARD PAGE HEADING LINE-COUNT 28(3).

TABLES MARA.

SELECT-OPTIONS S_MATNR FOR MARA-MATNR.

PARAMETERS P_MATNR LIKE MARA-MATNR DEFAULT '100-100'.

DATA: BEGIN OF IT_MARA OCCURS 0,
        MATNR  TYPE  MARA-MATNR,
        ERSDA  TYPE  MARA-ERSDA,
        ERNAM  TYPE  MARA-ERNAM,
        MATKL  TYPE  MARA-MATKL,
      END OF IT_MARA.

DATA: BEGIN OF IT_MARD OCCURS 0,
        MATNR  TYPE  MARD-MATNR,
        WERKS  TYPE  MARD-WERKS,
        LGORT  TYPE  MARD-LGORT,
        LABST  TYPE  MARD-LABST,
      END OF IT_MARD.


DATA IT_T023T LIKE T023T OCCURS 0 WITH HEADER LINE.
**************************************************************************
*                            INITIALIZATION                              *
**************************************************************************
INITIALIZATION.

  S_MATNR-SIGN = 'I'.
  S_MATNR-OPTION = 'BT'.
  S_MATNR-LOW = '100-100'.
  S_MATNR-HIGH = '100-200'.

  APPEND S_MATNR.

  S_MATNR-SIGN = 'I'.
  S_MATNR-OPTION = 'BT'.
  S_MATNR-LOW = '100-300'.
  S_MATNR-HIGH = '300-400'.

  APPEND S_MATNR.

**************************************************************************
*                         AT SELECTION-SCREEN                            *
**************************************************************************
AT SELECTION-SCREEN.

  DATA G_MATNR LIKE MARA-MATNR.

  SELECT SINGLE MATNR FROM MARA INTO G_MATNR WHERE MATNR = P_MATNR.
  IF G_MATNR IS INITIAL.
    SET CURSOR FIELD 'P_MATNR'.
    MESSAGE E000(ZG01) WITH P_MATNR.
  ENDIF.

**************************************************************************
*                          START-OF-SELECTION                            *
**************************************************************************
START-OF-SELECTION.

  SELECT MATNR
         ERSDA
         ERNAM
         MATKL INTO TABLE IT_MARA
               FROM MARA
               WHERE MATNR IN S_MATNR.

**************************************************************************
*                            END-OF-SELECTION                            *
**************************************************************************
END-OF-SELECTION.

  SET TITLEBAR 'ZMARA'.

  LOOP AT IT_MARA.
    WRITE:/ IT_MARA-MATNR HOTSPOT ON,
            IT_MARA-ERSDA,
            IT_MARA-ERNAM,
            IT_MARA-MATKL HOTSPOT ON.
    HIDE IT_MARA-MATNR.
  ENDLOOP.

**************************************************************************
*                               TOP-OF-PAGE                              *
**************************************************************************
TOP-OF-PAGE.

  ULINE.
  WRITE:/  TEXT-A01.
  ULINE.

**************************************************************************
*                               END-OF-PAGE                              *
**************************************************************************
END-OF-PAGE.

  ULINE.
  WRITE:/10 '*** End of Page ***', SY-PAGNO.
  ULINE.

**************************************************************************
*                              AT LINE-SELECTION                         *
**************************************************************************
AT LINE-SELECTION.

  DATA: G_FIELD(20) TYPE C,
        G_VALUE(18) TYPE C.

  GET CURSOR FIELD G_FIELD VALUE G_VALUE.

  IF G_FIELD EQ 'IT_MARA-MATNR'.

    SELECT MATNR
           WERKS
           LGORT
           LABST INTO TABLE IT_MARD
                 FROM MARD
                 WHERE MATNR = G_VALUE.

    LOOP AT IT_MARD.
      WRITE:/ IT_MARD-MATNR, IT_MARD-WERKS, IT_MARD-LGORT, IT_MARD-LABST.
    ENDLOOP.

  ELSEIF G_FIELD EQ 'IT_MARA-MATKL'.

    SELECT * FROM T023T INTO TABLE IT_T023T WHERE SPRAS = SY-LANGU
                                              AND MATKL = G_VALUE.
    LOOP AT IT_T023T.
      WRITE:/ IT_T023T-MATKL, IT_T023T-WGBEZ.
    ENDLOOP.
  ENDIF.
**************************************************************************
*                    TOP-OF-PAGE DURING LINE-SELECTION                   *
**************************************************************************
TOP-OF-PAGE DURING LINE-SELECTION.

  ULINE.

  IF G_FIELD EQ 'IT_MARA-MATNR'.

    SET TITLEBAR 'ZMARD'.
    WRITE:/10 'Material Price Details..'.

  ELSEIF G_FIELD EQ 'IT_MARA-MATKL'.

    SET TITLEBAR 'ZT023T'.
    WRITE:/10 'Material Group Description..'.

  ENDIF.

  ULINE.