*&---------------------------------------------------------------------*
*& Report  ZERN_TAW12_WRITE                                            *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZERN_TAW12_WRITE  NO STANDARD PAGE HEADING .
* KULANILACAK TABLOLAR
TABLES : SBOOK   ,
         SFLIGHT ,
         SSCRFIELDS,
         SCARR .
*         ZNUFUS.

* 1. EKRANDA YAZILACAK DEGERLER
DATA : BEGIN OF KTAB OCCURS 0       ,
       A(1)                         , " Checkbox
       CARRNAME LIKE SCARR-CARRNAME ,
       CARRID LIKE SCARR-CARRID     ,
       CONNID   LIKE SPFLI-CONNID   ,
       CITYFROM LIKE SPFLI-CITYFROM ,
       CITYTO   LIKE SPFLI-CITYTO   ,
         END OF KTAB.





* SPFLI TABLOSUNDAN VERILER ITAB ICERISENE ATILIR

*DATA: XTAB LIKE ZNUFUS OCCURS 0 WITH HEADER LINE.
DATA ITAB LIKE SPFLI OCCURS 0 WITH HEADER LINE .
DATA STAB LIKE SFLIGHT OCCURS 0 WITH HEADER LINE .

selection-screen begin of screen 123 as window title text-456.
selection-screen begin of block bl1  .

parameters: par1 like sbook-CUSTOMID,
            par2 like sbook-CONNID,
            par3 like sbook-FLDATE.
*            ADI TYPE TEXT20,
*            SOYADI TYPE TEXT20,
*            YASI  TYPE I,
*            CINSIYET TYPE TEXT20.

SELECTION-SCREEN PUSHBUTTON /26(20) TEXT-003 USER-COMMAND EKL.
SELECTION-SCREEN PUSHBUTTON /26(20) TEXT-004 USER-COMMAND SIL.
SELECTION-SCREEN PUSHBUTTON /26(20) TEXT-005 USER-COMMAND DEG.
selection-screen end of block bl1.
selection-screen end of screen 123.


* EKRANDAN GIRILECEK OLAN CARRID DEÐERI
  PARAMETERS : P_CARRID LIKE SPFLI-CARRID.

AT USER-COMMAND.


  IF SY-UCOMM EQ 'ARNT'.
    PERFORM AT_USER_COMMAND.
    PERFORM WRITE_SCREEN.
  elseif sy-ucomm eq 'RZRT'.

  perform call_screen.


  ENDIF.

AT SELECTION-SCREEN .

*  IF SSCRFIELDS-UCOMM EQ 'EKL'.
*
*    PERFORM FILL_TABLE USING ADI SOYADI YASI.
*
*  ELSEIF SSCRFIELDS-UCOMM EQ 'SIL'.
*
*    PERFORM DELETE_TABLE USING ADI  .
*
* ELSEIF SSCRFIELDS-UCOMM EQ 'DEG'.
*
* PERFORM MODIFY_TABLE USING ADI.
*
*  ENDIF.




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

* DATABASE TABLOLARINDAN DATA ALIMI
  PERFORM GET_DATA.

END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
FORM GET_DATA.

*BREAK TRAINING .

  SELECT * FROM SPFLI INTO TABLE ITAB WHERE CARRID EQ P_CARRID.


  LOOP AT ITAB.

    SELECT SINGLE * FROM SCARR WHERE CARRID EQ ITAB-CARRID.

    MOVE : SCARR-CARRNAME TO KTAB-CARRNAME ,
           ITAB-CARRID   TO  KTAB-CARRID   ,
           ITAB-CONNID    TO KTAB-CONNID   ,
           ITAB-CITYFROM  TO KTAB-CITYFROM  ,
           ITAB-CITYTO    TO KTAB-CITYTO    .


    APPEND KTAB.
  ENDLOOP.

  SET PF-STATUS 'DE'.
  LOOP AT KTAB.
    WRITE : / KTAB-A AS CHECKBOX ,
              KTAB-CARRNAME      ,
              KTAB-CONNID        ,
              KTAB-CITYFROM      ,
              KTAB-CITYTO        .

    HIDE : KTAB-A ,
         KTAB-CARRNAME ,
         KTAB-CONNID.
  ENDLOOP.

ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  at_user_command
*&---------------------------------------------------------------------*
FORM AT_USER_COMMAND.



  DO .
    READ LINE SY-INDEX FIELD VALUE KTAB-A .
* SAYFA BITENE KADAR OKU
*------------------------
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
*------------------------
    IF KTAB-A EQ 'X'.

      LOOP AT KTAB WHERE CARRNAME EQ KTAB-CARRNAME AND
                         CONNID   EQ KTAB-CONNID .
        MOVE 'X' TO KTAB-A .
        MODIFY KTAB INDEX SY-TABIX.
      ENDLOOP.

    ENDIF.
  ENDDO.

ENDFORM.                    " at_user_command
*&---------------------------------------------------------------------*
*&      Form  write_screen
*&---------------------------------------------------------------------*
FORM WRITE_SCREEN.

  CLEAR KTAB.

  CLEAR STAB.
  REFRESH STAB.

  LOOP AT KTAB WHERE A EQ 'X'.

    SELECT * FROM SFLIGHT  APPENDING TABLE  STAB
                            WHERE CARRID EQ KTAB-CARRID AND
                                  CONNID EQ KTAB-CONNID    .


  ENDLOOP.


  SET PF-STATUS 'DE'.

  LOOP AT STAB.

    WRITE : /

               STAB-CARRID COLOR 4,
               STAB-CONNID COLOR 7 ,
               STAB-FLDATE COLOR 6 ,
               STAB-SEATSMAX COLOR 5 ,
               STAB-SEATSOCC COLOR 3 .



  ENDLOOP.


  LOOP AT KTAB.

    CLEAR KTAB-A.
*    MOVE ' ' TO ktab-a .
    MODIFY KTAB INDEX SY-TABIX.



  ENDLOOP.

ENDFORM.                    " write_screen
*&---------------------------------------------------------------------*
*&      Form  call_screen
*&---------------------------------------------------------------------*

FORM call_screen.

CALL SELECTION-SCREEN 123.

ENDFORM.                    " call_screen




*FORM FILL_TABLE USING VAR1 VAR2 VAR3.
*
*  MOVE: VAR1 TO XTAB-AD,
*        VAR2 TO XTAB-SOYAD,
*        VAR3 TO XTAB-YAS,
*        PAR1 TO XTAB-CONNID,
*        PAR2 TO XTAB-CARRID,
*        PAR3 TO XTAB-FLDATE,
*        CINSIYET TO XTAB-CINISIYET.
*
*  APPEND XTAB.
*
*  INSERT INTO ZNUFUS VALUES XTAB.
*
*ENDFORM.                    " FILL_TABLE
*&---------------------------------------------------------------------
*
*&      Form  DELETE_TABLE
*&---------------------------------------------------------------------
*

*FORM DELETE_TABLE USING    P_ADI  .
*
*
*  DELETE FROM ZNUFUS WHERE AD EQ P_ADI  .
*   INSERT INTO ZNUFUS VALUES XTAB.
*
*ENDFORM.                    " DELETE_TABLE

*&---------------------------------------------------------------------*
*&      Form  TABLE_MODIFY
*&---------------------------------------------------------------------*

*FORM MODIFY_TABLE USING P_ADI.
*
*UPDATE ZNUFUS  SET AD = 'UFO'  WHERE AD = P_ADI.
*
*ENDFORM.                    " TABLE_MODIFY
 
 
 
Serkan AKKAVAK
Bilgisayar Mühendisi
serkurumsal@yandex.com
SAP ve ABAP ile ilgili tüm sorularınızı gönderebilirsiniz.