Search This Blog

Search This Blog

SY-LISEL Example

REPORT  ZSYLISEL.

TYPES: BEGIN OF TY_T001,
         BUKRS TYPE BUKRS," COMPANY CODE
         BUTXT TYPE BUTXT," NAME OF THE COMPANY
         ORT01 TYPE ORT01," CITY
         LAND1 TYPE LAND1," COUNTRY CODE
         WAERS TYPE WAERS," CURRENCY KEY
       END OF TY_T001.

DATA: IT_T001 TYPE STANDARD TABLE OF TY_T001,
      WA_T001 TYPE TY_T001.

DATA: V_BUKRS TYPE BUKRS.


TYPES: BEGIN OF TY_CUSTOMER,
         KUNNR TYPE KUNNR," CUSTOMER NO
         BUKRS TYPE BUKRS," COMPANY CODE
         AKONT TYPE AKONT," RECONCILIATION ACCOUNT
       END OF TY_CUSTOMER.

DATA: IT_CUSTOMER TYPE STANDARD TABLE OF TY_CUSTOMER,
      WA_CUSTOMER TYPE TY_CUSTOMER.


SELECT-OPTIONS: S_BUKRS FOR V_BUKRS.

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

SELECT BUKRS
       BUTXT
       ORT01
       LAND1
       WAERS
  INTO TABLE IT_T001
  FROM T001 WHERE BUKRS IN S_BUKRS.

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

  IF NOT IT_T001 IS INITIAL.

     WRITE:/5 'COM.CODE',15 'TEXT',45 'CITY',70 'COUNTRY'.

     ULINE.

    LOOP AT IT_T001 INTO WA_T001.

      WRITE:/5 WA_T001-BUKRS,
            15 WA_T001-BUTXT,
            45 WA_T001-ORT01,
            70 WA_T001-LAND1.
      CLEAR WA_T001.
   ENDLOOP.
  ENDIF.

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

CASE SY-LSIND.

*----1
 WHEN 1.

   V_BUKRS = SY-LISEL+4(4).

*RETRIEVE ALL THE CUSTOMERS FOR THE SELECTED COMPANY CODE.

         SELECT KUNNR
                BUKRS
                AKONT INTO TABLE IT_CUSTOMER FROM KNB1
               WHERE BUKRS = V_BUKRS.


*DISPLAY THE DATA.

        IF NOT IT_CUSTOMER IS INITIAL.

          WRITE:/5 'COM.CODE',15 'CUSTOMER',30 'RECON.ACC'.

          ULINE.

         LOOP AT IT_CUSTOMER INTO WA_CUSTOMER.

          WRITE:/5 WA_CUSTOMER-BUKRS,
                15 WA_CUSTOMER-KUNNR,
                30 WA_CUSTOMER-AKONT.

          CLEAR WA_CUSTOMER.
         ENDLOOP.
        ELSE.

          WRITE:/ 'NO FURTHER DETAILS FOUND FOR THE SELECTED COMP.CODE'.

        ENDIF.

 ENDCASE.

DOUBLE CLICK ON 1000.