ABAP 写入后返回初始选择屏幕
Posted
技术标签:
【中文标题】ABAP 写入后返回初始选择屏幕【英文标题】:ABAP return to the initial selection screen after a write 【发布时间】:2016-08-22 14:28:27 【问题描述】:我是 ABAP 新手。我创建了一个报告,该报告基本上处理已经使用功能模块构建的数据库的 CRUD。每个功能都有多个选择屏幕。是否有执行 READ 并使用“write”在屏幕上打印,然后返回初始选择屏幕?
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】:删除SELECTION-SCREEN BEGIN/END OF SCREEN 100
。这样100屏就变成了标准选择屏(1000),也就不用再调用了。因此,将CALL SELECTION-SCREEN 100
替换为START-OF-SELECTION
。通过这些更改,当您按输出屏幕上的后退箭头时,您将返回选择屏幕。
您可能还需要删除EXIT
。
【讨论】:
解决了我的问题。谢谢!以上是关于ABAP 写入后返回初始选择屏幕的主要内容,如果未能解决你的问题,请参考以下文章