ABAP嵌套子屏幕-实例

限于喜欢 提交于 2020-01-11 03:41:17

[ABAP 毕业设计基础] 查询个人信息
所需要的HR表:USR21,ADRP,ADCP,ADR6
屏幕配置:

屏幕100
在这里插入图片描述
flow logic:

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100.
CALL SUBSCREEN SUB INCLUDING SY-REPID SCREEN.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.
   CALL SUBSCREEN SUB.

layout:
在这里插入图片描述
屏幕110
在这里插入图片描述
flow logic

PROCESS BEFORE OUTPUT.
MODULE GET_DATA_0110.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0110.

layout
在这里插入图片描述
屏幕120
在这里插入图片描述
flow logic

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0120.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0120.

layout
在这里插入图片描述
代码

TABLES:USR21,ADRP,ADCP,adr6.

TYPES :BEGIN OF ts_usr21,
         bname      TYPE usr21-bname,
         persnumber TYPE usr21-persnumber,
         addrnumber TYPE usr21-addrnumber,
       END OF ts_usr21.

TYPES :BEGIN OF ts_adrp,
         persnumber TYPE adrp-persnumber,
         name_text  TYPE adrp-name_text,
       END OF ts_adrp.

types :begin of ts_adcp,
         persnumber TYPE adcp-persnumber,
         addrnumber TYPE adcp-addrnumber,
         department type adcp-department,
         function type adcp-function,
  end of ts_adcp.

  TYPES :BEGIN OF ts_adr6,
         persnumber TYPE adr6-persnumber,
         addrnumber TYPE adr6-addrnumber,
         smtp_addr  TYPE adr6-smtp_addr,
       END OF ts_adr6.

DATA:
      lt_usr21 type STANDARD TABLE OF ts_usr21,
      ls_usr21 type ts_usr21,
      lt_adrp type STANDARD TABLE OF ts_adrp,
      ls_adrp type ts_adrp,
      lt_adcp type STANDARD TABLE OF ts_adcp,
      ls_adcp type ts_adcp,
      lt_adr6 type STANDARD TABLE OF ts_adr6,
      ls_adr6 type ts_adr6,
   screen(4)  TYPE n value 0110,
   ok_code LIKE sy-ucomm,
   ok_save LIKE sy-ucomm.
CALL SCREEN 100.
CALL SCREEN 110.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'PF001'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE ok_code.

    WHEN 'EXIT'  OR 'CANCEL'.

      LEAVE PROGRAM.
WHEN 'BACK'.
  SCREEN = 0110.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  GET_DATA_0110  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE get_data_0110 OUTPUT.
  SELECT   bname persnumber addrnumber
     FROM USR21
     INTO  ls_usr21
    where bname = usr21-bname.
    endselect.

        select persnumber addrnumber department function
          from adcp
          into ls_adcp
          where persnumber = ls_usr21-persnumber and addrnumber = ls_usr21-addrnumber.


          adcp-function = ls_adcp-function.
          adcp-department = ls_adcp-department.
          endselect.

SELECT persnumber ADDRNUMBER SMtp_addr
  from adr6
  into ls_adr6
  where persnumber = ls_usr21-persnumber and addrnumber = ls_usr21-addrnumber.

  adr6-smtp_addr = ls_adr6-smtp_addr.
  endselect.

ENDMODULE.                 " GET_DATA_0110  OUTPUT


    MODULE USER_COMMAND_0110 INPUT.
  CASE ok_code.
    WHEN 'DISPLAY' .

      if  usr21-bname <> ls_usr21-BNAME AND USR21 IS NOT INITIAL.
        SCREEN = 0110.
        ELSEIF  adcp-department IS INITIAL  .
      MESSAGE s398(00) WITH 'Please input department'.
      elseif adcp-function IS INITIAL.
        MESSAGE s398(00) WITH 'Please input function'.
        ELSE.
      screen = 0120.
        endif.

    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0120  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0120 OUTPUT.

   select persnumber addrnumber department function
          from adcp
          into ls_adcp
          where department = adcp-department and function = adcp-function.
     endselect.
select persnumber name_text
      from adrp
      into  ls_adrp
      where persnumber = ls_adcp-persnumber.
      endselect.
adrp-name_text = ls_adrp-name_text.

  SELECT  bname  persnumber addrnumber
     FROM USR21
     INTO  ls_usr21
    where persnumber = ls_adcp-persnumber and addrnumber = ls_adcp-addrnumber.
    endselect.
usr21-bname = ls_usr21-bname.

ENDMODULE.

效果图
在这里插入图片描述
点击display
在这里插入图片描述
再点击display
在这里插入图片描述

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!