SAP,ABAP:ALV变式复制

应用场景:程序优化,需要新开一个程序优化,优化完成后原程序ALV变式无法带到新的程序,
ALV变式是很好用的功能

REPORT zbsc.


  • 事务代码:ZBSC-ALV变式复制
  • 程序名称:ZBSC-ALV变式复制
  • 程序目的: ZBSC-ALV变式复制
  • 开发人员:
    *(修改日志)--------------------------------------------------------
  • 日志号 修改人 修改时间 修改说明 传输号码

  • 001

======================================================================

  • INCLUDE
    ======================================================================
    INCLUDE zbsc_top.
    INCLUDE zbsc_f01.

======================================================================

  • AT SELECTION-SCREEN.
    ======================================================================
    AT SELECTION-SCREEN OUTPUT.

======================================================================

  • INITIALIZATION
    ======================================================================
    INITIALIZATION.

======================================================================

  • START-OF-SELECTION.
    ======================================================================
    START-OF-SELECTION.

PERFORM frm_copy_data."变式复制

======================================================================

  • END-OF-SELECTION.
    ======================================================================
    END-OF-SELECTION.

&---------------------------------------------------------------------
*& 包含 ZBSC_TOP
&---------------------------------------------------------------------
TABLES:ltdx.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS:p_ycx TYPE ltdx-report OBLIGATORY.

*SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 33(60) text-002 .
SELECTION-SCREEN END OF LINE."步骤:

*SELECTION-SCREEN SKIP 1.

PARAMETERS:p_xcx TYPE ltdx-report OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1 .

&---------------------------------------------------------------------
*& 包含 ZBSC_F01
&---------------------------------------------------------------------
&---------------------------------------------------------------------
*& Form FRM_COPY_DATA
&---------------------------------------------------------------------

  •   变式复制
    

----------------------------------------------------------------------
FORM frm_copy_data .

SELECT *
INTO TABLE @DATA(lt_ltdxt)
FROM ltdxt
WHERE relid = ‘LT’
AND type = ‘F’
AND langu = ‘1’
AND report = @p_ycx
AND log_group = @space.

SELECT *
INTO TABLE @DATA(lt_ltdx)
FROM ltdx
WHERE relid = ‘LT’
AND type = ‘F’

  •  AND langu = '1'
    AND report    = @p_ycx
    AND log_group = @space.
    

    LOOP AT lt_ltdxt INTO DATA(ls_ltdxt).
    ls_ltdxt-report = p_xcx.
    MODIFY lt_ltdxt FROM ls_ltdxt.
    ENDLOOP.

    LOOP AT lt_ltdx INTO DATA(ls_ltdx).
    ls_ltdx-report = p_xcx.
    MODIFY lt_ltdx FROM ls_ltdx.
    ENDLOOP.

    IF lt_ltdx[] IS NOT INITIAL
    AND lt_ltdxt[] IS NOT INITIAL.

    MODIFY ltdxt FROM TABLE lt_ltdxt.
    IF sy-subrc = 0.

    MODIFY ltdx FROM TABLE lt_ltdx.
    IF sy-subrc = 0.
      COMMIT WORK AND WAIT.
    
      MESSAGE '复制成功' TYPE 'S'.
    
    ELSE.
      ROLLBACK WORK.
      MESSAGE '复制失败' TYPE 'E'.
    
    ENDIF.
    

    ELSE.
    ROLLBACK WORK.
    MESSAGE ‘复制失败’ TYPE ‘E’.

    ENDIF.

    ENDIF.

ENDFORM.

你可能感兴趣的:(ABAP,ABAP,SAP,abap,SAP)