i made a program to display as an output an ALV report with a check box column and a custom button with custom FCT code.
when the alv is displayed and multiple rows are checked ,i need to fetch data of the selected rows with the check box and display them on a new window with a table control.
please take into consideration that iam still new to abap ,so plz explain your answers.
tables : vbak,
tvakt,
dd07t,
kna1.
TYPE-POOLS: slis.
*&---------------------------------------------------------------------*
*Data declaration and types constructing
*-----------------------------------------------
types : begin of task_report,
check(1) type c,
vbeln type vbak-vbeln,
kunnr type vbak-kunnr,
audat type vbak-audat,
vbtyp type vbak-vbtyp,
netwr type vbak-netwr,
waerk type vbak-waerk,
auart type vbak-auart,
name1 type kna1-name1,
stras type kna1-stras,
bezei type tvakt-bezei,
ddtext type DD07T-ddtext,
color(4) type c,
end of task_report.
DATA : it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv,
is_layout type slis_layout_alv,
it_excluding TYPE slis_t_extab,
wa_excluding TYPE slis_extab.
DATA : it_task_report type table of task_report,
wa_task_report type task_report.
SELECTION-SCREEN begin of BLOCK B.
SELECT-OPTIONS or_num for WA_TASK_REPORT-vbeln.
SELECT-OPTIONS cust for WA_TASK_REPORT-kunnr.
SELECTION-SCREEN END OF BLOCK B.
*-----------------------------------------------
select
a~vbeln,
a~kunnr,
a~audat,
a~vbtyp,
a~netwr,
a~waerk,
a~auart,
b~name1,
b~stras,
c~bezei,
d~ddtext
from vbak as a INNER JOIN kna1 as b on a~KUNNR = b~KUNNR
INNER JOIN TVAKT as c on a~AUART = c~AUART and c~SPRAS = 'E'
INNER JOIN dd07t as d on a~VBTYP = d~DOMVALUE_L and d~DDLANGUAGE = 'E' and d~DOMNAME = 'VBTYP'
where a~vbeln in @or_num and a~kunnr in @cust
into CORRESPONDING FIELDS OF table @IT_TASK_REPORT.
clear WA_TASK_REPORT.
LOOP AT IT_TASK_REPORT INTO WA_TASK_REPORT.
IF WA_TASK_REPORT-netwr GE 10000.
WA_TASK_REPORT-color = 'C500'.
ENDIF.
MODIFY IT_TASK_REPORT FROM WA_TASK_REPORT TRANSPORTING color.
CLEAR: WA_TASK_REPORT.
ENDLOOP.
*-------------------------------------------------------------------Building the field catalogue-----------------------------------------------------------------------------*
wa_fcat-fieldname ='CHECK'.
wa_fcat-seltext_m ='Check'.
wa_fcat-tabname ='it_task_report'.
wa_fcat-EDIT = 'X'.
WA_FCAT-CHECKBOX = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='VBELN'.
wa_fcat-seltext_m ='Sales order number'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='VBELN'.
wa_fcat-seltext_m ='Sales order number'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='KUNNR'.
wa_fcat-seltext_m ='Customer'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
clear WA_FCAT.
wa_fcat-fieldname ='NAME1'.
wa_fcat-seltext_m ='Customer name'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='STRAS'.
wa_fcat-seltext_m ='Address'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='AUDAT'.
wa_fcat-seltext_m ='Document date'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='VBTYP'.
wa_fcat-seltext_m ='Document category'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='DDTEXT'.
wa_fcat-seltext_m ='Document category description'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='NETWR'.
wa_fcat-seltext_m ='Net value'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='WAERK'.
wa_fcat-seltext_m ='Currency'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='AUART'.
wa_fcat-seltext_m ='Sales order type'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname ='BEZEI'.
wa_fcat-seltext_m ='Order type description'.
wa_fcat-tabname ='it_task_report'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
*--------------------------------------------------------------------finished building field catalog-----------------------------------------------------------------------*
IS_LAYOUT-info_FIELDNAME = 'COLOR'.
IS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = it_fcat
IS_LAYOUT = is_layout
I_callback_user_command = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
TABLES
t_outtab = IT_TASK_REPORT
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----------------------------------------------------------*
* FORM USER_COMMAND *
*----------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*----------------------------------------------------------*
FORM USER_COMMAND using r_ucomm like sy-UCOMM
rs_selfield type slis_selfield.
IF r_ucomm = '&FAD'.
*what to write in here to fetch the selected rows with the check box and display them on a table control in a new *window "&FAD is the FCT code of the custom button"
ENDIF.
FORM SET_PF_STATUS using rx_extab type SLIS_t_EXTAB.
SET PF-STATUS 'TASK1_PF'.
ENDFORM.
* the pf status is for adding the custom button