티스토리 툴바


1. 주로 ALV field catalog 정의할 때 쓰면 좋습니다..


form / macro

*&---------------------------------------------------------------------*
*&      Form  APPEND_ITAB
*&---------------------------------------------------------------------*
*       Append into Internal Table from Workarea..
*----------------------------------------------------------------------*
*       ->PT_ITAB : ITAB with header line
*       ->P_FLAG  : S:start, (null):normal, E:End
*       ->P_KEY   : fieldname
*       ->P_VALUE : fieldvalue
*----------------------------------------------------------------------*
form APPEND_ITAB tables PT_ITAB
                 using  P_FLAG  P_KEY P_VALUE.
  field-symbols <FS_VALUE> type any.

  if P_FLAG eq 'S'.
    clear PT_ITAB.
  endif.

  assign component P_KEY of structure PT_ITAB to <FS_
VALUE >.
  move P_VALUE to <FS_
VALUE >.

  case P_FLAG.
    when 'S'"..nothing
    when ' '"..nothing
    when 'E'append PT_ITABclear PT_ITAB.
    when others.
  endcase.

  unassign <FS_
VALUE>.
endform.                                                   
" APPEND_ITAB

*..// append itab.
define $$APPEND_ITAB.
  PERFORM APPEND_ITAB TABLES &1
                      USING  &2 &3 &4.
end-of-definition. 
 



사용방법..

  $$APPEND_ITAB  PT_FCAT :
          'S'     'FIELDNAME'     'CHK',
          ' '     'EDIT'          'X',
          ' '     'REPTEXT'       'Check',
          'E'     'CHECKBOX'      'X',

          'S'     'FIELDNAME'     'ICON',
          ' '     'REPTEXT'       'Icon',
          'E'     'ICON'          
'X'.




저작자 표시 비영리 동일 조건 변경 허락
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 세지군 트랙백 0 : 댓글 1

ABAP Report 개발시 아래와 같은 Templete 로 작성합니다...
그냥 개인적인 abap 개발 표준 인게지유...

*----------------------------------------------------------------------*

* Module/Sub-module:

*----------------------------------------------------------------------*

* T-CODE      :

* Author      :

* Date        :

* Type        :

* Description :

*----------------------------------------------------------------------*

*                            변경이력                                  *

* ----------   ----------   ----------   ----------------------------- *

*  변경번호     변경일자     변경자명              변경내용            *

* ----------   ----------   ----------   ----------------------------- *

*

*----------------------------------------------------------------------*


report  YFIBR0010 message-id OK.

*----------------------------------------------------------------------*

*..// include

*----------------------------------------------------------------------*



*----------------------------------------------------------------------*

*..// Types

*----------------------------------------------------------------------*


*----------------------------------------------------------------------*

*..// Tables

*----------------------------------------------------------------------*

tables : DD02L.


*----------------------------------------------------------------------*

*..// Internal Table & Workarea

*----------------------------------------------------------------------*



*----------------------------------------------------------------------*

*..// Global Valuable

*----------------------------------------------------------------------*

data : GO_DREF type ref to DATA.


*----------------------------------------------------------------------*

*..// Field Symbols

*----------------------------------------------------------------------*

field-symbols : <FS_ITAB> type TABLE.




*----------------------------------------------------------------------*

*..// Ranges

*----------------------------------------------------------------------*



*----------------------------------------------------------------------*

*..// Constants

*----------------------------------------------------------------------*



*----------------------------------------------------------------------*

*..// Macro

*----------------------------------------------------------------------*

*..// Clear ITAB

define $$CLEAR.

  CLEAR : &1, &1[].

end-of-definition.


*..// Append Ranges Type

define $$SET_R.

  MOVE : &2 TO &1-SIGN,

         &3 TO &1-OPTION,

         &4 TO &1-LOW,

         &5 TO &1-HIGH.

  APPEND &1. CLEAR &1.

end-of-definition.


*..// append itab.

define $$APPEND_ITAB.

  PERFORM APPEND_ITAB TABLES &1

                      USING  &2 &3 &4.

end-of-definition.


*..// append bdc

define $$APPEND_BDCDATA.

  PERFORM APPEND_BDCDATA TABLES &1

                         USING  &2 &3 &4.

end-of-definition.


*----------------------------------------------------------------------*

*..// local Class - Definition

*----------------------------------------------------------------------*


*----------------------------------------------------------------------*

*..// local Class - Implementation

*----------------------------------------------------------------------*





*----------------------------------------------------------------------*

*..// Selection Screen

*----------------------------------------------------------------------*

selection-screen begin of block BLK1 with frame title TEXT-T01.

parameters : P_TABNM type DD02L-TABNAME obligatory.

selection-screen  end  of block BLK1.



*----------------------------------------------------------------------*

*..// Initialization

*----------------------------------------------------------------------*

initialization.
 

*----------------------------------------------------------------------*

*..// At selection screen

*----------------------------------------------------------------------*

at selection-screen.


*----------------------------------------------------------------------*

*..// At selection screen output

*----------------------------------------------------------------------*

at selection-screen output.


*----------------------------------------------------------------------*

*..// at selection screen request

*----------------------------------------------------------------------*




*----------------------------------------------------------------------*

*..// Start-of-selection

*----------------------------------------------------------------------*

start-of-selection.


  create data GO_DREF type table of (P_TABNM).

  assign GO_DREF->* to <FS_ITAB>.


  select *

    into corresponding fields of table <FS_ITAB>

    from (P_TABNM).



*----------------------------------------------------------------------*

*..//  End -of-selection

*----------------------------------------------------------------------*

end-of-selection.


  perform DISPLAY_SIMPLE_ALV tables <FS_ITAB>.










*----------------------------------------------------------------------*

*..// Sub-routines

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*&      Form  APPEND_ITAB

*&---------------------------------------------------------------------*

*       Append into Internal Table from Workarea..

*----------------------------------------------------------------------*

*       ->PT_ITAB : ITAB with header line

*       ->P_FLAG  : S:start, (null):normal, E:End

*       ->P_KEY   : fieldname

*       ->P_VALUE : fieldvalue

*----------------------------------------------------------------------*

form APPEND_ITAB tables PT_ITAB

                 using  P_FLAG  P_KEY P_VALUE.

  field-symbols : <FS_ITAB> type any.


  if P_FLAG eq 'S'.

    clear : PT_ITAB.

  endif.


  assign component P_KEY of structure PT_ITAB to <FS_ITAB>.

  move : P_VALUE to <FS_ITAB>.


  case P_FLAG.

    when 'S'. "..nothing

    when ' '. "..nothing

    when 'E'. append PT_ITAB. clear PT_ITAB.

    when others.

  endcase.


  unassign <FS_ITAB>.

endform.                                                   " APPEND_ITAB

*&---------------------------------------------------------------------*

*&      Form  APPEND_BDCDATA

*&---------------------------------------------------------------------*

*       BDC setting

*----------------------------------------------------------------------*

*      -->P_BDCTAB   : Batch 입력: 신규테이블 필드구조

*      -->P_VAL1     : BDC 화면시작

*      -->P_VAL2     : BDC 모듈 풀  / 필드이름

*      -->P_VAL3     : BDC 화면번호 / BDC 필드값

*----------------------------------------------------------------------*

form APPEND_BDCDATA tables P_BDCTAB structure BDCDATA

                    using  P_VAL1 P_VAL2 P_VAL3.

  case P_VAL1.

    when SPACE.         "..field

      P_BDCTAB-FNAM     = P_VAL2.

      P_BDCTAB-FVAL     = P_VAL3.


    when others.        "..screen

      P_BDCTAB-PROGRAM  = P_VAL2.

      P_BDCTAB-DYNPRO   = P_VAL3.

      P_BDCTAB-DYNBEGIN = P_VAL1.

  endcase.

  append P_BDCTAB. clear P_BDCTAB.

endform.                                                " APPEND_BDCDATA




*&---------------------------------------------------------------------*

*&      Form  display_simple_alv

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*       ->PT_ITAB : ITAB with header line

*----------------------------------------------------------------------*

form DISPLAY_SIMPLE_ALV tables PT_ITAB.

  data : LO_SALV  type ref to CL_SALV_TABLE,

         LO_FUNCS type ref to CL_SALV_FUNCTIONS_LIST,

         LO_COLS  type ref to CL_SALV_COLUMNS_LIST.


  "..// create instance

  try.

      call method CL_SALV_TABLE=>FACTORY

        importing

          R_SALV_TABLE = LO_SALV

        changing

          T_TABLE      = PT_ITAB[].

    catch CX_SALV_MSG .

  endtry.


  "..// set functions

  LO_FUNCS = LO_SALV->GET_FUNCTIONS( ).

  LO_FUNCS->SET_ALL( ABAP_TRUE ).



  "..// column optimize

  LO_COLS  = LO_SALV->GET_COLUMNS( ).

  LO_COLS->SET_OPTIMIZE( ABAP_TRUE ).


  "..// Display

  LO_SALV->DISPLAY( ).


endform.                    "display_simple_alv

 
개인적으로 갖다 쓰라는 얘긴 못하겠음...ㅋㅋㅋ
 
저작자 표시 비영리 동일 조건 변경 허락
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 세지군 트랙백 0 : 댓글 0