ABAP ALV可编辑字段长度受限

问题描述:自开发ALV报表中某个字段设定为可编辑状态,但是实际操作中发现被设为可编辑状态的字段输入长度受限制了。

 

解决办法:通过上网查找和研究摸索,原来是要给该字段一个参考字段,要编辑的字段长度和参考字段的长度会保持一致。

 

FORM FRM_SET_FIELD1  USING  I_FIELDNAME
                            I_SELTEXT
                            I_REF_FIELD
                            I_REF_TABLE
                            I_SEL.

  DATA:LS_FIELDCAT1 TYPE LVC_S_FCAT.

  CLEAR:LS_FIELDCAT1.
  LS_FIELDCAT1-FIELDNAME   = I_FIELDNAME.
  LS_FIELDCAT1-SCRTEXT_L   = I_SELTEXT.
  LS_FIELDCAT1-SCRTEXT_S   = I_SELTEXT.
  LS_FIELDCAT1-SCRTEXT_M   = I_SELTEXT.
  LS_FIELDCAT1-EDIT = 'X'.
  LS_FIELDCAT1-REF_FIELD   = I_REF_FIELD.
  LS_FIELDCAT1-REF_TABLE   = I_REF_TABLE.
  LS_FIELDCAT1-CHECKBOX    = I_SEL.

  APPEND LS_FIELDCAT1 TO GT_FIELDCAT1 .
ENDFORM.
FORM FRM_EDIT_ALV.

  DATA:LS_LAYOUT   TYPE LVC_S_LAYO.

  LS_LAYOUT-ZEBRA = 'X'.
  LS_LAYOUT-CWIDTH_OPT = 'X'.
  LS_LAYOUT-SEL_MODE = 'X'.

  CLEAR GT_FIELDCAT1[].
  PERFORM FRM_SET_FIELD1 USING 'SEL' '选择' '' '' 'X'.
  PERFORM FRM_SET_FIELD1 USING 'GJAHR' '会计年度' 'GJAHR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'POPER' '期间' 'POPER' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'RASSC' '贸易伙伴' 'RASSC' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'RKCUR' '货币' 'RKCUR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZVBELN' '销售订单' 'ZVBELN' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZPOSNR' 'SO行项目' 'ZPOSNR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'EBELN'  '采购订单' 'EBELN' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'EBELP'  'PO行项目' 'EBELP' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZKSL1'  '收入金额' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZKSL2'  '实际成本' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZKSL3'  '计划成本' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'KALNR'  '成本估算号' 'KALNR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'DOCREF'  '凭证参考' 'DOCREF' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'TOT'  '实际制造费用' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZTOT'  '计划制造费用' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'VKORG'  '销售组织' 'VKORG' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'KUNNR'  '客户' 'KUNNR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'WERKS'  '工厂' 'WERKS' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'MSL'  '数量' 'MSL' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'MATNR'  '物料' 'MATNR' 'MARA' ''.
  PERFORM FRM_SET_FIELD1 USING 'GSBER'  '业务范围' 'GSBER' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'VKBUR'  '销售办事处' 'VKBUR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'VKGRP'  '销售组' 'VKGRP' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'PRCTR'  '事业部' 'PRCTR' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZPRCTR1'  '接收方利润中心' 'ZPRCTR1' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'RBUKRS'  '公司代码' 'RBUKRS' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZDDSX'  '订单属性' 'ZDDSX' 'ZTFICO043' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZMLIN'  '产品线' 'ZMLIN' 'MARA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZMFAN'  '产品族' 'ZMFAN' 'MARA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZCBXFY'  '成本性费用' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZBZDQB'  '标准地区部费用' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZBZSHYB'  '标准事业部费用' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZBZPT'  '标准平台费用' 'KSL' 'ACDOCA' ''.
  PERFORM FRM_SET_FIELD1 USING 'ZJYLR'  '订单经营利润' 'KSL' 'ACDOCA' ''.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      IS_LAYOUT_LVC            = LS_LAYOUT
      IT_FIELDCAT_LVC          = GT_FIELDCAT1[]
      I_SAVE                   = 'U'
      I_CALLBACK_PF_STATUS_SET = 'FRM_STATE_EDIT'
      I_CALLBACK_USER_COMMAND  = 'FRM_USER_COMMAND'
    TABLES
      T_OUTTAB                 = GT_EDIT
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.

 

你可能感兴趣的:(ABAP技能树,ABAP)