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: 

How can we get check box in alv report

Former Member
0 Kudos

Hi, All

how can we get a check box in an ALV report for every row,

6 REPLIES 6

Former Member
0 Kudos

hi, check this...

REPORT zcprg_sd_002_dmt .

INCLUDE zbdcrecx1 .

----


  • TABLES

*

----


TABLES : vbak ,

vbpa,

vbap,

kna1 ,

jcds,

knkk,

tj30t.

DATA: curry LIKE mkpf-mjahr,

vgbel LIKE lips-vgbel,

reason(40) TYPE c.

TYPE-POOLS : slis .

----


  • SELECTION SCREEN

*

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .

SELECT-OPTIONS : s_vkorg FOR vbak-vkorg DEFAULT '2000',

s_erdat FOR vbak-erdat DEFAULT sy-datum ,

s_vbeln FOR vbak-vbeln,

s_kunnr FOR kna1-kunnr ,

s_auart FOR vbak-auart.

SELECTION-SCREEN END OF BLOCK b1 .

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .

PARAMETERS : r_pgm RADIOBUTTON GROUP 1 USER-COMMAND $sy ,

r_pjmd RADIOBUTTON GROUP 1 DEFAULT 'X',

r_agm RADIOBUTTON GROUP 1,

r_ajmd RADIOBUTTON GROUP 1 ,

r_reje RADIOBUTTON GROUP 1,

r_all RADIOBUTTON GROUP 1 .

SELECTION-SCREEN END OF BLOCK b2 .

----


  • GLOBLE DATA

*

----


DATA : g_save(1) TYPE c ,

g_exit(1) TYPE c ,

g_variant LIKE disvariant ,

gx_variant LIKE disvariant ,

f2code LIKE sy-ucomm VALUE '&ETA' ,

layout TYPE slis_layout_alv ,

prg LIKE sy-repid ,

gt_list_top_of_page TYPE slis_t_listheader ,

gt_events TYPE slis_t_event ,

fieldcat TYPE slis_t_fieldcat_alv .

----


  • INTERNAL TABLES

*

----


DATA: BEGIN OF satab OCCURS 0,

vbeln TYPE vbak-vbeln,

objnr TYPE vbak-objnr,

status TYPE bsvx-sttxt,

END OF satab.

TYPES : BEGIN OF itab1 ,

nochk ,

vkorg LIKE vbak-vkorg,

vbeln LIKE vbak-vbeln,

objnr LIKE vbak-objnr,

erdat LIKE vbak-erdat,

name1(40) TYPE c,

netwr LIKE vbak-netwr,

waerk LIKE vbak-waerk,

kunnr LIKE kna1-kunnr,

ort01 LIKE kna1-ort01,

status LIKE bsvx-sttxt,

txt30 LIKE tj30t-txt30,

vbtyp LIKE vbak-vbtyp,

auart LIKE vbak-auart,

klimk LIKE knkk-klimk,

skfor LIKE knkk-skfor,

sauft LIKE knkk-sauft,

bal_c LIKE knkk-sauft,

c_avi LIKE knkk-sauft,

p_cl TYPE p DECIMALS 3,

END OF itab1 .

DATA : BEGIN OF itab OCCURS 0,

nochk ,

vkorg LIKE vbak-vkorg,

vbeln LIKE vbak-vbeln,

objnr LIKE vbak-objnr,

erdat LIKE vbak-erdat,

name1(40) TYPE c,

netwr LIKE vbak-netwr,

waerk LIKE vbak-waerk,

kunnr LIKE kna1-kunnr,

ort01 LIKE kna1-ort01,

status LIKE bsvx-sttxt,

txt30 LIKE tj30t-txt30,

vbtyp LIKE vbak-vbtyp,

auart LIKE vbak-auart,

klimk LIKE knkk-klimk,

skfor LIKE knkk-skfor,

sauft LIKE knkk-sauft,

bal_c LIKE knkk-sauft,

c_avi LIKE knkk-sauft,

p_cl TYPE p DECIMALS 3,

END OF itab .

DATA : w_knkli TYPE knkk-knkli,

w_oeikw TYPE s066-oeikw,

w_olikw TYPE s067-olikw,

w_ofakw TYPE s067-ofakw.

----


  • INITIALIZATION

*

----


INITIALIZATION .

prg = sy-repid .

----


  • Selection Options Mandatory

----


AT SELECTION-SCREEN OUTPUT .

----


  • START OF SELECTION

*

----


START-OF-SELECTION .

PERFORM get_sa_no .

PERFORM get_sa_details.

PERFORM merge_fieldcatalog .

PERFORM set_fieldcat .

PERFORM build_layout USING layout .

IF g_save EQ space .

PERFORM initialize_variant .

ENDIF .

PERFORM disp_alv .

$$----


$$

$$* F O R M M O D U L E S $$*

$$----


$$

&----


*& Form get_sa_n

&----


FORM get_sa_no .

SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE satab

WHERE vbeln IN s_vbeln

AND erdat IN s_erdat

AND vkorg IN s_vkorg

AND objnr NE space

AND auart IN s_auart

AND kunnr IN s_kunnr.

LOOP AT satab.

CALL FUNCTION 'STATUS_TEXT_EDIT'

EXPORTING

client = sy-mandt

flg_user_stat = 'X'

objnr = satab-objnr

only_active = 'X'

spras = sy-langu

IMPORTING

user_line = satab-status.

MOVE satab-vbeln TO itab-vbeln.

MOVE satab-status TO itab-status.

MOVE satab-objnr TO itab-objnr.

APPEND itab.

CLEAR itab.

MODIFY satab.

ENDLOOP.

IF r_pgm EQ 'X' .

DELETE itab WHERE status NE 'CRTD' AND status NE 'NERE'

AND status NE 'PELC' .

ELSEIF r_pjmd EQ 'X' .

DELETE itab WHERE status NE 'GMAR'.

ELSEIF r_agm EQ 'X'.

DELETE itab WHERE status NE 'GMAR' AND status NE 'MDAR'.

ELSEIF r_ajmd EQ 'X'.

DELETE itab WHERE status NE 'MDAR'.

ELSEIF r_reje EQ 'X' .

DELETE itab WHERE status NE 'REJE'.

ENDIF.

DELETE ADJACENT DUPLICATES FROM itab COMPARING vbeln.

ENDFORM. " get_inv_no

&----


*& Form merge_fieldcatalog

&----


FORM merge_fieldcatalog.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = prg

i_inclname = prg

i_internal_tabname = 'ITAB'

CHANGING

ct_fieldcat = fieldcat.

ENDFORM. " merge_fieldcatalog

&----


*& Form set_fieldcat

&----


FORM set_fieldcat.

DATA: wa_fieldcat TYPE slis_fieldcat_alv .

LOOP AT fieldcat INTO wa_fieldcat.

CASE wa_fieldcat-fieldname .

WHEN 'VBELN'.

wa_fieldcat-seltext_s = 'Document No.' .

reward if useful..

Former Member
0 Kudos

Hi

1. add one more field checkbox of length 1 to ur final internal tabel

2. in ur fieldcatalg add this line

wa_fcat-fieldname = 'CHECKBOx'.

wa_fcat-checkbox = 'X'.

wa_fcat-outputlen = '1'.

wa_fcat-col_pos = '1'.

append wa_fcat to it_fcat.

3.in ur layout , add this line

wa_layout-box_fieldname = 'CHECKBOX'.

4.In th USER_COMMAND subroutine of ur REUSE_ALV_GRID_DISpLAy FM

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

case p_ucomm.

Data ref1 type ref to cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = ref1.

call method ref1->check_changed_data

when 'SAVE'.

  • write ur code her

.

<b>Reward fi usefull</b>

Former Member
0 Kudos

HI

<b>Use parameters</b>

is_layout = s_layout

<b>of function REUSE_ALV_LIST_DISPLAY

where</b>

*LAYOUT

CLEAR s_layout.

s_layout-box_fieldname = 'FLAG'.

s_layout-box_tabname = 'INTTAB'.

<b>and</b>

DATA : BEGIN OF inttab OCCURS 0,

flag(1),

...

end of inttab.

see the links

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

Simple ALV report

http://www.sapgenie.com/abap/controls/alvgrid.htm

http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

ALV

1. Please give me general info on ALV.

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

2. How do I program double click in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=11601

http://www.sapfans.com/forums/viewtopic.php?t=23010

3. How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm

4. How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

5. How to print page number / total number of pages X/XX in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

http://www.sapfans.com/forums/viewtopic.php?t=64320

http://www.sapfans.com/forums/viewtopic.php?t=44477

7. How can I set the cell color in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=52107

8. How do I print a logo/graphics in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=81149

http://www.sapfans.com/forums/viewtopic.php?t=35498

http://www.sapfans.com/forums/viewtopic.php?t=5013

9. How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

10. How can I use ALV for reports that are going to be run in background?

http://www.sapfans.com/forums/viewtopic.php?t=83243

http://www.sapfans.com/forums/viewtopic.php?t=19224

11. How can I display an icon in ALV? (Common requirement is traffic light icon).

http://www.sapfans.com/forums/viewtopic.php?t=79424

http://www.sapfans.com/forums/viewtopic.php?t=24512

12. How can I display a checkbox in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

13. Top-of-page in ALV

14. ALV Group Heading

http://www.sap-img.com/fu037.htm

How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

15. ALV output to PDF conversion

It has an example code for PDF Conversion.

http://www.erpgenie.com/abap/code/abap51.htm

Go thru these programs they may help u to try on some hands on

ALV Demo program

BCALV_DEMO_HTML

BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode

BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode

BCALV_GRID_DEMO Simple ALV Control Call Demo Program

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO

BC_ALV_DEMO_HTML_D0100

Regards

Pavan

Former Member
0 Kudos

Hi ram g,

1) in your alv table set a 1 char field.

2) set in your ALV layout structure this: layout-box_fieldname = 'NAME OF CHAR FIELD'.

3) enjoy

regs

rewards point for helpful

Former Member
0 Kudos

Hi Ram,

Go through this standard program you can apply the same logic BCALV_EDIT_05 .

(or)

****************************************************************************************************

Use parameters

Code:

is_layout = s_layout

of function REUSE_ALV_LIST_DISPLAY

where Code:

*LAYOUT

CLEAR s_layout.

s_layout-box_fieldname = 'FLAG'.

s_layout-box_tabname = 'INTTAB'.

and

Code:

DATA : BEGIN OF inttab OCCURS 0,

flag(1),

...

end of inttab.

(or)

****************************************************************************************************

just for the basic checkbox in each record of alv...

add one character fild in internal table

and then use this with field catlog ..here in this case my field name is checkbox so...

wa_fieldcat-fieldname = 'CHECKBOX'.

wa_fieldcat-tabname = 'IT_CONF'.

below mentioned field are imp.....

wa_fieldcat-checkbox = 'X'......to make it display as checkbox

wa_fieldcat-edit = 'X'......so u can tick or untick dem..

APPEND wa_fieldcat TO fieldcat.

clear wa_fieldcat.

Reward Points for the helpful.

Regards,

Harini.S

Former Member
0 Kudos

Dear Ram,

When building field catalog for ALV, set for the needed field

ls_fieldcat-icon = true.

ls_fieldcat-outputlen = 2.

Then, before calling 'REUSE_ALV...' stuff, modify your data: instead of 'X' put the relevant icon (for instance icon_okay - be sure to include type pools icon statement).

Regards,

Abir

***************************************

  • Don't forget to Reward Points *