2011 Dec 22 9:38 AM
Hi
i displayed the report output in ALV using 'REUSE_ALV_GRID_DISPLAY'. I maintained checkboxes as first column of data.
and i also added three user defined buttons like check,uncheck,print form. Now my problem is when user selecting the records in ALV using the checkbox, i have to trace out which checkbox has been selected in ALV and when user clicks on print form button, based up on user selection i have to call the smartform for that partcular record and print. So for every record,it has to check and call the smartform. All my data in internal table i_data. Can anyone suggest on this.
FORM USER_COMMAND USING FU_UCOMM LIKE SY-UCOMM FU_SELFIELD TYPE SLIS_SELFIELD.
CASE fu_ucomm.
WHEN '&CHK'."when user press on check all button
LOOP AT i_data.
MOVE 'X' TO i_data-sel.
MODIFY I_DATA.
ENDLOOP.
FU_SELFIELD-REFRESH = 'X'.
WHEN '&DCHK'. "when user press on decheck all button
LOOP AT I_DATA .
MOVE ' ' TO i_data-SEL.
MODIFY I_DATA TRANSPORTING SEL.
CLEAR I_DATA.
ENDLOOP.
FU_SELFIELD-REFRESH = 'X'.
when '&print''."when user presson print button
ENDCASE.
ENDFORM. "USER_COMMAND
2011 Dec 22 12:10 PM
Hi Arjun,
And maintain wa_fcat-hotspot = 'X' in Fieldcatalog for Check field.
When you press on checkbox, the checkbox is highligthed and X value is updated in Internal table.
Place the button(Print) and call the smartform in your program and use this internal table because that internal table will hold only the checked values.
Place below code in user_command.
WHEN OTHERS.
READ TABLE IT_EKKO ASSIGNING <WA_EKKO> INDEX FU_SELFIELD-TABINDEX.
<WA_EKKO>-CHECK = 'X'.
MODIFY table IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK .
FU_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM.
hope this is helpful.
Regards,
G.Aditya.
Edited by: Aditya.G on Dec 22, 2011 5:41 PM
2011 Dec 22 11:04 AM
Do this:
When 'print Button'.
LOOP AT i_data where sel = 'X'
PRINT.
ENDLOOP.
2011 Dec 22 11:12 AM
Hi Arjun,
Logic for both Check and Uncheck are proper. use below code for &Print
when '&print'.
LOOP AT i_data where sel = 'X'.
PERFORM 'call_Smartform' . "Call you smartform from here
ENDLOOP.
2011 Dec 22 12:10 PM
Hi Arjun,
And maintain wa_fcat-hotspot = 'X' in Fieldcatalog for Check field.
When you press on checkbox, the checkbox is highligthed and X value is updated in Internal table.
Place the button(Print) and call the smartform in your program and use this internal table because that internal table will hold only the checked values.
Place below code in user_command.
WHEN OTHERS.
READ TABLE IT_EKKO ASSIGNING <WA_EKKO> INDEX FU_SELFIELD-TABINDEX.
<WA_EKKO>-CHECK = 'X'.
MODIFY table IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK .
FU_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM.
hope this is helpful.
Regards,
G.Aditya.
Edited by: Aditya.G on Dec 22, 2011 5:41 PM
2011 Dec 23 8:01 AM
Hi adithya,
when i kept the hotspot in fieldcatalog,it is not allowing to select the checkbox,
remaining thing i done but it is coming only for one checkbox.if we select multiple checkboxes it is not coming.but i need smartform has to call for every checkbox user has selected.
can u suggest on this. i'm copying my code here.
LOOP AT I_DATA.
READ TABLE I_DATA INTO WA_DATA INDEX FU_SELFIELD-TABINDEX.
WA_DATA-SEL = 'X'.
MODIFY I_DATA FROM WA_DATA TRANSPORTING SEL.
FU_SELFIELD-REFRESH = 'X'.
MOVE-CORRESPONDING WA_DATA TO WA_PRINT.
APPEND WA_PRINT TO I_PRINT.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZHRF1_PTAR1001'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION FM_NAME
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
FR_DATE = PN-BEGDA
TO_DATE = PN-ENDDA
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
TABLES
ITAB = I_PRINT
* EXCEPTIONS
* FORMATTING_ERROR = 1
* INTERNAL_ERROR = 2
* SEND_ERROR = 3
* USER_CANCELED = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDCASE.
2011 Dec 27 2:34 AM
Hi Adithya,
when i take this
WHEN OTHERS.
READ TABLE IT_EKKO ASSIGNING <WA_EKKO> INDEX FU_SELFIELD-TABINDEX.
<WA_EKKO>-CHECK = 'X'.
MODIFY table IT_EKKO FROM <WA_EKKO> TRANSPORTING CHECK .
FU_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM.
the checkbox is updating only for one record. but i need for multiple records.Can u suggest please.
2011 Dec 27 4:09 AM
2011 Dec 27 6:21 AM
Hi Srihari,
Thank you very much.My problem has been solved.
2011 Dec 27 5:50 AM
Hi Arjun!!!!
Please see the below links for your reference. It will definitely solve your problem. First link will give u an idea what exactly needs to be done and second link is a small code snippet which will actually play a important role in achieving what exactly you want..
Link: [http://wiki.sdn.sap.com/wiki/display/Snippets/ALVGridDisplaywithcheckboxtoprocessselectedrecordsatruntime]
Come up with queries if any!!!
Cheers
VJ
2011 Dec 27 6:25 AM
2014 Mar 11 6:53 AM
2024 Jul 16 3:11 PM
Can you mention how you declare internal table for storing selected output. i_data andI_DATA.?