Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29011
  • 博文数量: 10
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 120
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 19:21
文章分类

全部博文(10)

文章存档

2008年(10)

我的朋友

分类:

2008-09-05 12:13:32

  ***********************************************************************
**Program name: Z_DEFINE_INPUT
**Description : 数据的增加修改删除
**Date/Autohr :
************************************************************************
** M O D I F I C A T I O N  L O G
************************************************************************
** ChangeDate  Programmer  Request     Description
** ==========  ==========  ==========  =========================
**
************************************************************************
REPORT Z_DEFINE_INPUT
  NO STANDARD PAGE HEADING
  LINE-SIZE 120
  LINE-COUNT 90.
*** Global Data declear
INCLUDE Z_DEFINE_INPUTTOP.
INCLUDE Z_DEFINE_INPUT_GRID.
INCLUDE Z_DEFINE_INPUTPBO.
INCLUDE Z_DEFINE_INPUTPAI.
INCLUDE Z_DEFINE_INPUTF01.
*======================================================================*
*  Selection Screen Events
*======================================================================*
***  maintain selection screen output
AT SELECTION-SCREEN OUTPUT.
PERFORM txt_title.
*** F4 value help
*AT SELECTION-SCREEN ON VALUE-REQUEST for .
*** check input data
AT SELECTION-SCREEN.
PERFORM deal_screen.
*AT SELECTION-SCREEN ON .
*AT SELECTION-SCREEN ON BLOCK <>.
****CHECK ON SELECT SCREEN INPUT

*======================================================================*
*  Report Events
*======================================================================*
*** initial data
INITIALIZATION.

 create object main_grid.
*** prepare report data
START-OF-SELECTION.
   CALL SCREEN 3001.
*** output report
END-OF-SELECTION.
  *&---------------------------------------------------------------------*
*&  Include           Z_DEFINE_INPUTTOP
*&---------------------------------------------------------------------*
TABLES:VBAP,afko,marc,S031,ZCET,mast,stpo,ekko,ekpo,ZCET1.
data:okcode type sy-ucomm value ''.
data: g_custom_container type ref to cl_gui_custom_container.
data: get_row_id type lvc_t_row.
data: set_row_id type lvc_t_row.
data: get_row    like line of get_row_id.
data: set_row    like line of set_row_id.
data:isload1 type c.
data:edit_status1(2type c.
DATA:BEGIN OF IT_AFKO OCCURS 0,
     DEPT4 LIKE MARC-FEVOR,
     MONTH1 LIKE S031-SPMON,
     VBELN LIKE ZCET-VBELN,
*     POSNR TYPE VBAP-POSNR,
     POSNR(6TYPE C,"20080827
     MATNR LIKE ZCET-MATNR,
     STATUS(1TYPE C,
     PQTY LIKE AFKO-GAMNG,
     IQTY LIKE AFKO-GAMNG,
     PSIGN(1TYPE C,
     ISIGN(1TYPE C,
     PREASON(50TYPE C,
     IREASON(50TYPE C,
     END OF IT_AFKO.
DATA:BEGIN OF IT_AFKO1 OCCURS 0,
     DEPT4 LIKE MARC-FEVOR,
     MONTH1 LIKE S031-SPMON,
     VBELN LIKE ZCET-VBELN,
     POSNR TYPE VBAP-POSNR,
     POSNR1(6TYPE C,
     MATNR LIKE ZCET-MATNR,
     STATUS(1TYPE C,
     PQTY LIKE AFKO-GAMNG,
     IQTY LIKE AFKO-GAMNG,
     PSIGN(1TYPE C,
     ISIGN(1TYPE C,
     PREASON(50TYPE C,
     IREASON(50TYPE C,
     END OF IT_AFKO1.
selection-screen begin of  screen 4001.
selection-screen begin of block blk1.
selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt01.
  selection-screen position 15.
select-options :s_fevor for marc-fevor.
selection-screen end of line.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt02.
  selection-screen position 15.
  select-options: s_spmon for S031-SPMON.
selection-screen end of line.
selection-screen end of block blk1.
selection-screen end of  screen 4001.

selection-screen begin of  screen 4002.
selection-screen begin of block blk2.
selection-screen begin of line.
selection-screen position 1.
selection-screen comment 1(10) txt03.
selection-screen position 15.
parameters:dept4 like marc-fevor OBLIGATORY.
selection-screen end of line.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt04.
  selection-screen position 15.
  parameters:month1 like S031-SPMON OBLIGATORY.
selection-screen end of line.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt012.
  selection-screen position 15.
  parameters:VBELN like ZCET-VBELN OBLIGATORY.
selection-screen end of line.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt014.
  selection-screen position 15.
  parameters:POSNR like VBAP-POSNR." OBLIGATORY.
selection-screen end of line.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt013.
  selection-screen position 15.
  parameters:MATNR1 like ZCET-MATNR OBLIGATORY.
selection-screen end of line.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt05.
  selection-screen position 15.
  parameters:pqty like AFKO-GAMNG.

  selection-screen position 50.
  selection-screen comment 50(10) txt08.
  selection-screen position 65.
  parameters:psign LIKE ZCET-psign AS LISTBOX VISIBLE LENGTH 3.
selection-screen end of line.

SELECTION-SCREEN BEGIN OF LINE.
  SELECTION-SCREEN POSITION 1.
  SELECTION-SCREEN COMMENT 1(12) txt010.
  SELECTION-SCREEN POSITION 15.
  PARAMETERS:PREASON(50TYPE C.
SELECTION-SCREEN END OF LINE.

selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt06.
  selection-screen position 15.
  parameters:iqty like AFKO-GAMNG.

  selection-screen position 50.
  selection-screen comment 50(10) txt09.
  selection-screen position 65.
  parameters:isign(1type c AS LISTBOX VISIBLE LENGTH 3.
selection-screen end of line.

SELECTION-SCREEN BEGIN OF LINE.
  SELECTION-SCREEN POSITION 1.
  SELECTION-SCREEN COMMENT 1(12) txt011.
  SELECTION-SCREEN POSITION 15.
  PARAMETERS:IREASON(50TYPE C.
SELECTION-SCREEN END OF LINE.
selection-screen begin of line.
  selection-screen position 1.
  selection-screen comment 1(10) txt07.
  selection-screen position 15.
  parameters:status as CHECKBOX.
selection-screen end of line.
selection-screen end of block blk2.
selection-screen end of  screen 4002.
  *&---------------------------------------------------------------------*
*&  Include           Z_DEFINE_INPUT_GRID
*&---------------------------------------------------------------------*
class grid definition.
  public  section.
          methods:set_grid_header  importing
                                            fieldname      type lvc_fname  " IT'S CHAR TYPES(30)
                                            coltext        type lvc_txtcol " IT'S CHAR TYPES(40)
                                            outputlen      type lvc_outlen " IT'S NUMC TYPES(6)
                                            no_out         type c
                                            do_sum         type c
                                            no_sum         type c
                                            edit           type c
                                            is_chk         type c
                                            is_group_filed type c
                                            is_group_total type c.

          methods:set_container    importing container_name type ref to cl_gui_container.
          methods:set_grid_view    changing  datasource type standard table.
          methods:set_grid_name    importing name  type c.
          methods:handle_grid_doublu_click for event double_click of cl_gui_alv_grid importing e_row e_column es_row_no.
          methods:get_row_id       changing sel_rows type lvc_t_row.
          methods:set_grid_layout  changing layout type lvc_s_layo.
          "SET_SELECTED_ROWS
          methods:set_row_id       changing sel_rows type lvc_t_row.

private section.
**********----------------------------------------------------*
**********
**********----------------------------------------------------*
          data: col_index       type i.
          data: z_grid          type ref to cl_gui_alv_grid.
          data: gt_fieldcat     type lvc_t_fcat.
          data: it_fieldcat     like line of gt_fieldcat.
          data: gs_layout       type lvc_s_layo.
          data: t_fcodes        type ui_functions.
          data: grid_name(4)    type c value ''.
          data: s_sort          type  lvc_t_sort.
          data: l_s_sort        type  lvc_s_sort.
**********----------------------------------------------------*

**********----------------------------------------------------*
          data: g_custom_container type ref to cl_gui_custom_container.
endclass.

class grid implementation.

  method set_grid_header.
          col_index = col_index + 1.
          it_fieldcat-col_pos   = col_index.
          it_fieldcat-fieldname = fieldname.
          it_fieldcat-coltext   = coltext.
          it_fieldcat-no_out    = no_out.
          it_fieldcat-seltext   = coltext.
          it_fieldcat-edit      = edit.
          it_fieldcat-checkbox  = is_chk.
          it_fieldcat-do_sum    = do_sum.
          it_fieldcat-no_sum    = no_sum.
          if outputlen >= 0 .
             it_fieldcat-outputlen = outputlen.
          endif.
          if is_group_filed = 'X'.
             clear l_s_sort.
             l_s_sort-fieldname = fieldname.
             l_s_sort-subtot    = is_group_total.
             append l_s_sort to s_sort.
          endif.
          append it_fieldcat to gt_fieldcat.
  endmethod.



  method set_container.
       create object: z_grid             exporting i_parent       = container_name.

  endmethod.

  method set_grid_layout.
      gs_layout = layout.
  endmethod.

  method set_grid_view.
         refresh t_fcodes .
         append cl_gui_alv_grid=>mc_fc_expcrdata      to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_expcrdesig     to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_expcrtempl     to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_graph          to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_help           to t_fcodes.
         append cl_gui_alv_grid=>mc_mb_sum            to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_average        to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_to_office      to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_view_crystal   to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_send           to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_info           to t_fcodes.
         append cl_gui_alv_grid=>mc_fc_call_abc       to t_fcodes.

         call method z_grid->set_table_for_first_display
          exporting
                    is_layout            = gs_layout
                    it_toolbar_excluding = t_fcodes[]
          changing
                    it_outtab            = datasource
                    it_sort              = s_sort[]
                    it_fieldcatalog      = gt_fieldcat
          exceptions
            invalid_parameter_combination = 1.

         call method z_grid->refresh_table_display
                               exceptions
                               finished = 1
                               others = 2.
         set handler me->handle_grid_doublu_click for z_grid.

     endmethod.

     method set_grid_name.
           grid_name = name.

     endmethod.

     method handle_grid_doublu_click.
            "PERFORM METHOD_DOUBLE_CLICK USING E_ROW E_COLUMN ES_ROW_NO GRID_NAME.
     endmethod.
     method get_row_id.
           call method z_grid->get_selected_rows importing et_index_rows = sel_rows.
     endmethod.
     method set_row_id.
           call method z_grid->set_selected_rows exporting it_index_rows = sel_rows.
     endmethod.
endclass.

data:main_grid type ref to grid.
data:main_grid1 type ref to grid. "davidzhang
  *&---------------------------------------------------------------------*
*&  Include           Z_DEFINE_INPUTPBO
*&---------------------------------------------------------------------*
MODULE STATUS_3001 OUTPUT.
  SET PF-STATUS 'Z_TOOLBAR3'.
  if isload1 = ''.
    isload1 = 'X'.
    CREATE OBJECT main_grid1.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'DEPT4'
        coltext        = '部門'
        outputlen      = 8
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'MONTH1'
        coltext        = '月份'
        outputlen      = 8
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'VBELN'
        coltext        = '銷售單'
        outputlen      = 10
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'POSNR'
        coltext        = '銷售單項目'
        outputlen      = 10
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'MATNR'
        coltext        = '產品型號'
        outputlen      = 10
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'PQTY'
        coltext        = '計劃數量'
        outputlen      = 10
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'PSIGN'
        coltext        = '計劃數量變化'
        outputlen      = 12
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'PREASON'
        coltext        = '計劃數量調整原因'
        outputlen      = 12
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'IQTY'
        coltext        = '入庫數量'
        outputlen      = 10
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'ISIGN'
        coltext        = '入庫數量變化'
        outputlen      = 12
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'IREASON'
        coltext        = '入庫數量調整原因'
        outputlen      = 12
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.
    call method main_grid1->set_grid_header
      EXPORTING
        fieldname      = 'STATUS'
        coltext        = '狀態'
        outputlen      = 5
        no_out         = ''
        do_sum         = ''
        no_sum         = ''
        edit           = ''
        is_chk         = ''
        is_group_filed = ''
        is_group_total = ''.

    create object: g_custom_container exporting container_name = 'CUS1'.
    call method main_grid1->set_container
      EXPORTING
        container_name = g_custom_container.
    call method main_grid1->set_grid_name
      EXPORTING
        name = 'MAN1'.
    data:gs_layout1 type lvc_s_layo.
    gs_layout1-detailtitl = ''.
    gs_layout1-sel_mode   = 'D'.
    gs_layout1-smalltitle = 'X'.
    gs_layout1-no_toolbar = ''.
    gs_layout1-zebra      = 'X'.
    gs_layout1-no_rowmark = ''.
*    gs_layout1-CWIDTH_OPT     = 'X'.
    call method main_grid1->set_grid_layout
      CHANGING
        layout = gs_layout1.
    call method main_grid1->set_grid_view
      CHANGING
        datasource = IT_AFKO[].
  ENDIF.
ENDMODULE.                 " STATUS_3001  OUTPUT
  *&---------------------------------------------------------------------*
*&  Include           Z_DEFINE_INPUTPAI
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_3001  INPUT
*&---------------------------------------------------------------------*
MODULE USER_COMMAND_3001 INPUT.
*          PERFORM getdata.
          PERFORM set_sign.
   okcode = sy-ucomm.
   case okcode.
     when 'QUERY1'.
        call selection-screen 4001 starting at 20 5 ending at 90 8 .
     when 'EDIT1'.
        edit_status1 = '編輯'.
        PERFORM edit1_info.
     when 'ADD'.
        edit_status1 = '新增'.
        call selection-screen 4002 starting at 20 5 ending at 100 15 .
     when 'DEL1'.
        PERFORM del1_info.
     when 'EXIT'.
       LEAVE TO SCREEN 0.
   endcase.
   clear okcode.
ENDMODULE.                 " USER_COMMAND_3001  INPUT
  *&---------------------------------------------------------------------*
*&  Include           Z_DEFINE_INPUTF01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  txt_title
*&---------------------------------------------------------------------*
FORM txt_title .
    txt01  = '生產部門:'.
    txt02  = '生產月份:'.
    txt03  = '生產部門:'.
    txt04  = '生產月份:'.
    txt05  = '計劃數量:'.
    txt06  = '入庫數量:'.
    txt07  = '狀態:'.
    txt08  = '數量增減:'.
    txt09  = '數量增減:'.
    txt010  = '計劃數量調整原因:'.
    txt011  = '入庫數量調整原因:'.
    txt012  = '銷售單號:'.
    txt013 = '產品型號:'.
    txt014 = '銷售單ITEM'.
ENDFORM.                    " txt_title
*&---------------------------------------------------------------------*
*&      Form  deal_screen
*&---------------------------------------------------------------------*
FORM deal_screen .
    okcode = sy-ucomm.
    case sy-dynnr.
        when '4001'."QUERY  dacidzhang added
          case okcode.
            when 'CRET'.
*              if s_fevor <> '' and s_spmon <> ''.
               PERFORM query_info1.
               call method   main_grid1->set_grid_view
                 changing datasource = IT_AFKO[].
*              endif.
          endcase.
       when '4002'.  "ADD
         case okcode.
           when 'CRET'.
             case edit_status1.
               when '新增'.
                 PERFORM modify_info.
                 call method   main_grid1->set_grid_view
                 changing datasource = IT_AFKO[].
               when '編輯'.
                 PERFORM save_info1.
                 call method   main_grid1->set_grid_view
                 changing datasource = IT_AFKO[].
            endcase.
         endcase.
     endcase.
     okcode = ''.
ENDFORM.                    " deal_screen
*&---------------------------------------------------------------------*
*&      Form  modify_info
*&---------------------------------------------------------------------*
FORM modify_info .
DATA:VBELN1 LIKE VBAP-VBELN,
      MATNR2 TYPE VBAP-MATNR,
      IDNRK1 TYPE STPO-IDNRK,
      EBELN LIKE EKKO-EBELN,
      MATNR LIKE VBAP-MATNR,
      IDNRK LIKE VBAP-MATNR.
  SELECT SINGLE VBELN MATNR
    INTO (VBELN1, MATNR2)
    FROM VBAP
    WHERE VBELN = VBELN
*    AND POSNR = POSNR
    AND   MATNR = MATNR1.
 IF SY-SUBRC <> 0.
     SELECT SINGLE VBAP~VBELN VBAP~MATNR
     INTO (VBELN1, MATNR2)
     FROM VBAK JOIN VBAP ON VBAK~VBELN = VBAP~VBELN
     WHERE VBAK~VBELN = VBELN
     AND   VBAK~AUART = 'ZFDS'.

     SELECT SINGLE IDNRK
     INTO IDNRK1
     FROM MAST JOIN STPO ON MAST~STLNR = STPO~STLNR
     WHERE STPO~IDNRK = MATNR1
     AND   MAST~MATNR = MATNR2.

     IF SY-SUBRC <> 0.
       SELECT SINGLE EKKO~EBELN EKPO~MATNR
       INTO (EBELN, MATNR)
       FROM EKKO JOIN EKPO ON EKKO~EBELN = EKPO~EBELN
       WHERE EKKO~EBELN = VBELN
       AND   EKPO~EBELP = POSNR
       AND   EKKO~BSART = 'ZFST'
       AND   EKKO~BUKRS = '6000'.

       SELECT SINGLE IDNRK
       INTO IDNRK
       FROM MAST JOIN STPO ON MAST~STLNR = STPO~STLNR
       WHERE STPO~IDNRK = MATNR1
       AND   MAST~MATNR = MATNR.
       IF SY-SUBRC <> 0.
          MESSAGE '請輸入有效的銷售單和產品型號!' type 'I'.
       ELSE.
          CLEAR IT_AFKO.
          IT_AFKO-DEPT4 = DEPT4.
          IT_AFKO-MONTH1 = MONTH1.
          IT_AFKO-STATUS = STATUS.
          IT_AFKO-PQTY = PQTY.
          IT_AFKO-IQTY = IQTY.
          IT_AFKO-PSIGN = PSIGN.
          IT_AFKO-ISIGN = ISIGN.
          IT_AFKO-PREASON = PREASON.
          IT_AFKO-IREASON = IREASON.
          IT_AFKO-VBELN = VBELN.
          IT_AFKO-MATNR = MATNR1.
          IT_AFKO-POSNR = POSNR.
          INSERT INTO ZCET1 VALUES IT_AFKO.
          if sy-subrc = 0.
             commit work.
             message '新增成功!' type 'I'.
             perform query_info2.
          else.
             rollback work.
             message '新增失敗!' type 'I'.
          endif.
       ENDIF.
     ELSE.
          CLEAR IT_AFKO.
          IT_AFKO-DEPT4 = DEPT4.
          IT_AFKO-MONTH1 = MONTH1.
          IT_AFKO-STATUS = STATUS.
          IT_AFKO-PQTY = PQTY.
          IT_AFKO-IQTY = IQTY.
          IT_AFKO-PSIGN = PSIGN.
          IT_AFKO-ISIGN = ISIGN.
          IT_AFKO-PREASON = PREASON.
          IT_AFKO-IREASON = IREASON.
          IT_AFKO-VBELN = VBELN.
          IT_AFKO-MATNR = MATNR1.
          IT_AFKO-POSNR = POSNR.
          INSERT INTO ZCET1 VALUES IT_AFKO.
          if sy-subrc = 0.
             commit work.
             message '新增成功!' type 'I'.
             perform query_info2.
          else.
             rollback work.
             message '新增失敗!' type 'I'.
          endif.
     ENDIF.
 ELSE.
      CLEAR IT_AFKO.
      IT_AFKO-DEPT4 = DEPT4.
      IT_AFKO-MONTH1 = MONTH1.
      IT_AFKO-STATUS = STATUS.
      IT_AFKO-PQTY = PQTY.
      IT_AFKO-IQTY = IQTY.
      IT_AFKO-PSIGN = PSIGN.
      IT_AFKO-ISIGN = ISIGN.
      IT_AFKO-PREASON = PREASON.
      IT_AFKO-IREASON = IREASON.
      IT_AFKO-VBELN = VBELN.
      IT_AFKO-MATNR = MATNR1.
      IT_AFKO-POSNR = POSNR.
      INSERT INTO ZCET1 VALUES IT_AFKO.
      if sy-subrc = 0.
         commit work.
         message '新增成功!' type 'I'.
         perform query_info2.
      else.
         rollback work.
         message '新增失敗!' type 'I'.
      endif.
ENDIF.
ENDFORM.                    " modify_info
*&---------------------------------------------------------------------*
*&      Form  query_info1
*&---------------------------------------------------------------------*
FORM query_info1 .
CLEAR IT_AFKO.
SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_AFKO
FROM ZCET1
WHERE DEPT4 IN S_FEVOR
AND   MONTH1 IN S_SPMON.
LOOP AT IT_AFKO.
  SHIFT IT_AFKO-POSNR BY 1 PLACES RIGHT.
  SHIFT IT_AFKO-POSNR BY 3 PLACES LEFT.
*  IT_AFKO1-POSNR1 = IT_AFKO1-POSNR.
  MODIFY IT_AFKO.
  CLEAR IT_AFKO.
ENDLOOP.
ENDFORM.                    " query_info1
*&---------------------------------------------------------------------*
*&      Form  query_info2
*&---------------------------------------------------------------------*
FORM query_info2 .
CLEAR IT_AFKO.
SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_AFKO
  FROM ZCET1
  WHERE DEPT4 = DEPT4 AND MONTH1 = MONTH1.
LOOP AT IT_AFKO.
  SHIFT IT_AFKO-POSNR BY 1 PLACES RIGHT.
  SHIFT IT_AFKO-POSNR BY 3 PLACES LEFT.
*    IT_AFKO1-POSNR1 = IT_AFKO1-POSNR.
  MODIFY IT_AFKO.
  CLEAR IT_AFKO.
ENDLOOP.
ENDFORM.                    " query_info2
*&---------------------------------------------------------------------*
*&      Form  edit1_info
*&---------------------------------------------------------------------*
FORM edit1_info .
     call method main_grid1->get_row_id changing sel_rows = get_row_id.
     data:sel_row_id type lvc_index.
     loop at get_row_id into get_row.
          sel_row_id = get_row-index.
          exit.
     endloop.
     if sel_row_id > 0.
*         clear ZCET.
         read table IT_AFKO index sel_row_id.
*         if IT_AFKO-STATUS <> ''.
*             message '已經審核的資料不能被修改,請重新選擇!' type 'I'.
*         else.
             DEPT4   =  IT_AFKO-DEPT4.
             MONTH1  =  IT_AFKO-MONTH1.
             PQTY    = IT_AFKO-PQTY.
             IQTY    = IT_AFKO-IQTY.
             PSIGN   = IT_AFKO-PSIGN.
             ISIGN   = IT_AFKO-ISIGN.
             STATUS  = IT_AFKO-STATUS.
             PREASON = IT_AFKO-PREASON.
             IREASON =  IT_AFKO-IREASON.
             VBELN = IT_AFKO-VBELN.
             MATNR1 = IT_AFKO-MATNR.
             POSNR = IT_AFKO-POSNR.
*             ischk = '1'.
             call selection-screen 4002 starting at 20 5 ending at 90 15 .
*        endif.
     else.
         message '請選擇需要編輯的資料!' type 'I'.
     endif.
ENDFORM.                    " edit1_info
*&---------------------------------------------------------------------*
*&      Form  del1_info
*&---------------------------------------------------------------------*
FORM del1_info .
     call method main_grid1->get_row_id changing sel_rows = get_row_id.
     data:sel_row_id type lvc_index.
     data:index type i value 0.
     data:isok  type c value ''.
     loop at get_row_id into get_row.
          sel_row_id = get_row-index.
          index = index + 1.
     endloop.
     if index > 0.
         data: answer(1type c.
         call function 'POPUP_TO_CONFIRM_STEP'
         exporting
            defaultoption = 'Y'
            textline1     = '你確認要刪除這些資料嗎,已經被審核的資料將不會刪除?'
            titel         = '系統提示'
            cancel_display = ''
          importing
            answer = answer.
         if answer = 'J' .
             loop at get_row_id into get_row.
*                 clear zding.
                 sel_row_id = get_row-index.
                 READ TABLE IT_AFKO INDEX sel_row_id.
                 if IT_AFKO-STATUS = ''.
*                     delete from zding where id = zding-id.
                   DELETE FROM ZCET1 WHERE DEPT4 = IT_AFKO-DEPT4
                          AND MONTH1 = IT_AFKO-MONTH1
                          AND STATUS = ''.
                   DELETE IT_AFKO INDEX sel_row_id.
                     if sy-subrc = 0.
                          commit work.
                          isok = 'X'.
                     else.
                          rollback work.
                          isok = ''.
                          exit.
                          message '刪除失敗!' type 'I'.
                     endif.
                 endif.
                 clear get_row.
                 CLEAR IT_AFKO.
*                 clear zding.
             endloop.
         endif.
     else.
        message '請先選擇需要刪除的記錄!' type 'I'.
     endif.
*     clear zding.
     if isok = 'X'.
call method   main_grid1->set_grid_view   changing datasource = IT_AFKO[].
        clear set_row.
        refresh set_row_id.
        set_row-index = sel_row_id.
        append set_row to set_row_id.
        call method main_grid1->set_row_id changing sel_rows = set_row_id.
     endif.
ENDFORM.                    " del1_info
*&---------------------------------------------------------------------*
*&      Form  set_sign
*&---------------------------------------------------------------------*
FORM set_sign .
type-pools vrm.
  data: l_values type line of vrm_values,
        lt_values type vrm_values.

  l_values-key = '+'.
  l_values-text = '+'.
  append l_values to lt_values.

  l_values-key = '-'.
  l_values-text = '-'.
  append l_values to lt_values.

  call function 'VRM_SET_VALUES'
    exporting
      id              = 'psign'
      values          = lt_values
    exceptions
      id_illegal_name = 1
      others          = 2.

    call function 'VRM_SET_VALUES'
    exporting
      id              = 'isign'
      values          = lt_values
    exceptions
      id_illegal_name = 1
      others          = 2.
  clear lt_values[].
ENDFORM.                    " set_sign
*&---------------------------------------------------------------------*
*&      Form  save_info1
*&---------------------------------------------------------------------*
FORM save_info1 .
 CLEAR IT_AFKO.
 IT_AFKO-DEPT4 = DEPT4.
 IT_AFKO-MONTH1 = MONTH1.
 IT_AFKO-STATUS = STATUS.
 IT_AFKO-PQTY = PQTY.
 IT_AFKO-IQTY = IQTY.
 IT_AFKO-PSIGN = PSIGN.
 IT_AFKO-ISIGN = ISIGN.
 IT_AFKO-PREASON = PREASON.
 IT_AFKO-IREASON = IREASON.
 IT_AFKO-MATNR = MATNR1.
 IT_AFKO-VBELN = VBELN.
 IT_AFKO-POSNR = POSNR.
* DELETE FROM ZCET WHERE DEPT4 LIKE '%'.
*    INSERT INTO ZCET VALUES IT_AFKO.
  UPDATE ZCET1 FROM IT_AFKO.
*   MODIFY ZCET FROM IT_AFKO.
     if sy-subrc = 0.
          commit work.
          message '修改成功!' type 'I'.
          perform query_info2.
     else.
          rollback work.
          message '修改失敗!' type 'I'.
     endif.
ENDFORM.                    " save_info1

阅读(904) | 评论(0) | 转发(0) |
0

上一篇:alv grid的用法

下一篇:在路上

给主人留下些什么吧!~~