Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

calling the smartform based on checkboxes selection in ALV

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

10 REPLIES 10

0 Kudos

Do this:

When 'print Button'.

LOOP AT i_data where sel = 'X'

PRINT.

ENDLOOP.

0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

Hello friend,

Try these links it will help you to solve your request

I think this will solve your issue if the problem exists still please revert back to me i will help you.

Thanks,

Sri Hari

0 Kudos

Hi Srihari,

Thank you very much.My problem has been solved.

Former Member
0 Kudos

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]

Link: []

Come up with queries if any!!!

Cheers

VJ

0 Kudos

Hi vishal.

thank you very much for ur reply.

0 Kudos

This message was moderated.