ALV选择屏幕增加字段描述
Posted 想发财的小夏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ALV选择屏幕增加字段描述相关的知识,希望对你有一定的参考价值。
选择屏幕在用户选择单值之后,屏幕增加文本字段描述。
需求大概如下:
代码如下:
REPORT ztst_xinx.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) c01 FOR FIELD p_lgort.
SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS: p_lgort TYPE lgort_d OBLIGATORY.
SELECTION-SCREEN COMMENT 43(30) ct01.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b01.
INITIALIZATION. " 初始化
PERFORM frm_init.
AT SELECTION-SCREEN OUTPUT. " Enter
PERFORM frm_screem_status.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lgort. " F4 Update
PERFORM f4_lgort USING 'P_LGORT' 'CT01' CHANGING p_lgort.
*&---------------------------------------------------------------------*
*& Form frm_init
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_init .
c01 = '工厂库存地点'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_dyp_status
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_screem_status .
SELECT SINGLE lgobe
FROM t001l
INTO @ct01
WHERE lgort = @p_lgort
AND werks = '0001'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form f4_lgort
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> P_
*& --> P_
*& <-- P_LGORT2
*&---------------------------------------------------------------------*
FORM f4_lgort USING l_field1
l_txt
CHANGING l_lgort.
DATA: lt_return TYPE STANDARD TABLE OF ddshretval,
lt_dynpfields TYPE STANDARD TABLE OF dynpread,
lv_txt TYPE char255.
SELECT werks,lgort,lgobe
FROM t001l
INTO TABLE @DATA(lt_t001l).
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'LGORT'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = l_field1
value_org = 'S'
TABLES
return_tab = lt_return
value_tab = lt_t001l.
READ TABLE lt_return INTO DATA(ls_return) INDEX 1.
IF sy-subrc = 0.
l_lgort = ls_return-fieldval.
ELSE.
PERFORM frm_get_dynp_value USING l_field1 CHANGING l_lgort.
ENDIF.
READ TABLE lt_t001l INTO DATA(ls_t001l) WITH KEY lgort = l_lgort.
IF sy-subrc = 0.
lt_dynpfields = VALUE #( ( fieldname = l_txt fieldvalue = ls_t001l-lgobe ) ).
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_get_dynp_value
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> L_FIELD1
*& <-- L_LGORT
*&---------------------------------------------------------------------*
FORM frm_get_dynp_value USING pv_fname CHANGING pv_field.
DATA : lv_prog LIKE d020s-prog,
lv_dynp LIKE d020s-dnum,
lt_dynfild LIKE dynpread OCCURS 0 WITH HEADER LINE.
lv_prog = sy-repid. "repid.
lv_dynp = sy-dynnr.
lt_dynfild-fieldname = pv_fname.
APPEND lt_dynfild.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = lv_prog
dynumb = lv_dynp
TABLES
dynpfields = lt_dynfild
EXCEPTIONS
invalid_abapworkarea = 04
invalid_dynprofield = 08
invalid_dynproname = 12
invalid_dynpronummer = 16
invalid_request = 20
no_fielddescription = 24
undefind_error = 28.
IF sy-subrc = 0.
READ TABLE lt_dynfild INDEX 1.
pv_field = lt_dynfild-fieldvalue.
ENDIF.
ENDFORM.
以上是关于ALV选择屏幕增加字段描述的主要内容,如果未能解决你的问题,请参考以下文章