***********************************************************************
* Title : *
* Application : MM   *
* Subject : 农户基本信息的维护程序 *
* Requested by : (YH_MM) *
* Execution : Online when required *
* Ref no: : *
* Author : *
* Req Date : 20120709 *
***********************************************************************
*     农户信息及商品关系维护程序 *
***********************************************************************
*     设计主要逻辑与原理说明 ::: *
***********************************************************************
* 1.程序流程及功能:自建农户基表创建农户基本信息的新增,修改,及查询 *
* 2,取数:从自建农户基本信息表中取得需要展示的数据用ALV显示. *
* 3.输入:农户名称,身份证号码。 *
* 4.输出:农户编码, 农户名称,身份证号码,状态。 *
* 5.事件:用Tabel Control实现自建表的新增功能用ALV实现自建表的修改功能*
***********************************************************************
***********************************************************************
* MODIFICATIONS (latest entry at the top) *
* ------------------------------------------------------------------- *
* REL DATE NAME (COMPANY) DESCRIPTION TASK-NO *
* --- ---- ---- --------- ----------- ------- *
* *
***********************************************************************
REPORT YHMMR003 NO STANDARD PAGE HEADING
LINE-SIZE
LINE-COUNT ()
MESSAGE-ID YH_MM1. *---------------------------------------------------------------------------------
*---------------------- 声明类型池----------------------*
*---------------------------------------------------------------------------------
TYPE-POOLS: SLIS,
VRM. *---------------------------------------------------------------------------------
*----------------------声明数据字典---------------------*
*---------------------------------------------------------------------------------
TABLES: YTNAH,
YTNHCG. *---------------------------------------------------------------------------------
*--------------------- 结构定义-------------------------*
*---------------------------------------------------------------------------------
TYPES: BEGIN OF TY_YTNAH,
NHBM TYPE YTNAH-NHBM,
NHMC TYPE YTNAH-NHMC,
SFZHM TYPE YTNAH-SFZHM,
ZHTA TYPE YTNAH-ZHTA,
CPUTM TYPE YTNAH-CPUTM,
AEDAT TYPE YTNAH-AEDAT,
USNAM TYPE YTNAH-USNAM,
END OF TY_YTNAH.
TYPES: TY_TAB_YTNAH TYPE TY_YTNAH OCCURS .
DATA: G_LINE TYPE I.
DATA :BEGIN OF GT_ITAB OCCURS .
INCLUDE STRUCTURE YTNAH.
DATA: SEL TYPE C,
UPD.
DATA: END OF GT_ITAB. DATA: WA_TAB LIKE GT_ITAB.
DATA: WA_TAB1 LIKE GT_ITAB. DATA :BEGIN OF GT_ITAB1 OCCURS .
INCLUDE STRUCTURE YTNAH.
DATA: SEL TYPE C,
UPD.
DATA: END OF GT_ITAB1. *---------------------------------------------------------------------------------
*----------------------- 内表定义 -----------------------*
*--------------------------------------------------------------------------------- DATA: BEGIN OF GT_DATA OCCURS .
INCLUDE STRUCTURE YTNAH.
DATA: ROWCOLOR() TYPE C,
CELLCOLOR TYPE LVC_T_SCOL,
PEYPE_DD_HNDL TYPE INT4.
DATA: END OF GT_DATA.
DATA: WA_DATA LIKE GT_DATA. DATA: GT_CHANGE TYPE TABLE OF YTNAH WITH HEADER LINE,
GT_CH TYPE TABLE OF YTNAH WITH HEADER LINE,
WA_CHANGE TYPE YTNAH.
DATA: GT_YTNAH TYPE TABLE OF YTNAH WITH HEADER LINE,
WA_YTNAH TYPE YTNAH. *---------------------------------------------------------------------------------
*---------------------- ALV参数定义 ---------------------*
*---------------------------------------------------------------------------------
DATA: G_PROGRAM TYPE SY-REPID,
GW_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
GT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
*---------------------------------------------------------------------------------
*--------------------- 常量定义 -------------------------*
*---------------------------------------------------------------------------------
DATA: G_LINNO LIKE SY-TABIX,
G_LINES TYPE I,
G_LINES1 TYPE I,
G_CREA TYPE C,
G_COUNT TYPE I. *&SPWIZARD: LINES OF TABLECONTROL 'TC_ITEM'
DATA: G_TC_ITEM_LINES LIKE SY-LOOPC.
*&SPWIZARD: LINES OF TABLECONTROL 'TC_ITEM1'
DATA: G_TC_ITEM1_LINES LIKE SY-LOOPC.
*---------------------------------------------------------------------------------
*--------------------- 全局变量定义 ----------------------*
*---------------------------------------------------------------------------------
DATA: G_INDEX TYPE SY-TABIX.
DATA: OK_CODE TYPE SY-UCOMM,
G_DUP_FLAG TYPE C.
DATA G_ANSWER TYPE C.
DATA: VID TYPE VRM_ID,
VLIST TYPE VRM_VALUES,
WA_VALUE LIKE LINE OF VLIST.
*---------------------------------------------------------------------------------
*--------------------- 屏幕定义 --------------------------*
*---------------------------------------------------------------------------------
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_ITEM' ITSELF
CONTROLS: TC_ITEM TYPE TABLEVIEW USING SCREEN .
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_ITEM1' ITSELF
CONTROLS: TC_ITEM1 TYPE TABLEVIEW USING SCREEN . *=================================================================================
* SELECTION-SCREEN
*=================================================================================
SELECTION-SCREEN BEGIN OF BLOCK BLK0 WITH FRAME TITLE TEXT-.
SELECTION-SCREEN SKIP .
*& 农户编码
*& 身份证号码
SELECT-OPTIONS: S_NHBM FOR YTNAH-NHBM MATCHCODE OBJECT YH_NHBM NO-EXTENSION NO INTERVALS,
S_SFZHM FOR YTNAH-SFZHM MATCHCODE OBJECT YH_SFZHM ,
*& 农户采购组织区分标识:
S_NHSIG FOR YTNHCG-NHSIG NO INTERVALS NO-EXTENSION
MATCHCODE OBJECT YH_NHSIG ." OBLIGATORY. "农户对应的采购组织信息。 *& 查询
*& 修改
*& 新增
PARAMETERS: RB_QUERY RADIOBUTTON GROUP G1,
RB_CHANG RADIOBUTTON GROUP G1,
RB_ADD RADIOBUTTON GROUP G1. " DEFAULT 'X'. SELECTION-SCREEN END OF BLOCK BLK0. *----------------------------------------------------------------------
* INITIALIZATION
*----------------------------------------------------------------------
INITIALIZATION. * 初始化数据
* PERFORM frm_initial. *----------------------------------------------------------------------
* AT SELECTION-SCREEN
*----------------------------------------------------------------------
AT SELECTION-SCREEN. PERFORM FRM_INIT_DATA.
* 权限检查部分
PERFORM FRM_CHECK_AUTHOR. *=================================================================================
* MAIN PROGRAM
*=================================================================================
*---------------------------------------------------------------------------------
* START-OF-SELECTION
*---------------------------------------------------------------------------------
START-OF-SELECTION.
*&S1 查询时
IF RB_QUERY IS NOT INITIAL.
*&S1.1取数
PERFORM FRM_GET_DATA.
*&S1.2ALV显示
PERFORM FRM_OUTPUT_DATA.
ENDIF. *&S2 修改时
IF RB_CHANG IS NOT INITIAL.
CLEAR: GT_DATA, WA_DATA.
*&S2.1获取修改数据
PERFORM GET_DATA_MODIFY.
*&S2.2数据修改操作
PERFORM FRM_MODIFY_DATA.
ENDIF. *&S3 TB维护农户表
IF RB_ADD NE SPACE.
*& 以采购组织对农户进行区分:
IF S_NHSIG IS INITIAL.
MESSAGE I006 WITH '请选择创建农户对应的采购组织!!!'.
STOP.
ENDIF. TC_ITEM-LINES = .
TC_ITEM-TOP_LINE = . *& 进行维护的时候,锁定数据表。
PERFORM FRM_LOCK_YTNAH USING SY-MANDT.
CALL SCREEN .
ENDIF.
*---------------------------------------------------------------------------------
* END-OF-SELECTION
*--------------------------------------------------------------------------------- *&---------------------------------------------------------------------*
*& Form FRM_INIT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_INIT_DATA .
*& 查询时候的必输条件:
IF RB_QUERY IS NOT INITIAL.
IF S_NHBM IS INITIAL.
MESSAGE I006 WITH '请输入农户编码作为查询条件!'.
STOP.
ENDIF.
ENDIF. *& 修改时候的必输条件:
IF RB_CHANG IS NOT INITIAL.
IF S_NHBM IS INITIAL.
MESSAGE I006 WITH '请输入农户编码作为查询条件!'.
STOP.
ENDIF.
ENDIF. ENDFORM. " FRM_INIT_DATA *&---------------------------------------------------------------------*
*& Form FRM_CHECK_AUTHOR
*&---------------------------------------------------------------------*
* *& 权限检查
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_AUTHOR . * AUTHORITY-CHECK OBJECT 'M_MATE_WGR'
* ID 'ADD' FIELD RB_ADD
* ID 'ACTVT' FIELD '01'.
* IF SY-SUBRC <> 0.
* MESSAGE i012 with '没有农户信息' RB_ADD '创建的权限!'.
* stop.
* ENDIF. ENDFORM. " FRM_CHECK_AUTHOR *&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
* 从数据表中取数(从自建表ytnah中取数到gt_data)
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA . *&S1.1.1从农户表中取得数据
SELECT NHBM
NHMC
SFZHM
ZHTA
CPUTM
AEDAT
USNAM
INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM YTNAH
WHERE NHBM IN S_NHBM
AND SFZHM IN S_SFZHM. *&S1.1.2检查有没有数据
DESCRIBE TABLE GT_DATA LINES G_LINES.
IF G_LINES = .
MESSAGE I001 WITH '根据查询条件未找到数据!'.
STOP.
ENDIF. *&S1.1.3内表排序:
SORT GT_DATA BY NHBM. ENDFORM. " frm_get_data *&---------------------------------------------------------------------*
*& Form FRM_OUTPUT_DATA
*&---------------------------------------------------------------------*
* ALV显示
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_OUTPUT_DATA . DEFINE ADD_FIELDCAT.
CLEAR WA_FIELDCAT. WA_FIELDCAT-FIELDNAME = &.
WA_FIELDCAT-SELTEXT_L = &.
WA_FIELDCAT-COL_POS = &.
WA_FIELDCAT-JUST = &.
WA_FIELDCAT-OUTPUTLEN = &.
WA_FIELDCAT-FIX_COLUMN = &.
WA_FIELDCAT-CHECKBOX = &. APPEND WA_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION. CLEAR GT_FIELDCAT. ADD_FIELDCAT 'NHBM' '农户编码' 'L' '' ''.
ADD_FIELDCAT 'NHMC' '农户名称' 'L' '' ''.
ADD_FIELDCAT 'SFZHM' '身份证号码' 'L' '' ''.
ADD_FIELDCAT 'ZHTA' '状态' 'R' '' ''.
ADD_FIELDCAT 'CPUTM' '输入时间' 'L' '' ''.
ADD_FIELDCAT 'AEDAT' '更改时间' 'L' '' ''.
ADD_FIELDCAT 'USNAM' '用户名' 'L' '' ''. GW_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "优化列 G_PROGRAM = SY-REPID. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_PROGRAM
IS_LAYOUT = GW_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_DATA. ENDFORM. " FRM_OUTPUT_DATA *&---------------------------------------------------------------------*
*& Form GET_DATA_MODIFY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA_MODIFY . *&S2.1.1从农户表中取得数据
SELECT NHBM
NHMC
SFZHM
ZHTA
CPUTM
AEDAT
USNAM
INTO CORRESPONDING FIELDS OF TABLE GT_CHANGE
FROM YTNAH
WHERE NHBM IN S_NHBM
AND SFZHM IN S_SFZHM. *&2.1.2检查有没有数据
DESCRIBE TABLE GT_CHANGE LINES G_LINES.
IF G_LINES = .
MESSAGE E001 WITH '根据查询条件未找到数据!'.
STOP.
ENDIF.
*&2.1.3内表排序:
SORT GT_CHANGE BY NHBM. ENDFORM. " GET_DATA_MODIFY *&---------------------------------------------------------------------*
*& Form FRM_MODIFY_DATA
*&---------------------------------------------------------------------*
* ALV显示,然后用ALV界面进行修改
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_MODIFY_DATA . CLEAR WA_EVENT.
MOVE 'PF_STATUS_SET' TO WA_EVENT-NAME.
MOVE 'F_PF_STATUS_SET' TO WA_EVENT-FORM.
APPEND WA_EVENT TO GT_EVENT. CLEAR WA_EVENT.
MOVE 'USER_COMMAND' TO WA_EVENT-NAME.
MOVE 'F_USER_COMMAND' TO WA_EVENT-FORM.
APPEND WA_EVENT TO GT_EVENT. DEFINE ADD_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = &.
WA_FIELDCAT-SELTEXT_L = &.
WA_FIELDCAT-COL_POS = &.
WA_FIELDCAT-JUST = &.
WA_FIELDCAT-OUTPUTLEN = &.
WA_FIELDCAT-FIX_COLUMN = &.
WA_FIELDCAT-CHECKBOX = &.
WA_FIELDCAT-EDIT = &.
WA_FIELDCAT-EDIT_MASK = &.
* wa_fieldcat-datatype = &10. APPEND WA_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION. CLEAR GT_FIELDCAT. ADD_FIELDCAT 'NHBM' '农户编码' 'L' '' '' '' '' .
ADD_FIELDCAT 'NHMC' '农户名称' 'L' '' '' 'X' '' .
ADD_FIELDCAT 'SFZHM' '身份证号码' 'L' '' '' 'X' '' .
ADD_FIELDCAT 'ZHTA' '状态' 'R' '' '' 'X' '' .
ADD_FIELDCAT 'CPUTM' '输入时间' 'L' '' '' '' '' .
ADD_FIELDCAT 'AEDAT' '更改时间' 'L' '' '' '' '' .
ADD_FIELDCAT 'USNAM' '用户名' 'L' '' '' '' ' '. GW_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "优化列
GW_LAYOUT-BOX_FIELDNAME = 'ZSEL'.
G_PROGRAM = SY-REPID. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_PROGRAM
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
IS_LAYOUT = GW_LAYOUT
IT_FIELDCAT = GT_FIELDCAT
I_SAVE = 'A'
IT_EVENTS = GT_EVENT
TABLES
T_OUTTAB = GT_CHANGE
EXCEPTIONS
PROGRAM_ERROR =
OTHERS = .
IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. ENDFORM. "FRM_MODIFY_DATA *&---------------------------------------------------------------------*
*& ALV EVENT Form FRM_SET_LAYOUT
*& ALV状态栏事件 状态:STATUS
*&---------------------------------------------------------------------*
FORM F_PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB. SET PF-STATUS '' EXCLUDING EXTAB. ENDFORM. "f_pf_status_set *&---------------------------------------------------------------------*
*& ALV EVENT Form f_user_command
*&---------------------------------------------------------------------*
FORM F_USER_COMMAND USING RF_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD. DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = LR_GRID.
CALL METHOD LR_GRID->CHECK_CHANGED_DATA.
CALL METHOD LR_GRID->REFRESH_TABLE_DISPLAY. RS_SELFIELD-REFRESH = 'X'. CASE RF_UCOMM. **& 删除操作
* WHEN 'DELETE'.
* CLEAR OK_CODE.
* PERFORM FRM_DELETE_DATA_ALV. *& 保存操作
WHEN 'SAVE'.
CLEAR OK_CODE.
PERFORM FRM_SAVE_DATA_ALV. *& 退出操作
WHEN 'BACK'.
CLEAR OK_CODE.
PERFORM FRM_UNLOCK USING SY-MANDT.
LEAVE TO SCREEN . WHEN OTHERS. CLEAR OK_CODE. ENDCASE.
ENDFORM. " f_user_command *&---------------------------------------------------------------------*
*& Form FRM_DELETE_DATA_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DELETE_DATA_ALV .
DATA: L_INDEX TYPE SY-TABIX.
*& 检查数据是否存在:
PERFORM FRM_CHECK_YTNAM. CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = '确认'
TEXT_QUESTION = '确定删除此信息吗?'
TEXT_BUTTON_1 = '是'
TEXT_BUTTON_2 = '否'
DEFAULT_BUTTON = ''
DISPLAY_CANCEL_BUTTON = ' '
START_COLUMN =
START_ROW =
POPUP_TYPE = 'ICON_MESSAGE_WARNING'
IMPORTING
ANSWER = G_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND =
OTHERS = .
CHECK G_ANSWER EQ ''. *& 修改时候删除记录操作:
LOOP AT GT_CHANGE INTO WA_CHANGE WHERE ZSEL <> SPACE.
L_INDEX = SY-TABIX.
* DELETE GT_CHANGE INDEX L_INDEX.
DELETE ytnah FROM GT_CHANGE.
IF SY-SUBRC EQ .
DELETE GT_CHANGE INDEX L_INDEX.
ENDIF. ENDLOOP. ENDFORM. " FRM_DELETE_DATA_ALV *&---------------------------------------------------------------------*
*& Form FRM_SAVE_DATA_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SAVE_DATA_ALV .
PERFORM FRM_LOCK_YTNAH USING SY-MANDT. PERFORM FRM_CHECK_ZHTA. CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = '确认'
TEXT_QUESTION = '你真的要保存修改农户信息吗?'
TEXT_BUTTON_1 = '是'
TEXT_BUTTON_2 = '否'
DEFAULT_BUTTON = ''
DISPLAY_CANCEL_BUTTON = ' '
START_COLUMN =
START_ROW =
POPUP_TYPE = 'ICON_MESSAGE_WARNING'
IMPORTING
ANSWER = G_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND =
OTHERS = .
CHECK G_ANSWER EQ ''. *& 时间,日期,用户赋值:
LOOP AT GT_CHANGE WHERE NHBM IS NOT INITIAL.
MOVE: SY-UZEIT TO GT_CHANGE-CPUTM,
SY-DATUM TO GT_CHANGE-AEDAT,
SY-UNAME TO GT_CHANGE-USNAM.
MODIFY GT_CHANGE.
ENDLOOP. *&888:通过内表更新数据表:
MODIFY YTNAH FROM TABLE GT_CHANGE.
IF SY-SUBRC EQ .
COMMIT WORK.
MESSAGE S006 WITH '数据保存成功!'.
ELSE.
ROLLBACK WORK.
MESSAGE S006 WITH '数据保存失败!'.
ENDIF. ENDFORM. " FRM_SAVE_DATA_ALV *&---------------------------------------------------------------------*
*& Form FRM_CHECK_ZHTA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_ZHTA . DATA: BEGIN OF LT_NHBM OCCURS ,
NHBM LIKE YTNAH-NHBM,
END OF LT_NHBM. DATA: L_NHBM LIKE YTNAH-NHBM,
L_NHMC LIKE YTNAH-NHMC. DATA: L_LINES TYPE I.
*& 身份证重复性检查
IF GT_CHANGE-NHMC NE SPACE
AND GT_CHANGE-SFZHM NE SPACE
AND GT_CHANGE-ZHTA NE SPACE. *& 取得内表
GT_CH[] = GT_CHANGE[].
DESCRIBE TABLE GT_CHANGE LINES G_LINES. SORT GT_CH BY SFZHM." NHBM. DELETE ADJACENT DUPLICATES FROM GT_CH COMPARING SFZHM.
DESCRIBE TABLE GT_CH LINES L_LINES. *&判定记录是否存在:
IF G_LINES NE L_LINES.
MESSAGE E012 WITH '身份证号码重复输入,请检查!'.
CLEAR G_LINES.
STOP.
ENDIF. *&---检查身份证位数是否正常:
G_LINE = STRLEN( GT_CHANGE-SFZHM ).
IF G_LINE <> ." AND G_LINE <> 15.
MESSAGE E012 WITH '请输入18位身份证号码!' GT_CHANGE-SFZHM.
ENDIF. DATA: BEGIN OF LT_YTNAH OCCURS ,
NHBM LIKE YTNAH-NHBM,
END OF LT_YTNAH. BREAK AD_CAIXIANG.
*&---输入状态值进行检查
LOOP AT GT_CHANGE INTO WA_CHANGE.
CLEAR: LT_YTNAH, LT_YTNAH[].
IF WA_CHANGE-ZHTA NE 'A' AND WA_CHANGE-ZHTA NE 'B'.
MESSAGE E006 WITH '请输入合适的状态,A代表正常,B代表不正常!'.
LEAVE TO SCREEN .
ENDIF. IF WA_CHANGE-ZHTA EQ 'B'.
*& 修改农户状态时,先要检查农户商品对应关系信息:
SELECT NHBM
INTO TABLE LT_YTNAH
FROM YTNAM
WHERE NHBM EQ WA_CHANGE-NHBM
AND ZHTA EQ 'A'. IF SY-SUBRC EQ .
MESSAGE E012 WITH '此农户正常商品对应关系信息记录存在,请检查!' WA_CHANGE-NHBM.
ENDIF.
ENDIF.
ENDLOOP. ELSE.
MESSAGE I013 WITH '请保持农户基本信息的完整!'.
STOP.
ENDIF. ENDFORM. " FRM_CHECK_ZHTA *&---------------------------------------------------------------------*
*& Form FRM_UNLOCK_YTNAh
*&---------------------------------------------------------------------*
* *&对自建表ytanh进行解锁
*----------------------------------------------------------------------*
* -->P_SY_MANDT text
*----------------------------------------------------------------------*
FORM FRM_UNLOCK_YTNAH USING P_SY_MANDT. *& -解锁表YTNAH
CALL FUNCTION 'DEQUEUE_EYTNAH'
EXPORTING
MODE_YTNAH = 'E'
MANDT = SY-MANDT
EXCEPTIONS
FOREIGN_LOCK =
SYSTEM_FAILURE =
OTHERS = .
IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. ENDFORM. " FRM_UNLOCK_YTNAh *&---------------------------------------------------------------------*
*& Form FRM_LOCK_YTNAH
*&---------------------------------------------------------------------*
* *&对自建表ytanh进行锁定
*----------------------------------------------------------------------*
* -->P_SY_MANDT text
*----------------------------------------------------------------------*
FORM FRM_LOCK_YTNAH USING P_SY_MANDT. *& -锁表YTNAH
CALL FUNCTION 'ENQUEUE_EYTNAH'
EXPORTING
MODE_YTNAH = 'E'
MANDT = SY-MANDT
EXCEPTIONS
FOREIGN_LOCK =
SYSTEM_FAILURE =
OTHERS = .
IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. ENDFORM. " FRM_LOCK_YTNAH *&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS ''.
ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT. CASE OK_CODE.
*& 删除
WHEN'DELETE'.
CLEAR OK_CODE.
PERFORM FRM_DELETE_DATA. *& 保存操作处理
WHEN 'SAVE'.
CLEAR OK_CODE.
PERFORM FMR_CREA_DATA. *& 返回,删除,退出处理
WHEN 'BACK' OR 'CANC' OR 'EXIT'.
CLEAR OK_CODE.
CLEAR: GT_ITAB.
REFRESH: GT_ITAB.
PERFORM FRM_UNLOCK USING SY-MANDT.
LEAVE TO SCREEN . *& 全选处理
WHEN 'ALL'.
CLEAR OK_CODE.
WA_TAB-SEL = 'X'.
MODIFY GT_ITAB FROM WA_TAB TRANSPORTING SEL
WHERE SEL = ' '. *& 取消全选处理
WHEN 'RSAL'.
CLEAR OK_CODE.
WA_TAB-SEL = ' '.
MODIFY GT_ITAB FROM WA_TAB TRANSPORTING SEL
WHERE SEL = 'X'. WHEN 'P-' OR 'P--' OR 'P+' OR 'P++'.
CLEAR OK_CODE.
PERFORM FRM_TURN_PAGE_100. WHEN OTHERS.
CLEAR OK_CODE. ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------*
*& Module PAI_MODIFY_DATA_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE PAI_MODIFY_DATA_0100 INPUT. *&---数据改变处理逻辑流
DESCRIBE TABLE GT_ITAB LINES G_LINES.
G_COUNT = SY-LOOPC.
TC_ITEM-LINES = G_LINES + .
CLEAR GT_ITAB.
ENDMODULE. " PAI_MODIFY_DATA_0100 INPUT *&---------------------------------------------------------------------*
*& Module PAI_EXIT_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE PAI_EXIT_0100 INPUT. CASE OK_CODE.
WHEN 'EXIT' OR 'CANC'.
CLEAR OK_CODE.
LEAVE TO SCREEN . *&解锁数据表:
PERFORM FRM_UNLOCK USING SY-MANDT. ENDCASE.
ENDMODULE. " PAI_EXIT_0100 INPUT *&---------------------------------------------------------------------*
*& Module PAI_CHECK_DATA_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE PAI_CHECK_DATA_0100 INPUT.
DATA L_NHBM LIKE YTNAH-NHBM.
DATA WA_ITAB LIKE GT_ITAB. IF GT_ITAB-NHMC NE SPACE
AND GT_ITAB-SFZHM NE SPACE
AND GT_ITAB-ZHTA NE SPACE. *&G1 身份证重复性检查
SELECT SINGLE NHBM INTO L_NHBM
FROM YTNAH
WHERE SFZHM EQ GT_ITAB-SFZHM.
IF SY-SUBRC EQ .
MESSAGE E014 WITH '此身份证:' GT_ITAB-SFZHM '已对应农户:' L_NHBM.
LEAVE TO SCREEN .
ENDIF. * BREAK AD_CAIXIANG.
*&G2 身份证长度检查
G_LINE = STRLEN( GT_ITAB-SFZHM ).
IF G_LINE <> ." AND G_LINE <> 15.
MESSAGE E012 WITH '请输入18位身份证号码!' GT_ITAB-SFZHM.
ENDIF. CHECK SY-SUBRC <> . *&G3 身份证号码重复性检查:
READ TABLE GT_ITAB INTO WA_TAB1 WITH KEY SFZHM = GT_ITAB-SFZHM.
IF SY-SUBRC = .
MESSAGE E012 WITH '身份证号码重复输入,请检查输入的身份证号码!' GT_ITAB-SFZHM.
ENDIF. IF GT_ITAB-ZHTA NE 'A' AND GT_ITAB-ZHTA NE 'B'.
MESSAGE E006 WITH '请输入农户状态信息,A代表正常,B代表不正常!'. "LEAVE TO SCREEN 0100 .
ENDIF. CHECK SY-SUBRC <> . COLLECT GT_ITAB. ELSE.
MESSAGE I006 WITH ' 请输入完整的农户信息进行保存!!!'. ENDIF. CHECK GT_ITAB-SFZHM NE SPACE.
ENDMODULE. " PAI_CHECK_DATA_0100 INPUT *&---------------------------------------------------------------------*
*& Module INIT_LISTBOX_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE INIT_LISTBOX_0100 OUTPUT.
CLEAR VID.
CLEAR VLIST.
CLEAR WA_VALUE.
*&---下拉框设置
MOVE 'GT_ITAB-ZHTA' TO VID.
MOVE 'A' TO WA_VALUE-KEY.
MOVE 'A' TO WA_VALUE-TEXT.
APPEND WA_VALUE TO VLIST . MOVE 'GT_ITAB-ZHTA' TO VID.
MOVE 'B' TO WA_VALUE-KEY.
MOVE 'B' TO WA_VALUE-TEXT.
APPEND WA_VALUE TO VLIST . CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = VID
VALUES = VLIST. ENDMODULE. " INIT_LISTBOX_0100 OUTPUT
**&---------------------------------------------------------------------*
**& Module INIT_LISTBOX_0100 OUTPUT
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
*MODULE init_listbox_0100 OUTPUT. *ENDMODULE. " INIT_LISTBOX_0100 OUTPUT *&---------------------------------------------------------------------*
*& Form frm_delete_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DELETE_DATA . CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = '确认'
TEXT_QUESTION = '要删除准备创建的农户信息吗?'
TEXT_BUTTON_1 = '是'
TEXT_BUTTON_2 = '否'
DEFAULT_BUTTON = ''
DISPLAY_CANCEL_BUTTON = ' '
START_COLUMN =
START_ROW =
POPUP_TYPE = 'ICON_MESSAGE_WARNING'
IMPORTING
ANSWER = G_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND =
OTHERS = .
*& 维护时候农户信息的删除操作:
CHECK G_ANSWER EQ ''. LOOP AT GT_ITAB INTO WA_TAB WHERE SEL = 'X'. *& 删除内表数据:
DELETE GT_ITAB WHERE "NHBM EQ WA_TAB-NHBM
SFZHM EQ WA_TAB-SFZHM
AND NHMC EQ WA_TAB-NHMC.
IF SY-SUBRC EQ .
MESSAGE S011 WITH '成功删除记录!'.
ELSE.
MESSAGE S011 WITH '删除记录失败!'.
ENDIF. ENDLOOP. * stop.
LEAVE TO SCREEN . ENDFORM. " frm_delete_data *&---------------------------------------------------------------------*
*& Form FMR_CREA_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FMR_CREA_DATA .
DATA: L_NUMBER().
DATA :BEGIN OF LT_YTNAH OCCURS .
INCLUDE STRUCTURE YTNAH.
DATA: END OF LT_YTNAH. CLEAR: G_ANSWER.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = '确认'
TEXT_QUESTION = '需要进行农户信息保存吗?'
TEXT_BUTTON_1 = '是'
TEXT_BUTTON_2 = '否'
DEFAULT_BUTTON = ''
DISPLAY_CANCEL_BUTTON = ' '
START_COLUMN =
START_ROW =
POPUP_TYPE = 'ICON_MESSAGE_WARNING'
IMPORTING
ANSWER = G_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND =
OTHERS = .
CHECK G_ANSWER EQ ''. *&准备数据:
LOOP AT GT_ITAB WHERE NHBM EQ SPACE OR NHBM EQ ' ' . CLEAR L_NUMBER.
*& 生成农户编码流水号:
PERFORM FRM_NHBM_NO CHANGING L_NUMBER.
MOVE: L_NUMBER TO GT_ITAB-NHBM,
SY-MANDT TO GT_ITAB-MANDT.
MOVE: SY-UZEIT TO GT_ITAB-CPUTM,
SY-DATUM TO GT_ITAB-AEDAT,
SY-UNAME TO GT_ITAB-USNAM.
MOVE GT_ITAB TO LT_YTNAH.
MODIFY GT_ITAB .
APPEND LT_YTNAH.
CLEAR GT_ITAB. ENDLOOP. MODIFY YTNAH FROM TABLE LT_YTNAH. IF SY-SUBRC EQ .
COMMIT WORK.
MESSAGE S012 WITH '成功更新记录:' G_LINES.
LEAVE TO SCREEN .
ELSE.
ROLLBACK WORK.
MESSAGE I011 WITH '更新失败!'.
PERFORM FRM_UNLOCK USING SY-MANDT.
LEAVE TO SCREEN .
ENDIF. ENDFORM. " FMR_CREA_DATA *&---------------------------------------------------------------------*
*& Form FRM_NAHU_NO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_NHBM_NO CHANGING H_NUMBER. *&---获取农户编码流水号
DATA: L_NUMBER(). CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = ''
OBJECT = 'YH_MM_03'
IMPORTING
NUMBER = L_NUMBER
EXCEPTIONS
INTERVAL_NOT_FOUND =
NUMBER_RANGE_NOT_INTERN =
OBJECT_NOT_FOUND =
QUANTITY_IS_0 = . IF SY-SUBRC NE .
MESSAGE I011 WITH '产生对账流水吗失败!'.
EXIT.
ELSE.
CONCATENATE S_NHSIG+() L_NUMBER INTO H_NUMBER.
ENDIF. ENDFORM. " FRM_NAHU_NO *&---------------------------------------------------------------------*
*& Form FRM_turn_page_300
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_TURN_PAGE_100 . CALL FUNCTION 'FI_CUST_SCROLL'
EXPORTING
I_INPUT = ''
I_LNFIR = TC_ITEM-TOP_LINE
I_LNMAX = G_LINES
I_LOOPC = G_COUNT
I_OKCOD = SY-UCOMM
IMPORTING
E_LNFIR = TC_ITEM-TOP_LINE
EXCEPTIONS
OTHERS = . ENDFORM. " FRM_turn_page_300 *&---------------------------------------------------------------------*
*& Form FRM_UNLOCK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SY_MANDT text
*----------------------------------------------------------------------*
FORM FRM_UNLOCK USING H_MANDT. CALL FUNCTION 'DEQUEUE_EYTNAH'
EXPORTING
MODE_YTNAH = 'E'
MANDT = H_MANDT
EXCEPTIONS
FOREIGN_LOCK =
SYSTEM_FAILURE =
OTHERS = .
IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. ENDFORM. " FRM_UNLOCK *&---------------------------------------------------------------------*
*& Form FRM_CHECK_YTNAM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_YTNAM . DATA: BEGIN OF LT_YTNAM OCCURS ,
NHBM LIKE YTNAM-NHBM,
END OF LT_YTNAM. *& 删除数据时,需要检查要删除的数据在YTNAM表里面是否有条目:有的话,不允许删除:
LOOP AT GT_CHANGE WHERE ZSEL <> SPACE.
SELECT NHBM
INTO TABLE LT_YTNAM
FROM YTNAM
WHERE NHBM = GT_CHANGE-NHBM. IF SY-SUBRC EQ .
MESSAGE I012 WITH '此农户的商品对应关系信息已经存在,请检查!' GT_CHANGE-NHBM.
" STOP.
ENDIF. ENDLOOP. ENDFORM. " FRM_CHECK_YTNAM

YHMMR003 农户基本信息的维护程序的更多相关文章

  1. 获取linux服务器基本信息脚本

    为了方便日常运维写的一段简单脚本,用于集中获取服务器操作系统.CPU.内存使用.负载.硬盘使用.网络信息. 脚本比较简单,就不解释了,有兴趣的朋友请自行查看. #!/bin/bash##Name:sy ...

  2. 微信接口-获取用户openid基本信息

    一.协助获取微信用户openid功能 https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri= ...

  3. 使用HttpClient 4.3.4 自动登录并抓取中国联通用户基本信息和账单数据,GET/POST/Cookie

    一.什么是HttpClient? HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.虽然在 JDK 的 ...

  4. Java集合-5. (List)已知有一个Worker 类如下: 完成下面的要求 1) 创建一个List,在List 中增加三个工人,基本信息如下: 姓名 年龄 工资 zhang3 18 3000 li4 25 3500 wang5 22 3200 2) 在li4 之前插入一个工人,信息为:姓名:zhao6,年龄:24,工资3300 3) 删除wang5 的信息 4) 利用for 循

    第六题 5. (List)已知有一个Worker 类如下: public class Worker { private int age; private String name; private do ...

  5. 用C++和shell获取本机CPU、网卡IO、内存、磁盘等的基本信息

    用C++和shell获取本机CPU.网卡.内存.磁盘等的基本信息: 由于对C++相关的函数没多少了解,但是觉得用shell反而相对简单一些: 一.shell脚本,用来辅助C++获取主机的资源使用信息 ...

  6. C#微信公众号开发-高级接口-之网页授权oauth2.0获取用户基本信息(二)

    C#微信公众号开发之网页授权oauth2.0获取用户基本信息(一) 中讲解了如果通过微信授权2.0snsapi_base获取已经关注用户的基本信息,然而很多情况下我们经常需要获取非关注用户的信息,方法 ...

  7. C#微信公众号开发之网页授权oauth2.0获取用户基本信息(一)

    咨询 请加 QQ::QQ群: 在微信里面,非认证的公众号账号,只能通过在微信回复菜单单击等事件获取openid,但是认证的公众账号(之前认证的订阅号是不可以的,现在新开放了政府媒体机构的认证订阅号)可 ...

  8. Magicodes.WeiChat——WeChatOAuthTest(网页授权获取用户基本信息)

    Demo访问地址:http://wechat.magicodes.net/app/AppDemo/WeChatOAuthTest?tenantId=1 关于公众号如何获取用户信息,请参考此文档:htt ...

  9. 用c#开发微信(2)扫描二维码,用户授权后获取用户基本信息 (源码下载)

    本文将介绍基于Senparc.Weixin微信开发框架来实现网页授权来获取用户基本信息.先生成包含授权及回调url信息的二维码:用户用微信扫描之后,被要求授权以获取Ta的用户基本信息:用户授权后,通过 ...

随机推荐

  1. 安装了ubuntu14.04+windows7双系统的笔记本启动后出现grub rescue>提示符

    解决思想如下: 1.在grub rescue>提示符处输入ls  即可看到该命令列出了硬盘上的所有分区,找到安装了linux的分区,我的安装在(hd0,msdos8)下,所以我以(hd0,msd ...

  2. Nginx 简介

    一.介绍 Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器. Nginx是一款轻量级的Web服务器/反向代理服务器以及电子邮件代理服务器,并在一个BSD ...

  3. 《BI项目笔记》增量ETL数据抽取的策略及方法

    增量抽取 增量抽取只抽取自上次抽取以来数据库中要抽取的表中新增或修改的数据.在ETL使用过程中.增量抽取较全量抽取应用更广.如何捕获变化的数据是增量抽取的关键.对捕获方法一般有两点要求:准确性,能够将 ...

  4. Delphi名站以及高手Blog

    以前知道的: http://cnblogs.com/del (万一兄的,这个不用解释了) http://www.cnblogs.com/del/archive/2010/04/25/1720750.h ...

  5. Composite模式

    1 意图:将对象组成树形结构,以表示“部分——整体”的层次结构.Composite使得用户对单个对象和组合对象的使用具有一致性. 2 动机:同意处理图元对象和包含图元的容器对象.Composite通过 ...

  6. Ubuntu中设置静态IP和DNS

    在Ubuntu中设置静态IP共两步:1>设置IP:2>设置DNS1>设置IP    编辑 /etc/network/interface文件:       sudo vi /etc/n ...

  7. 常用linux命令积累

    ------------------------------不定时更新------------------------------------------------- 1.Ubuntu关机:shut ...

  8. 自定义泛型N维空间数组

    class Space<T> : IEnumerable<Space<T>> { public T Filler { get { if (!ed) { ed = t ...

  9. 并发编程 02—— ConcurrentHashMap

    Java并发编程实践 目录 并发编程 01—— ThreadLocal 并发编程 02—— ConcurrentHashMap 并发编程 03—— 阻塞队列和生产者-消费者模式 并发编程 04—— 闭 ...

  10. qt5.4.0在windows,32位下的编译, vs2010平台

    假设源代码入在D:\3DFrame\qt-everywhere-opensource-src-5.4.0\qt-everywhere-opensource-src-5.4.0 1:首先从官方网站下载源 ...