본문 바로가기

SAP BC-프로그램

사용자 레이아웃 설정 복사 프로그램

모듈 : BC
기능 설명 : 사용자 레이아웃 설정 복사
사용 예시 : 부서 계정 사용자가 다른 부서 계정으로 변경되었을 시, 기존 사용하던 계정의 레이아웃을 카피하여 옮겨줄때 사용.
사용 시, LTDX 테이블 데이터를 참조하여 레포트 단위로 레이아웃이 카피된다.


1. 소스코드

***********************************************************************
* Report            : ZBC_LAYOUT_COPY                                 *
* Module/Sub-Module : BC                                              *
* Description       : User Layout Copy                                *
***********************************************************************
*                          MODIFICATION LOG                           *
*                                                                     *
* DATE       AUTHORS            DESCRIPTION                           *
* ---------- ------------------ ------------------------------------- *
*             YHJ               Initial Release                       *
***********************************************************************

REPORT  ZBC_LAYOUT_COPY.


*----------------------------------------------------------------------*
* DATA
*----------------------------------------------------------------------*
TABLES: USR02.

DATA: LT_LTDX  LIKE LTDX  OCCURS 0 WITH HEADER LINE.
DATA: LT_LTDXT LIKE LTDXT OCCURS 0 WITH HEADER LINE.


*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*

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

  PARAMETERS ORIG_USR LIKE USR02-BNAME OBLIGATORY.
  PARAMETERS P_REPORT LIKE LT_LTDX-REPORT OBLIGATORY.

  SELECTION-SCREEN SKIP 1.

  SELECT-OPTIONS: COPY_USR FOR USR02-BNAME OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

* SELECT-OPTIONS: P_REPORT FOR LT_LTDX-REPORT OBLIGATORY.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
  %_ORIG_USR_%_APP_%-TEXT  = 'Original User'.
  %_COPY_USR_%_APP_%-TEXT  = 'Copy User'.
  %_P_REPORT_%_APP_%-TEXT  = 'Target Report'.

*----------------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------------*
START-OF-SELECTION.

  LOOP AT COPY_USR.

    SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_LTDX
      FROM LTDX
      WHERE USERNAME = ORIG_USR
        AND REPORT = P_REPORT.

    SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_LTDXT
      FROM LTDXT
      WHERE USERNAME = ORIG_USR
        AND REPORT = P_REPORT.

    LOOP AT LT_LTDX.
      LT_LTDX-USERNAME = COPY_USR-LOW.
      MODIFY LTDX FROM LT_LTDX.
    ENDLOOP.

    LOOP AT LT_LTDXT.
      LT_LTDXT-USERNAME = COPY_USR-LOW.
      MODIFY LTDXT FROM LT_LTDXT.
    ENDLOOP.

  ENDLOOP.

  MESSAGE 'Layout Copy 완료' TYPE 'S'.