Application Development and Automation 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: 
Read only

check box

Former Member
0 Likes
960

HI All,

How add a check box in the list for every record. and how do the coding for select check boxes.

Thanks&Regards.

Ramu.

7 REPLIES 7
Read only

Former Member
0 Likes
920

Hi,

While displaying the list we have to give like this

<b>write w_char as checkbox</b>.

w_char is character variable of length 1.

after that u can select checkboxes.

and in your code you have to write:

<b>if w_char = 'X'.

code.........

endif.</b>

Gothrough the following code segment. Just paste it in your abap editor.

And in your <b>pf-status</b> define 3 buttons

<b>SFLIGHT, SELECTALL, DESELECT</b>.

TABLES: spfli.

  • Select options.......................................................

"----


SELECTION-SCREEN BEGIN OF BLOCK schedule WITH FRAME TITLE schedule.

SELECT-OPTIONS:

s_carrid FOR spfli-carrid, " Carrier id

s_connid FOR spfli-connid. " Connection id

SELECTION-SCREEN END OF BLOCK schedule.

"----


  • Structure to hold Flight schedule information. *

"----


DATA:

BEGIN OF fs_schedule,

carrid TYPE spfli-carrid, " Carrier id

connid TYPE spfli-connid, " Connection id

airpfrom TYPE spfli-airpfrom, " Departure air port

airpto TYPE spfli-airpto, " Arrival air port

deptime TYPE spfli-deptime, " Departure time

arrtime TYPE spfli-arrtime, " Arrivel time

END OF fs_schedule.

"----


  • Structure to hold Flight information. *

"----


DATA:

BEGIN OF fs_flight,

carrid TYPE sflight-carrid, " Carrier id

connid TYPE sflight-connid, " Connection id

fldate TYPE sflight-fldate, " Flight date

seatsmax TYPE sflight-seatsmax, " Maximum seats

seatsocc TYPE sflight-seatsocc, " Occupied seats

END OF fs_flight.

"----


  • Internal table to hold schedule document information. *

"----


DATA:

t_schedule LIKE

STANDARD TABLE

OF fs_schedule.

"----


  • Internal table to hold schedule document item information. *

"----


DATA:

t_flight LIKE

STANDARD TABLE

OF fs_flight.

*" Data declarations...................................................

"----


  • Work variables *

"----


DATA:

w_checkbox TYPE c, " Checkbox

w_star TYPE c. " Asterisk

----


  • INITIALIZATION. *

----


INITIALIZATION.

PERFORM init.

----


  • START-OF-SELECTION. *

----


START-OF-SELECTION.

PERFORM selection.

----


  • END-OF-SELECTION. *

----


END-OF-SELECTION.

PERFORM output.

SET PF-STATUS 'DEMO'.

----


  • AT LINE-SELECTION. *

----


AT LINE-SELECTION.

IF sy-lsind EQ 1 AND sy-lilli GE 3.

IF fs_schedule-carrid NE ' '.

PERFORM read_and_display.

ELSE.

MESSAGE 'Select currect position'(003) TYPE 'W'.

ENDIF.

ELSE.

MESSAGE 'Select the appropriate line'(004) TYPE 'S'.

ENDIF. " IF sy-lsind EQ 1...........

----


  • AT USER COMMAND. *

----


AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'SFLIGHT'.

PERFORM read_display_flight_details.

WHEN 'SELECTALL'.

PERFORM select_flight_details.

WHEN 'DESELECT'.

PERFORM deselect_flight_details.

ENDCASE.

----


  • Form init *

----


  • This subroutine initializes titles to block schedule. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM init.

MOVE 'Flight schedule'(001) TO schedule.

ENDFORM. " Init

----


  • Form selection *

----


  • This subroutine retrive data from SFLIGHT. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM selection .

SELECT carrid " Carrier id

connid " Connection id

airpfrom " Departure air port

airpto " Arrival air port

deptime " Departure time

arrtime " Arrivel time

INTO TABLE t_schedule

FROM spfli

WHERE carrid IN s_carrid AND

connid IN s_connid.

IF sy-subrc NE 0.

WRITE 'No records found'(002).

ENDIF. " IF sy-subrc NE 0.

ENDFORM. " Selection

----


  • Form output *

----


  • This subroutine prints the output at basic list. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM output.

LOOP AT t_schedule INTO fs_schedule.

SKIP.

WRITE: /20 w_checkbox AS CHECKBOX,

fs_schedule-carrid,

fs_schedule-connid,

fs_schedule-airpfrom,

fs_schedule-airpto,

fs_schedule-deptime,

fs_schedule-arrtime,

w_star.

HIDE: fs_schedule-carrid,

fs_schedule-connid.

ENDLOOP. " LOOP AT t_schedule...

ENDFORM. " Output

----


  • Form read_and_display *

----


  • This subroutine prints the output in secondary list. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM read_and_display .

SELECT carrid " Carrier id

connid " Connection id

fldate " Flight date

seatsmax " Maximum seats

seatsocc " Occupied seats

FROM sflight

INTO TABLE t_flight

WHERE carrid EQ fs_schedule-carrid AND

connid EQ fs_schedule-connid.

IF sy-subrc EQ 0.

WRITE /3 sy-uline(65).

LOOP AT t_flight INTO fs_flight.

WRITE: /3 sy-vline, 6 fs_flight-carrid,

16 sy-vline, 18 fs_flight-connid,

28 sy-vline, 31 fs_flight-fldate,

41 sy-vline, 44 fs_flight-seatsmax,

54 sy-vline, 57 fs_flight-seatsmax,

67 sy-vline.

WRITE /3 sy-uline(65).

ENDLOOP. " LOOP AT t_flight...

ELSE.

WRITE 'No records found'(002).

ENDIF. " IF sy-subrc EQ 0.

CLEAR t_flight.

  • fs_schedule-carrid = ' '.

  • fs_schedule-connid = ' '.

ENDFORM. " Read_and_display

----


  • Form read_display_flight_details. *

----


  • This subroutine prints the output in secondary list. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM read_display_flight_details.

<b> DATA:

BEGIN OF fs_spfli,

carrid LIKE spfli-carrid, " Carrier id

connid LIKE spfli-connid, " Connection id

END OF fs_spfli.

DATA:

lt_spfli LIKE

STANDARD TABLE

OF fs_spfli.

DATA:

lw_lines TYPE i, " Number of lines

lw_lineno TYPE i VALUE 3, " Index

lw_count TYPE i. " Counter

DESCRIBE TABLE t_schedule LINES lw_lines.

DO lw_lines TIMES.

READ LINE lw_lineno

FIELD VALUE w_checkbox INTO w_checkbox

fs_schedule-carrid INTO fs_schedule-carrid

fs_schedule-connid INTO fs_schedule-connid .

IF sy-subrc EQ 0.

IF w_checkbox EQ 'X'.

ADD 1 TO lw_count.

CLEAR w_checkbox.

fs_spfli-carrid = fs_schedule-carrid.

fs_spfli-connid = fs_schedule-connid.

APPEND fs_spfli TO lt_spfli.

CLEAR fs_schedule.

ENDIF. " IF w_checkbox EQ 'X'.

ENDIF. " IF sy-subrc EQ 0.

ADD 1 TO lw_lineno.

ENDDO. " DO lw_lines TIMES.

IF lw_count EQ 0.

MESSAGE 'Select atleast one record'(005) TYPE 'I'.

ELSE.

SELECT carrid " Carrier id

connid " Connection id

fldate " Flight date

seatsmax " Maximum seats

seatsocc " Occupied seats

FROM sflight

INTO TABLE t_flight

FOR ALL ENTRIES

IN lt_spfli

WHERE carrid EQ lt_spfli-carrid

AND connid EQ lt_spfli-connid.

IF sy-subrc EQ 0.

WRITE /3 sy-uline(65).

LOOP AT t_flight INTO fs_flight.

WRITE: /3 sy-vline, 6 fs_flight-carrid,

16 sy-vline, 18 fs_flight-connid,

28 sy-vline, 31 fs_flight-fldate,

41 sy-vline, 44 fs_flight-seatsmax,

54 sy-vline, 57 fs_flight-seatsmax,

67 sy-vline.

WRITE /3 sy-uline(65).

ENDLOOP. " LOOP AT t_flight...

ELSE.

WRITE 'No records found'(002).

ENDIF. " IF sy-subrc EQ 0.

DESCRIBE TABLE t_schedule LINES lw_lines.

lw_lines = 2 * lw_lines + 2.

DO lw_lines TIMES.

READ LINE sy-index FIELD VALUE w_checkbox.

IF w_checkbox = 'X'.

w_checkbox = space.

w_star = '*'.

MODIFY LINE sy-index

FIELD VALUE w_checkbox

w_star

FIELD FORMAT w_checkbox INPUT OFF

COLOR 6 INVERSE ON.

ENDIF. " IF w_checkbox = 'X'.

ENDDO. " Do lw_lines times.

ENDIF. " IF lw_count EQ 0.</b>

ENDFORM. " Read_display_flight_details

----


  • Form select_flight_details . *

----


  • This subroutine select all entries. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM select_flight_details .

SY-LSIND = 0.

SET PF-STATUS 'DEMO' EXCLUDING 'SELECTALL' IMMEDIATELY.

DATA:

lw_lines TYPE i.

  • lw_lines = sy-linno.

DESCRIBE TABLE t_schedule LINES lw_lines.

lw_lines = 2 * lw_lines + 2.

DO lw_lines TIMES.

READ LINE sy-index FIELD VALUE w_checkbox w_star.

IF w_checkbox = space AND w_star NE '*'.

w_checkbox = 'X'.

MODIFY LINE sy-index

FIELD VALUE w_checkbox.

ENDIF. " IF w_checkbox = space...

ENDDO. " Do lw_lines times.

ENDFORM. " Select_flight_details

----


  • Form deselect_flight_details . *

----


  • This subroutine deselect all entries. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM deselect_flight_details .

SET PF-STATUS 'DEMO' EXCLUDING 'DESELECT' IMMEDIATELY.

DATA lw_lines TYPE i.

  • lw_lines = sy-linno.

DESCRIBE TABLE t_schedule LINES lw_lines.

lw_lines = 2 * lw_lines + 2.

DO lw_lines TIMES.

READ LINE sy-index FIELD VALUE w_checkbox.

IF w_checkbox = 'X'.

w_checkbox = space.

MODIFY LINE sy-index

FIELD VALUE w_checkbox.

ENDIF. " IF w_checkbox = 'X'.

ENDDO. " Do lw_lines times.

ENDFORM. " Deselect_flight_details

reward if it helps you.

Regards,

Sandhya

Read only

Former Member
0 Likes
920

Hi..just copy and paste this program which involves how to..work with check boxes...

REPORT YH642_030403 NO STANDARD PAGE HEADING MESSAGE-ID YH642_MSGS.

"----


  • Declaration of the structure to hold data that needs to be selected *

  • from database. *

"----


Data:

Begin of fs_spfli,

carrid type spfli-carrid, " Airline Code

connid type spfli-connid, " Flight Connection Code

airpfrom type spfli-airpfrom, " Departure Airport

airpto type spfli-airpto, " Destination Airport

deptime type spfli-deptime, " Departure Time

arrtime type spfli-arrtime, " Arrival Time

End of fs_spfli.

"----


  • Internal table to hold Flight Scedule data *

"----


Data:

t_spfli like standard table

of fs_spfli.

"----


  • Declaration of Structure to hold Flight Occupancy Data *

"----


*Data:

  • Begin of fs_sflight,

  • fldate type sflight-fldate, " Flight Date

  • seatsmax type sflight-seatsmax, " Maximum Seats

  • seatsocc type sflight-seatsocc, " Occupied Seats

  • End of fs_sflight.

"----


  • Internal table to hold Flight Occupancy data *

"----


Data:

t_sflight type

standard table

of sflight,

wa_sflight like line

of t_sflight.

*" Data declarations...................................................

"----


  • Work variables *

"----


data:

w_check type c, " Check box

w_char type c value space. " Stores *

"----


  • TOP-OF-PAGE *

"----


top-of-page.

perform list_header.

"----


  • START-OF-SELECTION *

"----


start-of-selection.

  • Reading Airline Schedule data

Perform read_schedule_data.

"----


  • END-OF-SELECTION *

"----


end-of-selection.

set pf-status 'PRINT'.

  • Generating List with Schedule of Flights

Perform print_schedule_data.

"----


  • AT USER-COMMAND *

"----


at user-command.

  • Providing Choice of Operations for User

case sy-ucomm.

when 'SFLIGHT'(001).

perform Print_Airfare_data.

when 'SELECTALL'(006).

perform select_all_checkboxes.

when 'DESELECTAL'(011).

perform deselect_all_checkboxes.

Endcase. " CASE SY-UCOMM

&----


*& FORM LIST_HEADER

&----


  • This subroutine prints list header.

----


  • There are no interface parameters to be passed to this subroutine. *

----


form list_header .

skip.

format color 1.

write:

/6 'CARRID',

14 'CONNID',

25 'FROM AIRPORT',

40 'TO AIRPORT',

55 'DEP TIME',

70 'ARR TIME'.

format color off.

perform draw_table in program yh642_020301

using 5 1 80 3 3 13 24 39 54 69 0 0 0 5.

endform. " list_header

&----


*& FORM READ_SCHEDULE_DATA

&----


  • This subroutine gets the required data from database

----


  • No parameters passing to this subroutine.

----


form read_schedule_data .

Select carrid " Airline Code

connid " Connection Id

airpfrom " Airport from

airpto " Arrival Airport

deptime " Departure time

arrtime " Arrival time

into table t_spfli

from spfli.

if sy-subrc eq 0.

endif. " ENDIF FOR SY-SUBRC

endform. " READ SCHEDULE DATA

&----


*& Form print_schedule_data

&----


  • This subroutine prints flight scheduled data.

----


  • No parameters passing to this subroutine.

----


form print_schedule_data .

data:

l_w_lines type i. " Number of lines

skip .

loop at t_spfli into fs_spfli.

write:

/ w_check as checkbox,

3 w_char,

6 fs_spfli-carrid,

15 fs_spfli-connid,

26 fs_spfli-airpfrom,

40 fs_spfli-airpto,

56 fs_spfli-deptime,

71 fs_spfli-arrtime.

Endloop.

describe table t_spfli lines l_w_lines.

add 10 to l_w_lines.

perform draw_table in program yh642_020301

using 5 1 80 l_w_lines 0 13 24 39 54 69 0 0 0 5.

endform. " PRINT SCHEDDULE DATA

&----


*& FORM PRINT AIRFARE DATA

&----


  • This Subroutine Prints airfare data for the record selected

----


  • No parameters passing to this subroutine.

----


form Print_Airfare_data .

"----


*Field String that holds the selected line contents. *

"----


Data:

Begin of lfs_spfli,

carrid type spfli-carrid, " Airline code

connid type spfli-connid, " Flight Connection number

End of lfs_spfli.

"----


  • Internal Table to hold the selected line contents. *

"----


Data:

ltkey_spfli like standard table

of lfs_spfli.

*" Data declarations...................................................

"----


  • Work variables *

"----


Data:

l_w_lines type i, " Total number of lines

l_w_lineno type i, " Line which is selected

l_w_count type i, " No.of check boxes

l_w_printl type i. " Number of lines to print.

set pf-status SPACE.

Describe table t_spfli lines l_w_lines.

l_w_lineno = l_w_lineno + 5.

Do l_w_lines times.

read line l_w_lineno

field value w_check into w_check

fs_spfli-carrid into fs_spfli-carrid

fs_spfli-connid into fs_spfli-connid.

If sy-subrc eq 0.

If w_check EQ 'X'.

add 1 to l_w_count.

clear w_check.

w_char = '*'.

modify current line field value w_char w_check

field format w_check input off.

  • line format color 3.

lfs_spfli-carrid = fs_spfli-carrid.

lfs_spfli-connid = fs_spfli-connid.

append lfs_spfli to ltkey_spfli.

clear w_char.

Endif. " IF W_CHECK EQ 'X'

Endif. " IF SY-SUBRC EQ 0

Add 1 to l_w_lineno.

Enddo. " DO W_LINES TIMES

If l_w_count eq 0.

message E007.

Else.

select * " GET SFLIGHT CONTENTS

from sflight

into table t_sflight

for all entries "

in ltkey_spfli

where carrid eq ltkey_spfli-carrid

and connid eq ltkey_spfli-connid.

if sy-subrc eq 0.

describe table t_sflight lines l_w_printl.

skip.

write:

/5 'Flight Date'(008),

20 'Maximum Seats'(012),

35 'Occupied Seats'(009).

skip.

loop at t_sflight into wa_sflight.

write:

/ wa_sflight-fldate under text-008,

wa_sflight-seatsmax under text-012,

wa_sflight-seatsocc under text-009.

endloop. " LOOP AT T_SFLIGHT

else.

Message E008.

Endif. " IF SY-SUBRC EQ 0

Endif. " IF W_COUNT EQ 0

add 5 to l_w_printl.

perform draw_table in program yh642_020301

using 4 1 55 l_w_printl 3 19 34 0 0 0 0 0 0 2.

endform. " PRINT AIRFARE_DATA

&----


*& FORM SELECT ALL CHECK BOXES

&----


  • This subroutines selects all the lines (Check boxes)

----


  • There are no interface parameters to be passed to this subroutine.*

----


form select_all_checkboxes .

Data:

lw_lines type i.

sy-lsind = 0.

Describe table t_spfli lines lw_lines.

lw_lines = lw_lines + 5.

Do lw_lines times.

If sy-index ge 5.

read line sy-index field value w_char into w_char.

if w_char eq '*'.

else.

w_check = 'X'(002).

modify line sy-index field value w_check.

endif.

Endif. " IF SY-INDEX GE 3

Enddo. " DO LW_LINES TIMES

endform. " SELECTS ALL CHECKBOXES

&----


*& FORM DESELECT ALL CHECK BOXES *

&----


  • This subroutine enables the user to deselect all the check boxes once*

----


*There are no interface parameters to be passed to this subroutine. *

----


form deselect_all_checkboxes .

Data:

lw_lines type i.

Describe table t_spfli lines lw_lines.

lw_lines = lw_lines + 8.

Do lw_lines times.

If sy-index ge 5.

read line sy-index field value w_check.

w_check = ' '.

modify line sy-index field value w_check.

Endif. " IF SY-INDEX GE 3

Enddo. " DO LW_LINES TIMES

endform. " DESELECT ALL CHECK BOXES

Read only

Former Member
0 Likes
920

Hi

try the following code........

*" Data Declaration..........................................

"----


DATA:

W_CHECK TYPE C , " Check Box

W_STAR TYPE C VALUE ''. " Star Variable

*" Declaration of Structures to hold Flight information.

"----


DATA:

BEGIN OF FS_SPFLI,

CARRID TYPE SPFLI-CARRID, " Carrier Id

CONNID TYPE SPFLI-CONNID, " Connection Id

AIRPFROM TYPE SPFLI-AIRPFROM, " Depatrure Airport

AIRPTO TYPE SPFLI-AIRPTO, " Destination Airport

DEPTIME TYPE SPFLI-DEPTIME, " Departure Time

ARRTIME TYPE SPFLI-ARRTIME, " Arrival Time

END OF FS_SPFLI.

*" Declaration of Structures to hold Flight information.

"----


DATA:

BEGIN OF FS_SSPFLI,

CARRID TYPE SPFLI-CARRID, " Carrier Id

CONNID TYPE SPFLI-CONNID, " Connection Id

END OF FS_SSPFLI.

*" Declaration of Structure to hold Seats Occupancy information

"----


DATA:

BEGIN OF FS_SFLIGHT,

FLDATE TYPE SFLIGHT-FLDATE, " Flight Date

SEATSMAX TYPE SFLIGHT-SEATSMAX," Maximum Seats

SEATSOCC TYPE SFLIGHT-SEATSOCC," Occupied Seats

END OF FS_SFLIGHT.

*" Tables Declaration to hold Flight information

"----


DATA:

T_SPFLI LIKE

STANDARD TABLE

OF FS_SPFLI.

*" Tables Declaration to hold Flight information

"----


DATA:

T_SSPFLI LIKE STANDARD TABLE OF FS_SPFLI.

*" Tables Declaration to hold Seats Occupancy information

"----


DATA:

T_SFLIGHT LIKE STANDARD TABLE OF FS_SFLIGHT.

*" START-OF-SELECTION EVENT..........................................

"----


START-OF-SELECTION.

PERFORM SELECT_SPFLI.

*" END-OF-SELECTION EVENT..........................................

"----


END-OF-SELECTION.

SET PF-STATUS 'FLIGHT'.

PERFORM DISPLAY_SPFLI.

*" AT USER-COMMAND EVENT..........................................

"----


AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'FLIGHT'.

PERFORM DISPLAY_SFLIGHT.

ENDCASE. " CASE SY-UCOMM..

----


  • Form SELECT_SPFLI

----


  • This subroutine selects the SPFLI details. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM SELECT_SPFLI .

SELECT CARRID " Carrier Id

CONNID " Connection Id

AIRPFROM " Depatrure Airport

AIRPTO " Destination Airport

DEPTIME " Departure Time

ARRTIME " Arrival Time

FROM SPFLI

INTO TABLE T_SPFLI.

IF SY-SUBRC NE 0.

MESSAGE ' NO DATA FOUND ' TYPE 'I'.

ENDIF. " IF SY-SUBRC EQ 0.

ENDFORM. " SELECT_SPFLI

----


  • Form DISPLAY_SPFLI

----


  • This subroutine displays the SPFLI details. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM DISPLAY_SPFLI .

WRITE:5'CarrID'(001),

15 'ConnID'(002),

30 'Des Airport'(003),

45 'Dept Airport'(004),

60 'Des Time'(005),

75 'Arr Time'(006).

SKIP.

LOOP AT T_SPFLI INTO FS_SPFLI.

WRITE:/ W_CHECK AS CHECKBOX.

WRITE:5 FS_SPFLI-CARRID,

15 FS_SPFLI-CONNID,

30 FS_SPFLI-AIRPFROM,

45 FS_SPFLI-AIRPTO,

60 FS_SPFLI-DEPTIME,

75 FS_SPFLI-ARRTIME.

WRITE:100 W_STAR.

ENDLOOP. " LOOP AT.....

ENDFORM. " DISPLAY_SPFLI

----


  • Form DISPLAY_SFLIGHT

----


  • This subroutine displays the SFLIGHT details. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM DISPLAY_SFLIGHT .

DATA:

LW_LINES TYPE I, " No OF Lines

LW_LINENO TYPE I, " Line Number

LW_COUNT TYPE I. " Counter

DESCRIBE TABLE T_SPFLI LINES LW_LINES.

LW_LINES = LW_LINES + 5.

DO LW_LINES TIMES.

READ LINE LW_LINENO

FIELD VALUE W_CHECK INTO W_CHECK

FS_SPFLI-CARRID INTO FS_SPFLI-CARRID

FS_SPFLI-CONNID INTO FS_SPFLI-CONNID.

IF W_CHECK EQ 'X'.

W_STAR = '*'.

MODIFY LINE LW_LINENO FIELD VALUE W_STAR.

MODIFY LINE LW_LINENO FIELD FORMAT W_CHECK INPUT OFF .

ADD 1 TO LW_COUNT.

FS_SSPFLI-CARRID = FS_SPFLI-CARRID.

FS_SSPFLI-CONNID = FS_SPFLI-CONNID.

APPEND FS_SSPFLI TO T_SSPFLI.

CLEAR T_SPFLI.

ENDIF. " IF W_CHECKBOX.....

ADD 1 TO LW_LINENO.

ENDDO. " DO LW_LINES....

IF LW_LINENO EQ 0.

MESSAGE ' NO RECORDS SELECTED' TYPE 'I'.

ENDIF. " IF LW_LINENO.....

SELECT FLDATE " Flight date

SEATSMAX " Maximum Seats

SEATSOCC " Seats occupied

FROM SFLIGHT

INTO TABLE T_SFLIGHT

FOR ALL ENTRIES IN T_SSPFLI

WHERE CARRID EQ T_SSPFLI-CARRID

AND CONNID EQ T_SSPFLI-CONNID.

IF SY-SUBRC NE 0.

MESSAGE ' NO DATA FOUND ' TYPE 'I'.

ENDIF. " IF SY-SUBRC EQ 0.

WRITE:/ 'Flight date '(007),20' Max seats'(008),40'Occ seats'(009).

SKIP.

LOOP AT T_SFLIGHT INTO FS_SFLIGHT.

WRITE:/ FS_SFLIGHT-FLDATE,

20 FS_SFLIGHT-SEATSMAX,

40 FS_SFLIGHT-SEATSOCC.

ENDLOOP. " LOOP AT......

ENDFORM. " DISPLAY_SFLIGHT

Reward all the Helpful answers

Read only

Former Member
0 Likes
920

in case u want to add check box to every row of an alv u need to write the following code in its catalog for every item

X_FIELDCAT-CHECKBOX = 'X'.

fg

X_FIELDCAT-FIELDNAME = 'CHK'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 1.

X_FIELDCAT-INPUT = 'X'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-CHECKBOX = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'VBELN'.

X_FIELDCAT-SELTEXT_L = 'VBELN'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 2.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'POSNR'.

X_FIELDCAT-SELTEXT_L = 'POSNR'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 3.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

now when ever u will chec it the internal table will have entry x corresponding to the check box

now loop at that internal table find where the checkbox field is x and play wth it

in short

1) after using CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

2) ur getting IT_FIELDCAT internal table.

3) they should one column in the internal table ( Data table :- JTAB )which ur using as check on the alv.

4) read the catlog IT_FIELDCAT with FIELDNAME = name of the column

5) modify the value of IT_FIELDCAT-CHECKBOX = 'X'.

6) Pass layout and enter the box field name that is column name

Read only

0 Likes
920

hi

now am getting the check box in the a;v out put. but how to do the coding for this.

means in the alv report i need to call transaction method on selected records.

on the application tool bar i need add one button to run the bdc with the selected records.

how select the all record by defalult.

Please help me.

Thanks in Advance .

Thanks &Regards.

Ramu.

Read only

Former Member
0 Likes
920

Hi,

gothrough the following code.

In alv pf-status define 2 buttons <b>SFLIGHT, SBOOK</b>

i.e, double click the pf-status <b>STANDARD</b> and define the buttons.

and paste the following code.

TABLES: SPFLI,SFLIGHT,SBOOK.

TYPE-POOLS:

SLIS.

DATA: BEGIN OF FS_SPFLI,

CHECK,

COLOUR(3).

INCLUDE STRUCTURE SPFLI.

DATA: END OF FS_SPFLI.

DATA: BEGIN OF FS_SFLIGHT,

CHECK,

COLOUR(3).

INCLUDE STRUCTURE SFLIGHT.

DATA: END OF FS_SFLIGHT.

DATA:

T_SPFLI LIKE

STANDARD TABLE

OF FS_SPFLI.

DATA:

T_SFLIGHT LIKE

STANDARD TABLE

OF FS_SFLIGHT.

DATA:

T_SBOOK LIKE

STANDARD TABLE

OF SBOOK.

DATA:

  • FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

  • FIELDCAT_LN LIKE LINE OF FIELDCAT,

FS_LAYOUT TYPE SLIS_LAYOUT_ALV.

START-OF-SELECTION.

SELECT *

FROM SPFLI

INTO CORRESPONDING FIELDS OF TABLE T_SPFLI.

FS_LAYOUT-BOX_FIELDNAME = 'CHECK'.

FS_LAYOUT-INFO_FIELDNAME = 'COLOUR'.

  • FS_LAYOUT-COLTAB_FIELDNAME = 'CELL'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_PF_STATUS_SET = 'SUB_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_STRUCTURE_NAME = 'SPFLI'

IS_LAYOUT = FS_LAYOUT

  • IT_FIELDCAT = FIELDCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = T_SPFLI

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

&----


*& Form SUB_PF_STATUS

&----


  • text

----


  • -->RT_EXTAB text

----


FORM SUB_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.

  • DATA: SOMETHING TYPE slis_extab.

  • SOMETHING-FCODE = '&ETA'.

  • APPEND SOMETHING TO RT_EXTAB.

SET PF-STATUS 'STANDARD' EXCLUDING 'SBOOK' IMMEDIATELY.

ENDFORM. "SUB_PF_STATUS

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->UCOMM text

  • -->SELFIELD text

----


FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM

SELFIELD TYPE SLIS_SELFIELD.

SELFIELD-REFRESH = 'X'.

*refresh t_sflight.

  • CASE UCOMM.

  • WHEN 'SFLIGHT'.

*

LOOP AT T_SPFLI INTO FS_SPFLI WHERE CHECK = 'X'.

FS_SPFLI-CHECK = '0'.

FS_SPFLI-COLOUR = 'C12'.

MODIFY T_SPFLI FROM FS_SPFLI TRANSPORTING COLOUR CHECK.

SELECT *

FROM SFLIGHT

APPENDING CORRESPONDING FIELDS OF TABLE T_SFLIGHT

WHERE CARRID = FS_SPFLI-CARRID

AND CONNID = FS_SPFLI-CONNID.

ENDLOOP.

PERFORM DISPLAY_SFLIGHT.

  • ENDCASE.

ENDFORM. "USER_COMMAND

&----


*& Form DISPLAY_SFLIGHT

&----


  • text

----


FORM DISPLAY_SFLIGHT.

FS_LAYOUT-BOX_FIELDNAME = 'CHECK'.

FS_LAYOUT-INFO_FIELDNAME = 'COLOUR'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_PF_STATUS_SET = 'FLIGHT'

I_CALLBACK_USER_COMMAND = 'SFLIGHT_COMMAND'

I_STRUCTURE_NAME = 'SFLIGHT'

IS_LAYOUT = FS_LAYOUT

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = T_SFLIGHT

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2 .

CLEAR T_SFLIGHT[].

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DISPLAY_SFLIGHT

&----


*& Form FLIGHT

&----


  • text

----


  • -->RT_EXTAB text

----


FORM FLIGHT USING RT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'STANDARD' EXCLUDING 'SFLIGHT' IMMEDIATELY.

ENDFORM. " FLIGHT

&----


*& Form SFLIGHT_COMMAND

&----


  • text

----


  • -->UCOMM text

  • -->SELFIELD text

----


FORM SFLIGHT_COMMAND USING UCOMM LIKE SY-UCOMM

SELFIELD TYPE SLIS_SELFIELD.

SELFIELD-REFRESH = 'X'.

*refresh t_sflight.

CASE UCOMM.

WHEN 'SBOOK'.

LOOP AT T_SFLIGHT INTO FS_SFLIGHT WHERE CHECK = 'X'.

FS_SFLIGHT-CHECK = '0'.

FS_SFLIGHT-COLOUR = 'C12'.

MODIFY T_SFLIGHT FROM FS_SFLIGHT TRANSPORTING COLOUR CHECK.

SELECT *

FROM SBOOK

APPENDING CORRESPONDING FIELDS OF TABLE T_SBOOK

WHERE CARRID = FS_SFLIGHT-CARRID

AND CONNID = FS_SFLIGHT-CONNID

AND FLDATE = FS_SFLIGHT-FLDATE.

ENDLOOP.

PERFORM DISPLAY_SBOOK.

ENDCASE.

ENDFORM. "USER_COMMAND

&----


*& Form DISPLAY_SBOOK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_SBOOK .

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_STRUCTURE_NAME = 'SBOOK'

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = T_SBOOK

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

CLEAR T_SBOOK.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DISPLAY_SBOOK

If u got the solution close this thread.

Reward if it helps you.........

Regards,

Sandhya

Read only

Former Member
0 Likes
920

Hi..

Try this code...

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE makt-matnr,

maktx LIKE makt-maktx,

c1,

END OF itab.

SELECT matnr maktx FROM makt INTO TABLE itab WHERE spras = 'EN'.

LOOP AT itab.

WRITE : / itab-c1 AS CHECKBOX hotspot on,itab-matnr,itab-maktx INPUT ON.

HIDE : itab-c1,itab-matnr.

ENDLOOP.

AT LINE-SELECTION.

DATA : d(60).

READ CURRENT LINE FIELD VALUE itab-c1.

IF sy-subrc EQ 0.

IF itab-c1 = 'X'.

WRITE : / 'SUCCESSFUL'.

ENDIF.

ENDIF.

Regards

Bala..