Skip to Content
0
Former Member
Nov 08, 2007 at 09:33 PM

Process Checkbox value in an ALV Output

58 Views

Hi All,

I have the following code below.

I have a check box in the ALV output.

When I check the check box in the ALV output and do further process I cant see the 'X' value being passed on to the checkbox field.

Could anyone kindly help me with letting me know where am I going wrong.

Please find the code below.

Regards,

Karthik

&----


*& Report ZGB_TEST *

*& *

&----


REPORT ZGB_TEST NO STANDARD PAGE HEADING

MESSAGE-ID FB.

----


  • INCLUDE

----


INCLUDE Z_STANDARD_HEADING_ALV.

----


  • TYPES *

----


TYPE-POOLS: SLIS. "ALV

TYPES: BEGIN OF TY_PKHD,

PKNUM TYPE PKNUM,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

PRVBE TYPE PRVBE,

LIFNR TYPE LIFNR,

PKBHT TYPE PKBHT,

ABLAD TYPE STLPL,

END OF TY_PKHD,

BEGIN OF TY_PKPS,

PKKEY TYPE PKKEY,

PKNUM TYPE PKNUM,

PKPOS TYPE PKPOS,

PKIMG TYPE PKIMG,

END OF TY_PKPS,

BEGIN OF TY_MAKT,

MATNR TYPE MATNR,

MAKTX TYPE MAKTX,

END OF TY_MAKT,

BEGIN OF TY_LFA1,

LIFNR TYPE LIFNR,

NAME1 TYPE NAME1,

END OF TY_LFA1,

BEGIN OF TY_MARC,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

BESKZ TYPE BESKZ,

BSTMI TYPE BSTMI,

END OF TY_MARC,

BEGIN OF TY_MAPL,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

PLNTY TYPE PLNTY,

PLNNR TYPE PLNNR,

PLNAL TYPE PLNAL,

ZKRIZ TYPE DZKRIZ,

ZAEHL TYPE CIM_COUNT,

END OF TY_MAPL,

BEGIN OF TY_PLPO,

PLNTY TYPE PLNTY,

PLNNR TYPE PLNNR,

PLNKN TYPE PLNKN,

ZAEHL TYPE CIM_COUNT,

VORNR TYPE VORNR,

ARBID TYPE ARBID,

WERKS TYPE WERKS_D,

LTXA1 TYPE LTXA1,

VGW01 TYPE VGWRT,

VGW02 TYPE VGWRT,

OBJID TYPE CR_OBJID,

END OF TY_PLPO,

BEGIN OF TY_CRHD,

OBJTY TYPE OBJTY,

OBJID TYPE CR_OBJID,

ARBPL TYPE ARBPL,

WERKS TYPE WERKS_D,

END OF TY_CRHD,

BEGIN OF TY_OUTPUT,

CHECKBOX(1),

PKKEY TYPE PKKEY,

MATNR TYPE MATNR,

MAKTX TYPE MAKTX,

BSTMI TYPE BSTMI,

PKIMG TYPE PKIMG,

MATHCALC TYPE I,

LIFNR TYPE LIFNR,

NAME1 TYPE NAME1,

PRVBE TYPE PRVBE,

ABLAD TYPE STLPL,

PKBHT TYPE PKBHT,

END OF TY_OUTPUT,

TI_PKHD TYPE STANDARD TABLE OF TY_PKHD,

TI_PKPS TYPE STANDARD TABLE OF TY_PKPS,

TI_MAKT TYPE STANDARD TABLE OF TY_MAKT,

TI_LFA1 TYPE STANDARD TABLE OF TY_LFA1,

TI_MARC TYPE STANDARD TABLE OF TY_MARC,

TI_MAPL TYPE STANDARD TABLE OF TY_MAPL,

TI_PLPO TYPE STANDARD TABLE OF TY_PLPO,

TI_CRHD TYPE STANDARD TABLE OF TY_CRHD,

TI_OUTPUT TYPE STANDARD TABLE OF TY_OUTPUT.

----


  • DATA *

----


  • TABLES: mara, marc, pkhd.

DATA: WA_MARA TYPE MARA,

WA_MARC TYPE MARC,

WA_PKHD TYPE PKHD.

  • INTERNAL TABLES

DATA: GT_PKHD TYPE TI_PKHD,

GT_PKPS TYPE TI_PKPS,

GT_MAKT TYPE TI_MAKT,

GT_LFA1 TYPE TI_LFA1,

GT_MARC TYPE TI_MARC,

GT_MAPL TYPE TI_MAPL,

GT_PLPO TYPE TI_PLPO,

GT_CRHD TYPE TI_CRHD,

GT_OUTPUT TYPE TI_OUTPUT.

  • GLOBAL VARIABLES

DATA: GV_LGORT TYPE LGORT_D.

  • STRUCTURES FOR ALV DISPLAY

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

GT_EVENTS TYPE SLIS_T_EVENT,

GT_SORT TYPE SLIS_T_SORTINFO_ALV,

GS_SORT TYPE SLIS_SORTINFO_ALV,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA: BEGIN OF STR_OUTPUT,

CHECKBOX(1),

PKKEY LIKE PKPS-PKKEY,

MATNR LIKE PKHD-MATNR,

MAKTX LIKE MAKT-MAKTX,

BSTMI LIKE MARC-BSTMI,

PKIMG LIKE PKPS-PKIMG,

MATHCALC TYPE I,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

PRVBE LIKE PKHD-PRVBE,

ABLAD LIKE PKHD-ABLAD,

PKBHT LIKE PKHD-PKBHT,

END OF STR_OUTPUT.

----


  • SELECTION SCREEN *

----


SELECTION-SCREEN: BEGIN OF BLOCK SEL_3 WITH FRAME TITLE TEXT-003.

PARAMETERS : P_WERKS LIKE WA_MARC-WERKS OBLIGATORY,

P_PRVBE LIKE WA_PKHD-PRVBE OBLIGATORY.

SELECTION-SCREEN: END OF BLOCK SEL_3.

SELECTION-SCREEN: BEGIN OF BLOCK SEL_2 WITH FRAME TITLE TEXT-002.

SELECT-OPTIONS : S_MATNR FOR WA_MARA-MATNR OBLIGATORY.

SELECTION-SCREEN: END OF BLOCK SEL_2.

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

PARAMETER : P_CHX AS CHECKBOX.

SELECT-OPTIONS : S_PKBHT FOR WA_PKHD-PKBHT.

SELECTION-SCREEN: END OF BLOCK SEL_1.

----


  • AT SELECTION SCREEN *

----


----


  • START-OF-SELECTION

----


START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM PREPARE_OUTPUT.

----


  • END-OF-SELECTION

----


END-OF-SELECTION.

CHECK NOT GT_OUTPUT IS INITIAL.

PERFORM GET_FIELDCATALOG. "build field catalog for ALV disp

PERFORM DISPLAY_DATA. "display data as ALV report

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA .

  • Get data code

ENDFORM. " get_data

&----


*& Form PREPARE_OUTPUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PREPARE_OUTPUT .

  • Prepate output code

ENDFORM. " PREPARE_OUTPUT

&----


*& Form GET_FIELDCATALOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_FIELDCATALOG .

DATA : WA_FIELDCAT LIKE LINE OF GT_FIELDCAT.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'STR_OUTPUT'

I_INCLNAME = 'ZGB_TEST'

I_BYPASSING_BUFFER = 'X'

I_BUFFER_ACTIVE = 'X'

CHANGING

CT_FIELDCAT = GT_FIELDCAT[].

LOOP AT GT_FIELDCAT INTO WA_FIELDCAT

WHERE FIELDNAME = 'CHECKBOX'.

WA_FIELDCAT-OUTPUTLEN = 2.

WA_FIELDCAT-CHECKBOX = 'X'.

WA_FIELDCAT-EDIT = 'X'.

  • WA_FIELDCAT-INPUT = '1'.

MODIFY GT_FIELDCAT FROM WA_FIELDCAT.

ENDLOOP.

ENDFORM. " GET_FIELDCATALOG

&----


*& Form GET_EVENTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_EVENTS .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

IMPORTING

ET_EVENTS = GT_EVENTS[].

ENDFORM. " GET_EVENTS

&----


*& Form DISPLAY_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_DATA .

DATA: WA_FIELDCAT LIKE LINE OF GT_FIELDCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_BYPASSING_BUFFER = 'X'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'(006)

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = GT_FIELDCAT[]

IT_EVENTS = GT_EVENTS[]

TABLES

T_OUTTAB = GT_OUTPUT[].

ENDFORM. " DISPLAY_DATA

&----


*& Form set_status

&----


  • GUI STATUS SET

----


FORM SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.

DELETE RT_EXTAB WHERE FCODE = '&REFRESH'.

SET PF-STATUS 'STANDARD_FULLSCREEN' EXCLUDING RT_EXTAB.

ENDFORM. "set_status

&----


*& Form USER_COMMAND

&----


  • text

----


FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM "#EC CALLED

LS_SELFIELD TYPE SLIS_SELFIELD. "#EC *

CASE R_UCOMM.

WHEN 'PALL'.

  • Print All

WHEN 'PSEL'.

  • Print Selected

ENDCASE.

ENDFORM. "user_command