写入后ABAP返回初始选择屏幕

时间:2016-08-22 14:28:28

标签: sap crud abap

我是ABAP的新手。我创建了一个报表,基本上处理已经使用功能模块构建的数据库的CRUD。它为每个功能提供多个选择屏幕。无论如何都要执行READ并将其打印在屏幕上并写入'然后返回初始选择屏幕?

DATA: lv_response1 TYPE flag,
      lv_response2 TYPE flag,
      lv_response3 TYPE flag.



SELECTION-SCREEN BEGIN OF SCREEN 100.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-t01.

PARAMETERS: s1 RADIOBUTTON GROUP g1,
            s2 RADIOBUTTON GROUP g1,
            s3 RADIOBUTTON GROUP g1,
            s4 RADIOBUTTON GROUP g1,
            s5 RADIOBUTTON GROUP g1.

SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 100.

SELECTION-SCREEN BEGIN OF SCREEN 200.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-t02.
PARAMETERS: p_skill   TYPE Z0B_SKILL_ACR,
            p_skills  type Z0B_SKILL_SUBDOM_ACR,
            p_skilld  TYPE Z0B_SKILL_NAME,
            p_skilll  TYPE z0b_linguistic.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN 200.

SELECTION-SCREEN BEGIN OF SCREEN 300.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-t03.
PARAMETERS: p_skid TYPE z0b_skillid,
            p_all  TYPE flag.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF SCREEN 300.

SELECTION-SCREEN BEGIN OF SCREEN 400.
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-t04.
PARAMETERS: p_skacr  TYPE z0b_skill_acr,
            p_skdesc TYPE z0b_skill_name.
SELECTION-SCREEN END OF BLOCK B4.
SELECTION-SCREEN END OF SCREEN 400.

SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-t05.
PARAMETERS p_dskid TYPE z0b_skillid.
SELECTION-SCREEN END OF BLOCK B5.
SELECTION-SCREEN END OF SCREEN 500.

CALL SELECTION-SCREEN 100.
IF s1 = 'X'.
  "Create skill
  CALL SELECTION-SCREEN 200.
  CALL FUNCTION 'Z0B_ADD_NEW_SKILL'
    EXPORTING
      IV_SKILL_ACR         = p_skill
      IV_SKILL_SUBDOM      = p_skills
      IV_SKILL_DESC        = P_skilld
      IV_SKILL_LINGUISTIC  = p_skilll
    IMPORTING
      EV_CHECK_SUBDOM      = lv_response1
      EV_CHECK_SKILL_ACR_A = lv_response2
      EV_CHECK             = lv_response3.
  IF lv_response1 eq 0.
    WRITE:/ 'Subdomain does not exist.'.
  ENDIF.
  IF lv_response2 eq 1.
    WRITE:/ 'Skill already exists.'.
  ENDIF.
  IF lv_response3 eq 0.
    WRITE:/ 'Database error.'.
  ENDIF.
  IF lv_response1 eq 1 AND lv_response2 eq 0 AND lv_response3 eq 1.
    WRITE:/ 'Skill created successfully.'.
  ENDIF.
  EXIT.
ENDIF.
***********************************************************************************************************
IF s2 = 'X'.

  "Read skill

  CALL SELECTION-SCREEN 300.
  data: lt_skills type Z0B_MY_SKILLS_T,
      ls_skills type z0b_skills_t.
  IF p_all is not INITIAL.
    CALL FUNCTION 'Z0B_GET_ALL_SKILLS'
     IMPORTING
       ET_NONLINGUISTIC_SKILLS       = lt_skills
       EV_CHECK                      = lv_response2
* EXCEPTIONS
*   NO_SKILL                      = 1
*   OTHERS                        = 2
              .
    write 'Non-linguistic skills'.
    LOOP AT lt_skills into ls_skills.
      write: / ls_skills-skillid, ls_skills-skill_text, ls_skills-skill_acr.
    ENDLOOP.
    CALL FUNCTION 'Z0B_GET_LANG'
     IMPORTING
       ET_LINGUISTIC_SKILLS       = lt_skills
       EV_CHECK                   = lv_response3
* EXCEPTIONS
*   NO_SKILL                   = 1
*   OTHERS                     = 2
      .
    write:/.
    write:/ 'Linguistic skills'.
    LOOP AT lt_skills into ls_skills.
      write: / ls_skills-skillid, ls_skills-skill_text, ls_skills-skill_acr.
    ENDLOOP.

    IF lv_response3 eq 0 and lv_response2 eq 0.
      WRITE:/ 'No entries.'.
    endif.
    exit.
  ENDIF.

  CALL FUNCTION 'Z0B_READ_MASTERDATA_SKILL'
    EXPORTING
      IV_SKILLID = p_skid
    IMPORTING
      ET_SKILLS  = lt_skills
      EV_CHECK   = lv_response3
*    EXCEPTIONS
*      NO_DATA    = 1
*      OTHERS     = 2.

  IF lv_response3 eq 0.
    WRITE:/ 'Database error.'.

  ENDIF.
  LOOP AT lt_skills into ls_skills.
    write: / ls_skills-skill_text, ls_skills-skill_acr.
  ENDLOOP.
endif.
***********************************************************************************
IF s3 = 'X'.
  " Update a skill
  CALL SELECTION-SCREEN 400.
  CALL FUNCTION 'Z0B_MODIFY_SKILL'
    EXPORTING
      IV_SKILLS_ACR        = p_skacr
      IV_SKILLS_DESC       = p_skdesc
   IMPORTING
     EV_CHECK             = lv_response1
* EXCEPTIONS
*   NO_SKILL             = 1
*   NO_DATA              = 2
*   NO_UPDATE            = 3
*   OTHERS               = 4
            .
  IF lv_response1 = 0.
    WRITE 'Failed.'.
  else.
    write 'Skill modified successfully'.
  ENDIF.
ENDIF.
***********************************************************************************
IF s4 = 'X'.
  CALL SELECTION-SCREEN 500.
  CALL FUNCTION 'Z0B_DELETE_SKILL'
    EXPORTING
      IV_SKILLS_ID       = p_dskid
   IMPORTING
     EV_CHECK           = lv_response1
* EXCEPTIONS
*   NO_SKILL           = 1
*   NO_MOVE            = 2
*   NO_DELETE_1        = 3
*   NO_DELETE_2        = 4
*   SKILL_USED         = 5
*   OTHERS             = 6
            .
  IF lv_response1 = 0.
    WRITE 'Failed.'.
  else.
    write 'Skill deleted successfully'.
  ENDIF.
ENDIF.

1 个答案:

答案 0 :(得分:2)

删除SELECTION-SCREEN BEGIN/END OF SCREEN 100。那样屏幕100将成为标准选择屏幕(1000),那么也不需要再调用它。因此,将CALL SELECTION-SCREEN 100替换为START-OF-SELECTION。通过这些更改,当您按下输出屏幕上的后退箭头时,您将返回选择屏幕。

您可能还必须删除EXIT