메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT Z_SWR_H1_ALV MESSAGE-ID f5 NO STANDARD PAGE HEADING
                                        LINE-SIZE 150
                                        LINE-COUNT 65.
************************************************************************
* TABLES
************************************************************************
TABLES : bkpf, "Accounting Document Header
         bseg. "Accounting Document Segment


************************************************************************
* DATA ( &TYPE)
************************************************************************
DATA : it_01 LIKE bkpf OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF it_02 OCCURS 0,
       bukrs LIKE bkpf-bukrs,  "회사코드
       belnr LIKE bkpf-belnr,  "전표번호
       gjahr LIKE bkpf-gjahr,  "회계연도
       blart LIKE bkpf-blart,  "전표유형
       bldat LIKE bkpf-bldat,  "증빙일
       budat LIKE bkpf-budat,  "전기일
       stblg LIKE bkpf-stblg,  "역분개전표
       stjah LIKE bkpf-stjah,  "역분개저너표 회계연도
       waers LIKE bkpf-waers,  "통화키
       monat LIKE bkpf-monat,  "회계기간
       buzei LIKE bseg-buzei,  "개별항목번호
       bschl LIKE bseg-bschl,  "전기키
       shkzg LIKE bseg-shkzg,  "차변/대변지시자
       dmbtr LIKE bseg-dmbtr,  "현지통화금액
       wrbtr LIKE bseg-wrbtr,  "전표통화금액
       sgtxt LIKE bseg-sgtxt,  "적요
       END OF it_02.

TYPE-POOLS : slis.


DATA : 1_pos      TYPE i VALUE 0.
DATA : fieldcat TYPE slis_t_fieldcat_alv,
       fieldcat_ln LIKE LINE OF fieldcat.
DATA : sortcat    TYPE slis_t_sortinfo_alv,
       sortcat_ln LIKE LINE OF sortcat.
DATA : eventcat   TYPE slis_t_event,
       eventcat_ln like line of eventcat.


************************************************************************
*SELECTION SCREEN( SELECT OPTIONS & PARAMETERS)
************************************************************************
selection-screen BEGIN OF block b1 WITH frame title text-001.
PARAMETERS : p_bukrs LIKE bkpf-bukrs OBLIGATORY MEMORY ID buk,
             p_gjahr LIKE bkpf-gjahr OBLIGATORY DEFAULT sy-datum,
            
SELECT-OPTIONS : s_belnr FOR bkpf-belnr.
SELECTION-SCREEN END OF BLOCK b1.


************************************************************************
* START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
* BKPF READ
  PERFORM read_bkpf.
* BSEG READ
  PERFORM read_bseg.
* IT_02 -> IT_01
  PERFORM merge_data.
***********************************************************************
* END-OF_SELECTION
***********************************************************************
END-OF-SELECTION.
*  PERFORM write_data.
  PERFORM build_fieldcat.
  PERFORM build_sortcat.
  PERFORM build_eventcat.
  PERFORM ALV_WRITE.


*&---------------------------------------------------------------------*
*&      Form  READ_BKPF
*&---------------------------------------------------------------------*
*       BKPF 내역 READ
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM read_bkpf.
  CLEAR it_01.
  REFRESH it_01.       "모든 INTERNAL TABLE이 가지고 있는 ENTRY삭제
  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE it_01
  FROM bkpf
  WHERE bukrs = p_bukrs
  AND gjahr = p_gjahr
  AND belnr IN s_belnr.

ENDFORM.                    " READ_BKPF


*&---------------------------------------------------------------------*
*&       Form  READ_BSEG
*&---------------------------------------------------------------------*
*        BSEG 내역 READ
*-----------------------------------------------------------------------
FORM read_bseg.
  CLEAR it_02.
  REFRESH it_02.
  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE it_02
  FROM bseg
  WHERE bukrs = p_bukrs
  AND gjahr = p_gjahr
  AND belnr IN s_belnr.
ENDFORM.                    " READ_BSEG


*IT_02의 정보를 IT_01에 넣어주도록 하자
*&----------------------------------------------------------------------
*&   FORM  MERGE_DATA
*&----------------------------------------------------------------------
*     IT_01 + iT_02 MERGE
*&---------------------------------------------------------------------*
FORM merge_data.
  SORT it_01 BY bukrs gjahr belnr.
  SORT it_02 BY bukrs gjahr belnr.
  LOOP AT it_02.
    READ TABLE it_01 WITH KEY bukrs = it_02-bukrs
                              gjahr = it_02-gjahr
                              belnr = it_02-belnr
                              BINARY SEARCH.

    IF sy-subrc <> 0.
    ELSE.
      it_02-blart = it_01-blart.
      it_02-bldat = it_01-bldat.
      it_02-budat = it_01-budat.
      it_02-stblg = it_01-stblg.
      it_02-stjah = it_01-stjah.
      it_02-waers = it_01-waers.
    ENDIF.
    IF it_02-shkzg  = 'H'.      "대변이면,
      it_02-dmbtr  = it_02-dmbtr * -1.
      it_02-wrbtr  = it_02-wrbtr * -1.
    ENDIF.
    MODIFY it_02.
  ENDLOOP.
ENDFORM.        "MERGE_DATA



*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcat.
  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BUKRS'.
  fieldcat_ln-key          = 'X'.     "필드고정역할, 색이다르게 나타남!!
  fieldcat_ln-emphasize    = 'C600'.  "COL_NEGATIVE색이다
* 색이두가지(빨강,파랑)가 같이 나타남(실행시에)
  fieldcat_ln-reptext_ddic = '회사코드'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'GJAHR'.
*  fieldcat_ln-key          = 'X'.
  fieldcat_ln-reptext_ddic = '회계연도'.
  APPEND fieldcat_ln TO fieldcat.



  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BELNR'.


  fieldcat_ln-reptext_ddic = '전표번호'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BLART'.
  fieldcat_ln-reptext_ddic = '전표유형'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BLDAT'.
  fieldcat_ln-emphasize    = 'C400'.
  fieldcat_ln-reptext_ddic = '증빙일'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BUDAT'.
  fieldcat_ln-emphasize    = 'C100'.
  fieldcat_ln-reptext_ddic = '전기일'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'WARES'.
  fieldcat_ln-reptext_ddic = '통화키'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BUZEI'.
  fieldcat_ln-reptext_ddic = '항목'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'BSCHL'.
  fieldcat_ln-reptext_ddic = '전기키'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'DMBTR'.
  fieldcat_ln-currency     = 'KRW'.
  fieldcat_ln-reptext_ddic = '현지통화금액'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'WRBTR'.
  fieldcat_ln-do_sum       = 'X'.
  fieldcat_ln-reptext_ddic = '전표통화금액'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'SGTXT'.
  fieldcat_ln-reptext_ddic = '적요'.
  APPEND fieldcat_ln TO fieldcat.


  1_pos = 1_pos + 1.
  CLEAR fieldcat_ln.
  fieldcat_ln-col_pos      = 1_pos.
  fieldcat_ln-fieldname    = 'STBLG'.
  fieldcat_ln-reptext_ddic = '역분개전표'.
  APPEND fieldcat_ln TO fieldcat.


ENDFORM.                    " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  build_sortcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_sortcat.
  sortcat_ln-spos = '1'.  "정렬하고자 하는 필드 순서를 지정
    sortcat_ln-fieldname = 'BUKRS'. "정렬하고자하는 FIELD명
    sortcat_ln-up = 'X'. "오름차순
    sortcat_ln-down = space. "내림차순정렬
  sortcat_ln-subtot = space.
  APPEND sortcat_ln TO sortcat.
ENDFORM.                    " build_sortcat
*&---------------------------------------------------------------------*
*&      Form  build_eventcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form build_eventcat.
EVENTCAT_LN-NAME = 'TOP_OF_PAGE'.
EVENTCAT_LN-FORM = 'PAGE_HEADER'.
APPEND EVENTCAT_ln TO EVENTCAT.
endform.                    " build_eventcat
*&---------------------------------------------------------------------*
*&      Form  ALV_WRITE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form ALV_WRITE.
DATA : PGM LIKE SY-REPID.   "PGM 변수선언
PGM = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
     EXPORTING                                   "Function으로 Data전송
               I_CALLBACK_PROGRAM      = PGM
               I_CLAABACK_USER_COMMNAD = 'USER_COMMMAND'
               IT_FIELDCAT             = FIELDCAT
               IT_SORT                 = SORTCAT
               I_SAVE                  = 'U'
               IT_EVENTS               = EVENTCAT
     TABLES
               T_OUTTAB                = IT_02
     EXCEPTIONS
               PROGRAM_ERROR           = 1
               OTHERS                  = 2.
endform.                    " ALV_WRITE


*&---------------------------------------------------------------------*
*    사용자 EVENT
*&---------------------------------------------------------------------*
FORM USER_COMMAND USING r_ucomm TYPE sy-ucomm
                        rs_selfield TYPE slis_selfield.


 CASE r_ucomm.
*더블클릭
   WHEN '&IC1'.
     READ TABLE it_02 INDEX rs_selfield-tabindex.
     IF it_02-belnr <> ' '.
       SET PARAMETER ID 'BLN' FIELD it_02-belnr.
       SET PARAMETER ID 'BUK' FIELD it_02-bukrs.
       SET PARAMETER ID 'GJR' FIELD it_02-gjahr.


       CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
     ENDIF.
 ENDCASE.
ENDFORM.                                "USER_COMMAND


*&---------------------------------------------------------------------
*
*&            Form  PAGE_HEADER
*&---------------------------------------------------------------------


FORM PAGE_HEADER.
 SKIP 1.
 WRITE : '전표내역 ALV 프로그램 HEADER'.
 ENDFORM.


 


 


ALV조회시 Double click해서 해당내역을 조회하려 합니다만(FB03)


 


어찌된 일인지 Double Click해봐도 먹통이네요...;;;


 


고수분들의 답변 기다립니다..ㅠ


 


 

번호 제목 글쓴이 날짜 조회 수
2833 [요청]SMARTFORM 관련 좋은 책좀 추천해주세요. [2] 찬호사랑 2008.12.17 896
2832 [요청]ALV Function 비교 - REUSE_ALV_GRID_DISPLAY & _LVC [1] 찬호사랑 2008.12.17 1444
2831 [요청]online프로그램으로 출장관리 프로그램을 만들려고합니다. 조언부탁드립니다 maeno2k 2008.12.17 1282
2830 [요청]안녕하세요...혹시 프로그램과 프로그램 description이 들어있는 테이블?? [2] 아밥초짜 2008.12.17 1077
2829 <b>[완료]</b>ID값 증가에 대한 질문 드립니다. [1] 튀밥 2008.12.16 1454
2828 <b>[완료]</b>WBS 출력할때 숫자코드값으로 보이는 문제 질문입니다 [3] SD_꽃미남 2008.12.16 1649
2827 <b>[완료]</b>T-code에 관한 질문입니다.급합니다.고수님들도와주세요 [5] 쭈니 2008.12.16 1435
2826 [요청]고객 생성 BDC (T-CODE : XD01) 에서 Recording할 때와 직접 실행할 때 스크린이 다를 경우...(?) [1] file 효방 ^-^ 2008.12.16 1947
2825 [요청]alv에서 type이하 선언에 관해..... [5] 아밥우먼 2008.12.16 1303
» <b>[완료]</b>ALV에서 Double Click시 전표내역을 조회하려고 합니다만... [3] 우락부락 2008.12.16 3080
2823 [요청]월드 파일 어케 PDF파일로 전환하여 출력할수 있을가요? [1] im 해성 2008.12.16 1364
2822 <b>[완료]</b><b>[완료]</b><b>[완료]</b>데이터 입력에 관한 질문입니다. [5] file 튀밥 2008.12.15 1287
2821 <b>[완료]</b>alv 관련 질문 입니다. edit 를 사용 하는면에서 .. [5] whdrms11 2008.12.15 1645
2820 <b>[완료]</b>인터널 테이블 값 찾는방법 궁금 합니다. [2] 초보bsp/abap 2008.12.15 1405
2819 <b>[완료]</b>OBJECTS_NOT_CHARLIKE <- 왜 나올까요 [2] 배불뚝이용 2008.12.15 1566
2818 <b>[완료]</b>Sap GUI Logon 서버정보 백업 파일 아시는분? [3] 엉큼고냥이 2008.12.15 1993
2817 [요청]asynchronous update/ssynchronous update 의 차이점 밥돌이 2008.12.15 1175
2816 [요청]원가요소를 가져올때.. bapi_costelem_getlist / k_hierarchy_tables_read.. sincere 2008.12.15 2826
2815 [요청]KKBLO와 'REUSE_ALV_GRID_DISPLAY'에 대한 질문입니다. [2] 원더걸 2008.12.14 3265
2814 [요청]'POPUP_WITH_3_BUTTONS_TO_CHOOSE' FUNCTION 관련 질문입니다. [2] 어렵다 2008.12.13 1369