[9기 SAP방] 챗GPT에 질문하여 ALV 필드 및 행 숨기기 매뉴얼

챗gpt로 질문한 내용 링크 드립니다.

https://chat.openai.com/share/05f6a9ce-595e-4903-988c-c7bbfd7fc6be

위와 같이 답을 주었습니다.

그래서 row도 숨길수있는지 여쭤보았습니다.


상태창과 스크린 만드는법은 아래 링크에 있는 내용과 동일합니다.

https://www.gpters.org/language/post/create-innerjoin-table-alv-JaFwOAyfu9Q0VtJ


소스코드

*&---------------------------------------------------------------------*
*& Report  ZGPTERS_09_UP_09
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZGPTERS_09_UP_09.

*&---------------------------------------------------------------------*
*& Report  ZGPTERS_09_UP_08
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

*REPORT ZGPTERS_09_UP_08.

TABLES : SSCRFIELDS.


"ALV
DATA : GO_ALV TYPE REF TO CL_GUI_ALV_GRID. "ALV
DATA : GO_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. "DETAL

DATA : GS_LAYOUT TYPE LVC_S_LAYO. "LAYOUT

DATA : GT_FCAT TYPE LVC_T_FCAT. "FIELD OPTION
DATA : GS_VARIANT TYPE DISVARIANT. "DEFAULT, USER VARIANCT
DATA: L_ABAP_SOURCE(132) TYPE C.  " 너비를 132자로 확장


DATA : OK_CODE TYPE SY-UCOMM.

*DATA : GT_ITAB LIKE SFLIGHT OCCURS 0
*      WITH HEADER LINE. "ITAB AND STRUCT
DATA : GT_ITAB LIKE ZSCARR_JOIN OCCURS 0
WITH HEADER LINE. "ITAB AND STRUCT
*WORK AREA   "LVC 필트카다로그 펑션사용시 LIKE사용해야함




*
*TYPES: BEGIN OF ty_result,
*         carrid TYPE sflight-carrid,
*         connid TYPE sflight-connid,
*         fldate TYPE sflight-fldate,
*         price TYPE sflight-price,
*  URL TYPE SCARR-URL,
*       END OF ty_result.
*
*DATA: GT_ITAB TYPE TABLE OF ty_result,
*      GS_ITAB TYPE ty_result.




START-OF-SELECTION.

  SELECT s1~carrid
         s1~connid
         s1~fldate
         s1~price
    S2~URL
    INTO CORRESPONDING FIELDS OF TABLE Gt_ITAB
*    INTO TABLE GT_ITAB
    FROM sflight AS s1
    INNER JOIN scarr AS s2
    ON s1~carrid = s2~carrid.


IF GT_ITAB[] IS INITIAL.
  MESSAGE S001(ZABAP) WITH 'NODATA'.
  ELSE.
*    CL_DEMO_OUTPUT=>DISPLAY( LT_ITAB[] ).

  LOOP AT GT_ITAB INTO DATA(ls_itab).
    IF ls_itab-carrid = 'AA'. "숨기고자 하는 조건에 맞게 수정
      DELETE GT_ITAB INDEX SY-TABIX.
    ENDIF.
  ENDLOOP.

    CALL SCREEN 100.

  ENDIF.
*call SCREEN 100.

END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'PBO0100'.
  SET TITLEBAR 'PBO0100'.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.

*    IF 'BACK' OR 'EXIT' OR 'CANC'.
*
*      LEAVE TO SCREEN 0.
*
*    ENDIF.

      CASE SY-UCOMM.
    WHEN 'BACK' OR 'CANC'.
*      IF SY-CALLD IS INITIAL.
        LEAVE TO SCREEN 0.
*      ELSE.
*        LEAVE PROGRAM.
*      ENDIF.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
  CLEAR SY-UCOMM.

ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  ALV_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE ALV_0100 OUTPUT.


DATA: LT_FCAT TYPE SLIS_T_FIELDCAT_ALV.

  "SCREED PBO

  "CONTAINER SETTING
  CREATE OBJECT GO_CONTAINER
  EXPORTING
    CONTAINER_NAME = 'CON0100'.

  "ALV GRID SETTING
  CREATE OBJECT GO_ALV
  EXPORTING
    I_PARENT = GO_CONTAINER.



  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     I_PROGRAM_NAME               = SY-REPID
     I_INTERNAL_TABNAME           = 'GT_ITAB'
     I_STRUCTURE_NAME             = 'ZSCARR_JOIN_S'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
     I_INCLNAME                   = SY-REPID
*     I_BYPASSING_BUFFER           =
*     I_BUFFER_ACTIVE              =
    CHANGING
      CT_FIELDCAT                  = LT_FCAT[]
*   EXCEPTIONS
*     INCONSISTENT_INTERFACE       = 1
*     PROGRAM_ERROR                = 2
*     OTHERS                       = 3
            .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.


LOOP AT LT_FCAT INTO DATA(ls_fieldcat).
    IF ls_fieldcat-fieldname = 'CONNID'.
      ls_fieldcat-tech = 'X'.
      MODIFY LT_FCAT FROM ls_fieldcat INDEX sy-tabix.
    ENDIF.
  ENDLOOP.


 CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
   EXPORTING
     IT_FIELDCAT_ALV       = LT_FCAT
*    IT_SORT_ALV           =
*    IT_FILTER_ALV         =
*    IS_LAYOUT_ALV         =
  IMPORTING
    ET_FIELDCAT_LVC       = GT_FCAT
*    ET_SORT_LVC           =
*    ET_FILTER_LVC         =
*    ES_LAYOUT_LVC         =
   TABLES
     IT_DATA               = GT_ITAB
*     IT_DATA               = lt_result
*  EXCEPTIONS
*    IT_DATA_MISSING       = 1
*    OTHERS                = 2
           .
 IF SY-SUBRC <> 0.
* Implement suitable error handling here
 ENDIF.

  "ALV LAYOUT
  GS_LAYOUT-SEL_MODE = 'A'.


"ALV PRINT

CALL METHOD GO_ALV->SET_TABLE_FOR_FIRST_DISPLAY
 EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
    IS_VARIANT                    = GS_VARIANT
    I_SAVE                        = 'A'
    I_DEFAULT                     = 'X'
    IS_LAYOUT                     = GS_LAYOUt
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
*    IR_SALV_ADAPTER               =
  CHANGING
    IT_OUTTAB                     = GT_ITAB[]
    IT_FIELDCATALOG               = GT_FCAT[]
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    others                        = 4
        .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.


ENDMODULE.                 " ALV_0100  OUTPUTㅅ

3322





이상입니다.

5주동안 부트캠프 9기 참여해주셔서 감사합니다.


#9기 SAP방

3
2개의 답글

👉 이 게시글도 읽어보세요

모집 중인 AI 스터디