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: 

ALV with radiobutton and checkbox

Former Member
0 Kudos

hi to all,

can anyone tell me how to write the code.....i have written one ALV report useing likp, lips , mara ,vbak.

and i wanted to get another report in the same selection screen using with tables vbap,vbak,MARA,mbew.

finally my question in brief.....IN ONE SELETION SCREEN I WANT TO GET DIFFERENT REPORTS USING WITH CHECKBOXS AND RADIO BUTTONS IN ALV...tell me how....

raju..

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

I can't understand your question: you want to choose the report in the selection-screen or in ALV.

Max

16 REPLIES 16

Former Member
0 Kudos

Hi

I can't understand your question: you want to choose the report in the selection-screen or in ALV.

Max

0 Kudos

at selecion screen

for example in selection screen two different selecion boxs......if i choose one selecion box..i'll get report is different from the if i choose another selecion box...

Message was edited by: mpr raju

0 Kudos

Write 2 different ALV then, use the check-box to call one or the other.

0 Kudos

Hi

I think radiobutton is better than checkbox: you are sure user can make only one chosen

PARAMETERS: REP1 RADIOBUTTIN GROUP R1 USER-COMMAND REP.

REP2 RADIOBUTTIN GROUP R1.

AT SELECTION-SCREEN.

CHECK SY-UCOMM = 'REP'.

CASE 'X'.

WHEN REP1. REPORT = 'ZREPORT1'.

WHEN REP2. REPORT = 'ZREPORT2'.

ENDCASE.

SUBMIT (REPORT) VIA SELECTION-SCREEN AND RETURN.

Max

0 Kudos

SO I HAVE TWO DIFFERENT ALV REPORTS......IT IS NOT ACCEPTING ME TO WIRTE IS AS REPORT1 AND REPORT2

CAN U TELL ME ONCE AGAIN IN BREIF...HOW CAN I WRITE TO INSERT RADIOBUTTON IN BOTH...

0 Kudos

Hi

but do you want to run two report or two different ALV in the same report?

Max

0 Kudos

TWO DIFFERENT ALV IN the same report.....based on selecion (radio button or check box).

0 Kudos

What about this ?

I assume that you call a subroutine (FORM) in order to display your ALV (List or Grid). Just duplicate it and make required modifications.

PARAMETERS: REP1 RADIOBUTTIN GROUP R1 USER-COMMAND REP.

REP2 RADIOBUTTIN GROUP R1.

AT SELECTION-SCREEN.

CHECK SY-UCOMM = 'REP'.

CASE 'X'.

WHEN REP1. PERFORM alv1.

WHEN REP2. PERFORM alv2.

ENDCASE.

0 Kudos

U first write the code for a single ALV report with the option cb_1 = 'X'. Then do the same way in another perform with the data u want to display.

No need to write two report statements k?

Then u write as

IF cb_2 = 'X'.

Perform.....

ENDIF.

Hope u got it, i haev mentioned the same in the above reply.

0 Kudos

Hi

CASE 'X'.

WHEN REP1. PERFORM INIT_STRUCTURE_ALV USING 'ITAB1'.

WHEN REP2. PERFORM INIT_STRUCTURE_ALV USING 'ITAB2'.

ENDCASE.

FORM INIT_STRUCTURE_ALV USING INT_TABLE.

refrsh gt_fieldcat.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = gt_repid

i_structure_name = INT_TABLE

i_bypassing_buffer = 'X'

changing

ct_fieldcat = gt_fieldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

..........

ENDFORM.

Max

0 Kudos

IM NEW TO ABAP DONT BE ANGRY IM SLOWLY GETTING THE POINT...

I AM ATTACHED HERE MY TWO DIFFERENT ALV REPORTS ...JUST LOOK ON BOTH AND ADVICE ME ....PLEASE...

RAJU....

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$$$$$ ALV CUSTOMER DETAILS $$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

&----


*& Report ZMMGTB1 *

*& *

&----


*& CUSTOMER DETAILS IN ALV

*

*& *

&----


REPORT ZMMGTB1 .

TABLES: vbap, vbak, MARA, mbew.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


data : BEGIN OF itabVBAK occurs 0,

matnr type mara-matnr,

LBKUM type mbew-lbkum,

VTWEG type vbak-vtweg,

VKORG type vbak-vkorg,

KUNNR type vbak-kunnr,

AUART type vbak-auart,

AUDAT type vbap-audat,

NETPR type vbap-netpr,

ARKTX type vbap-arktx,

VBELN type vbap-vbeln,

VRKME type vbap-vrkme,

WAERK type vbap-waerk,

NETWR type vbap-netwr,

line_color(1) type c, "Used to store row color attributes

  • color_line(2) TYPE c, " Line color

  • color_cell TYPE lvc_t_scol, " Cell color

  • celltab type LVC_T_STYL,

end of itabvbak.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid,

gt_events type slis_t_event,

gd_prntparams type slis_print_alv.

**********************SELECTION SCEREEN*******************************

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

******************************************BLOCK 2*********************

SELECTION-SCREEN begin of block blk5 with frame title text-004.

********CHECK BOX******

*parameter: P_c2 as checkbox USER-COMMAND CHECK.

*data: cursorfield(20) type c.

*****************************************BLOCK 2 SUB******************

selection-screen begin of block 6 with frame title text-005.

select-options:

s_audat for vbap-audat no-extension, "Document Date.

s_kunn1 for vbak-kunnr no-extension ,

"DEFAULT '5525' .

s_LBKUM for mbew-lbkum no-extension no-display,

s_matnr for mara-matnr no-extension.

selection-screen end of block 6.

*****************************************BLOCK 2 SUB******************

selection-screen begin of block 7 with frame title text-006.

select-options:

s_auart for vbak-auart no-extension no intervals,

s_vtweg for vbak-vtweg no-extension no intervals ,

s_vkorg for vbak-vkorg no-extension no intervals,

s_netpr for vbap-netpr no-extension no intervals no-display.

selection-screen end of block 7.

SELECTION-SCREEN end of block blk5.

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

*********************************************************test********

    • color management.

DATA : wa_color TYPE lvc_s_scol.

  • Internal table for color management.

DATA : it_color TYPE TABLE OF lvc_s_scol.

  • itab for input enabling.

DATA: lt_celltab TYPE lvc_t_styl. "

***********************************************************endtest***

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform build_events.

perform build_print_params.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

DEFINE m_fieldcat.

add 1 to ls_fieldcat-col_pos.

ls_fieldcat-fieldname = &1.

ls_fieldcat-ref_tabname = &2.

append ls_fieldcat to lt_fieldcat.

END-OF-DEFINITION.

fieldcatalog-fieldname = 'VBELN'.

fieldcatalog-seltext_m = 'Sales Order'.

fieldcatalog-col_pos = 0.

  • fieldcatalog-outputlen = 10.

fieldcatalog-hotspot = 'X'.

  • fieldcatalog-emphasize = 'C500'.

fieldcatalog-key = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material'.

fieldcatalog-col_pos = 1.

  • fieldcatalog-emphasize = 'C401'.

fieldcatalog-hotspot = 'X'.

fieldcatalog-key = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'ARKTX'.

fieldcatalog-seltext_m = 'Material Group'.

fieldcatalog-col_pos = 2.

fieldcatalog-key = ' '.

  • fieldcatalog-emphasize = 'C110'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'VRKME'.

fieldcatalog-seltext_m = 'Delivery item'.

  • fieldcatalog-emphasize = 'C300'. "Column colur, Bold and Inverse off

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'WAERK'.

fieldcatalog-seltext_m = 'External material group'.

  • fieldcatalog-emphasize = 'C600'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AUDAT'.

fieldcatalog-seltext_m = 'Actual goods movement date'.

fieldcatalog-col_pos = 6.

  • fieldcatalog-emphasize = 'C500'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETWR'.

fieldcatalog-seltext_m = 'Networth'.

fieldcatalog-col_pos = 7.

  • fieldcatalog-emphasize = 'C400'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AUART'.

fieldcatalog-seltext_m = 'Sales Document Type'.

fieldcatalog-col_pos = 8.

fieldcatalog-key = ' '.

  • fieldcatalog-emphasize = 'C110'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'KUNNR'.

fieldcatalog-seltext_m = 'Customer'.

fieldcatalog-col_pos = 9.

fieldcatalog-key = ' '.

  • fieldcatalog-emphasize = 'C110'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

gd_layout-info_fieldname = 'LINE_COLOR'.

gd_layout-info_fieldname = 'WS_COLOR'.

gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

it_events = gt_events

is_print = gd_prntparams

i_save = 'X'

  • is_variant = z_template

tables

t_outtab = itabvbak

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.

endform. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form VBAK table and populate itab it_VBAK

----


form data_retrieval.

data: ld_color(1) type C.

select mara~matnr

MBEW~lbkum

VBAK~VTWEG

VBAK~VKORG

VBAK~KUNNR

VBAK~AUART

VBAP~AUDAT

VBAP~NETPR

VBAP~ARKTX

VBAP~VRKME

VBAP~WAERK

VBAP~NETWR

VBAP~vbeln

into corresponding fields of table itabvbak from VBAP

inner join VBAK

on VBAPvbeln = VBAKvbeln

inner join mara

on VBAPmatnr = maramatnr

inner join mbew

on VBAPmatnr = mbewmatnr

where VBAK~kunnr in s_kunn1

and VBAP~AUDAT in s_AUDAT

and MBEW~LBKUM in s_LBKUM

and MARA~MATNR in s_MATNR

and VBAK~AUART in s_AUART

and VBAK~VTWEG in s_VTWEG

and VBAK~VKORG in s_VKORG

and VBAP~NETPR in s_NETPR.

endform. " DATA_RETRIEVAL

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


Form top-of-page.

*ALV Header declarations

data: t_header type slis_t_listheader,

wa_header type slis_listheader,

t_line like wa_header-info,

ld_lines type i,

ld_linesc(10) type c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'Customer Details'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

  • Total No. of Records Selected

describe table itabvbak lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' ld_linesc

into t_line separated by space.

wa_header-typ = 'A'.

wa_header-info = t_line.

append wa_header to t_header.

clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

  • i_logo = 'Z_LOGO'.

endform.

----


  • FORM USER_COMMAND *

----


  • --> R_UCOMM *

  • --> RS_SELFIELD *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • Check function code

CASE r_ucomm.

WHEN '&IC1'.

  • Check field clicked on within ALVgrid report

IF rs_selfield-fieldname = 'VBELN'.

  • Read data table, using index of row user clicked on

READ TABLE itabvbak INTO itabvbak INDEX rs_selfield-tabindex.

  • with key VBELN = rs_selfield-value

  • Set parameter ID for transaction screen field

SET PARAMETER ID 'AUN' FIELD itabvbak-vbeln.

  • Sxecute transaction VL02N, and skip initial data entry screen

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

IF rs_selfield-fieldname = 'MATNR'.

READ TABLE itabvbak INTO itabvbak INDEX rs_selfield-tabindex.

  • Set parameter ID for transaction screen field

SET PARAMETER ID 'MAT' FIELD itabvbak-matnr.

CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM.

&----


*& Form BUILD_EVENTS

&----


  • Build events table

----


form build_events.

data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 1

importing

et_events = gt_events[].

read table gt_events with key name = slis_ev_end_of_page

into ls_event.

if sy-subrc = 0.

move 'END_OF_PAGE' to ls_event-form.

append ls_event to gt_events.

endif.

read table gt_events with key name = slis_ev_end_of_list

into ls_event.

if sy-subrc = 0.

move 'END_OF_LIST' to ls_event-form.

append ls_event to gt_events.

endif.

endform. " BUILD_EVENTS

&----


*& Form BUILD_PRINT_PARAMS

&----


  • Setup print parameters

----


form build_print_params.

gd_prntparams-reserve_lines = '9'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

endform. " BUILD_PRINT_PARAMS

&----


*& Form END_OF_PAGE

&----


form END_OF_PAGE.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

write: sy-uline(50).

skip.

write:/40 'Page:', sy-pagno .

endform.

&----


*& Form END_OF_LIST

&----


form END_OF_LIST.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

skip.

write:/40 'Page:', sy-pagno .

endform.

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$$$$$ ALV DELIVERY DETAILS $$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

REPORT ZMMGTB2 .

TABLES: likp, lips , mara ,vbak.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


data : BEGIN OF itabVBAK occurs 0,

matnr type mara-matnr,

matkl type mara-matkl,

vbeln type likp-vbeln,

netpr type lips-netpr,

posnr type lips-posnr,

shkzg type lips-shkzg,

extwg type mara-extwg,

mstae type mara-mstae,

mstav type mara-mstav,

lfdat type likp-lfdat,

lfart type likp-lfart,

kunnr type likp-kunnr,

wadat_ist type likp-wadat_ist,

ARKTX TYPE LIPS-ARKTX,

BISMT TYPE MARA-BISMT,

line_color(1) type c, "Used to store row color attributes

  • color_line(2) TYPE c, " Line color

  • color_cell TYPE lvc_t_scol, " Cell color

  • celltab type LVC_T_STYL,

end of itabvbak.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid,

gt_events type slis_t_event,

gd_prntparams type slis_print_alv.

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

SELECTION-SCREEN begin of block blk1 with frame title text-001.

*****************************************BLOCK 1 SUB******************

data: cursorfield(20) type c.

selection-screen begin of block 2 with frame title text-002.

screen-intensified = '1'.

select-options:

s_kunnr for likp-kunnr no-extension MODIF ID SC1 ,

"CUSTOMER DEFAULT '5525' .

s_matnr for mara-matnr no-extension.

selection-screen end of block 2.

*****************************************BLOCK 1 SUB******************

selection-screen begin of block 3 with frame title text-003.

select-options:

s_shkzg for lips-shkzg no-extension no intervals,

s_lfart for likp-lfart no-extension no intervals,

s_matkl for lips-matkl no-extension no intervals.

"delivery type.

selection-screen end of block 3.

SELECTION-SCREEN end of block blk1.

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

*********************************************************test********

    • color management.

DATA : wa_color TYPE lvc_s_scol.

  • Internal table for color management.

DATA : it_color TYPE TABLE OF lvc_s_scol.

  • itab for input enabling.

DATA: lt_celltab TYPE lvc_t_styl. "

***********************************************************endtest***

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform build_events.

perform build_print_params.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

DEFINE m_fieldcat.

add 1 to ls_fieldcat-col_pos.

ls_fieldcat-fieldname = &1.

ls_fieldcat-ref_tabname = &2.

append ls_fieldcat to lt_fieldcat.

END-OF-DEFINITION.

fieldcatalog-fieldname = 'VBELN'.

fieldcatalog-seltext_m = 'Sales Order'.

fieldcatalog-col_pos = 0.

  • fieldcatalog-outputlen = 10.

fieldcatalog-hotspot = 'X'.

  • fieldcatalog-emphasize = 'C500'.

fieldcatalog-key = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material'.

fieldcatalog-col_pos = 1.

  • fieldcatalog-emphasize = 'C401'.

fieldcatalog-hotspot = 'X'.

fieldcatalog-key = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATKL'.

fieldcatalog-seltext_m = 'Material Group'.

fieldcatalog-col_pos = 2.

fieldcatalog-key = ' '.

  • fieldcatalog-emphasize = 'C110'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'ARKTX'.

fieldcatalog-seltext_m = 'Short Text for Sales Order Item'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'POSNR'.

fieldcatalog-seltext_m = 'Delivery item'.

  • fieldcatalog-emphasize = 'C300'. "Column colur, Bold and Inverse off

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EXTWG'.

fieldcatalog-seltext_m = 'External material group'.

  • fieldcatalog-emphasize = 'C600'.

fieldcatalog-col_pos = 9.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'WADAT_IST'.

fieldcatalog-seltext_m = 'Actual goods movement date'.

fieldcatalog-col_pos = 6.

  • fieldcatalog-emphasize = 'C500'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'KUNNR'.

fieldcatalog-seltext_m = 'Customer'.

fieldcatalog-col_pos = 5.

  • fieldcatalog-emphasize = 'C400'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'SHKZG'.

fieldcatalog-seltext_m = 'Returns item'.

fieldcatalog-col_pos = 10.

  • fieldcatalog-emphasize = 'C700'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'LFDAT'.

fieldcatalog-seltext_m = 'Delivery Date'.

fieldcatalog-col_pos = 7.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'LFART'.

fieldcatalog-seltext_m = 'Delivery Type'.

fieldcatalog-col_pos = 8.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'BISMT'.

fieldcatalog-seltext_m = 'Old material number'.

fieldcatalog-col_pos = 11.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MSTAE'.

fieldcatalog-seltext_m = 'Cross-Plant Material Status'.

fieldcatalog-col_pos = 12.

  • fieldcatalog-outputlen = 15.

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MSTAV'.

fieldcatalog-seltext_m = 'Cross-distribution-chain material status'.

fieldcatalog-col_pos = 13.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 14.

fieldcatalog-do_sum = 'X'.

  • fieldcatalog-emphasize = 'C700'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

gd_layout-info_fieldname = 'LINE_COLOR'.

gd_layout-info_fieldname = 'WS_COLOR'.

gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

it_events = gt_events

is_print = gd_prntparams

i_save = 'X'

  • is_variant = z_template

tables

t_outtab = itabvbak

exceptions

program_error = 1

others = 2.

      • Layout

*types: begin of slis_print_alv0,

  • print(1) type c, " print to spool

  • prnt_title(1) type c, " moment to print the title

  • end of slis_print_alv0.

*

*types: begin of slis_layout_main,

  • dummy,

  • end of slis_layout_main.

*

*types: begin of slis_layout_alv_spec0,

  • no_colhead(1) type c, " no headings

  • no_hotspot(1) type c, " headings not as hotspot

  • zebra(1) type c, " striped pattern

  • no_vline(1) type c, " columns separated by space

  • no_hline(1) type c, "rows separated by space B20K8A0N5D

  • cell_merge(1) type c, " not suppress field replication

  • edit(1) type c, " for grid only

  • edit_mode(1) type c, " for grid only

  • numc_sum(1) type c, " totals for NUMC-Fields possib.

  • no_input(1) type c, " only display fields

  • f2code like sy-ucomm, "

  • reprep(1) type c, " report report interface active

  • no_keyfix(1) type c, " do not fix keycolumns

  • expand_all(1) type c, " Expand all positions

  • no_author(1) type c, " No standard authority check

    • colour

  • info_fieldname type slis_fieldname, " infofield for listoutput

  • coltab_fieldname type slis_fieldname. " colors

*.

*

**--- Structure for specific color settings

*types: begin of slis_specialcol_alv,

  • matnr type mara-matnr,

  • itabvbak type mara,

  • nokeycol(3) type c,

  • end of slis_specialcol_alv.

*types: slis_t_specialcol_alv type slis_specialcol_alv occurs 1.

***********************************************************endtest***

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_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form VBAK table and populate itab it_VBAK

----


form data_retrieval.

data: ld_color(1) type C.

select mara~matnr

mara~matkl

likp~vbeln

lips~netpr

lips~posnr

lips~shkzg

mara~extwg

mara~mstae

mara~mstav

likp~lfdat

likp~lfart

likp~kunnr

likp~wadat_ist

LIPS~ARKTX

mara~BISMT

into corresponding fields of table itabvbak from lips

inner join likp

on lipsvbeln = likpvbeln

inner join mara

on lipsmatnr = maramatnr

inner join mbew

on lipsmatnr = mbewmatnr

where likp~kunnr in s_kunnr

and mara~matnr in s_matnr

and lips~shkzg in s_shkzg

and likp~lfart in s_lfart

and lips~matkl in s_matkl.

loop at itabvbak.

**********************************************OLD ONE****COLOR***

*Populate color variable with colour properties

*Char 1 = C (This is a color property)

*Char 2 = 3 (Color codes: 1 - 7)

*Char 3 = Intensified on/off ( 1 or 0 )

*Char 4 = Inverse display on/off ( 1 or 0 )

  • i.e. wa_vbak-line_color = 'C410'

ld_color = ld_color + 1.

  • Only 7 colours so need to reset color value

if ld_color = 6.

ld_color = 1.

endif.

concatenate 'C' ld_color '10' into itabvbak-line_color.

  • concatenate '3' ld_color '1' into itabvbak-line_color.

*ENDIF.

ENDLOOP.

                              • modify it_vbak from wa_vbak.

*****************************************ENDOFOLD ONE****COLOR***

endform. " DATA_RETRIEVAL

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


Form top-of-page.

*ALV Header declarations

data: t_header type slis_t_listheader,

wa_header type slis_listheader,

t_line like wa_header-info,

ld_lines type i,

ld_linesc(10) type c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'Delivery Details'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

  • Total No. of Records Selected

describe table itabvbak lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' ld_linesc

into t_line separated by space.

wa_header-typ = 'A'.

wa_header-info = t_line.

append wa_header to t_header.

clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

  • i_logo = 'Z_LOGO'.

endform.

----


  • FORM USER_COMMAND *

----


  • --> R_UCOMM *

  • --> RS_SELFIELD *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • Check function code

CASE r_ucomm.

WHEN '&IC1'.

  • Check field clicked on within ALVgrid report

IF rs_selfield-fieldname = 'VBELN'.

  • Read data table, using index of row user clicked on

READ TABLE itabvbak INTO itabvbak INDEX rs_selfield-tabindex.

  • with key VBELN = rs_selfield-value

  • Set parameter ID for transaction screen field

SET PARAMETER ID 'VL' FIELD itabvbak-vbeln.

  • Sxecute transaction VL02N, and skip initial data entry screen

CALL TRANSACTION 'VL02N' AND SKIP FIRST SCREEN.

ENDIF.

IF rs_selfield-fieldname = 'MATNR'.

READ TABLE itabvbak INTO itabvbak INDEX rs_selfield-tabindex.

  • Set parameter ID for transaction screen field

SET PARAMETER ID 'MAT' FIELD itabvbak-matnr.

CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM.

&----


*& Form BUILD_EVENTS

&----


  • Build events table

----


form build_events.

data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 1

importing

et_events = gt_events[].

read table gt_events with key name = slis_ev_end_of_page

into ls_event.

if sy-subrc = 0.

move 'END_OF_PAGE' to ls_event-form.

append ls_event to gt_events.

endif.

read table gt_events with key name = slis_ev_end_of_list

into ls_event.

if sy-subrc = 0.

move 'END_OF_LIST' to ls_event-form.

append ls_event to gt_events.

endif.

endform. " BUILD_EVENTS

&----


*& Form BUILD_PRINT_PARAMS

&----


  • Setup print parameters

----


form build_print_params.

gd_prntparams-reserve_lines = '9'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

endform. " BUILD_PRINT_PARAMS

&----


*& Form END_OF_PAGE

&----


form END_OF_PAGE.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

write: sy-uline(50).

skip.

write:/40 'Page:', sy-pagno .

endform.

&----


*& Form END_OF_LIST

&----


form END_OF_LIST.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

skip.

write:/40 'Page:', sy-pagno .

endform.

0 Kudos

Hi

but i can't understand yet: you have two report and now do you want to have a chance to go from a selection-screen o to other selection-screen?

Max

0 Kudos

I WANT BOTH ARE IN ONE SELECTION SCREEN

0 Kudos

Well, then, there is nothing wrong with the solution Max gave you. Are you sure we agree on what a selection-screen is ??

PS : You should check your keyboard, I think the Caps Lock got stuck...

0 Kudos

selection-screen:begin of block1

give selection parameters for 1st report.

end of block1

select screen being of block2

give selection parameters of 2nd report.

end of block.

parameters:p_reg radiobutton group ropt,

p_spl radiobutton group ropt.

start of selection.

g_repid = sy-cprog.

if p_reg = 'X'.

perform get_report_data1.

elseif p_spl = 'X'.

perform get_report_data1.

endif.

perform comment_build using gt_list_top_of_page[].

perform comment_user_build using gt_list_top_of_page[].

internal_tablename = 'ITABREP'.

perform build_fieldcatalog using 'I' fieldcat[].

internal_tablename = 'ITABOFFER'.

perform build_fieldcatalog using 'I' fieldcat1[].

perform adjust_fieldcat using fieldcat[].

perform display_alv_itab.

form display_alv_itab.

g_repid = sy-cprog.

if p_reg = 'X'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • i_background_id = 'DAK'

i_callback_program = g_repid

i_callback_user_command = g_user_command

i_callback_top_of_page = g_top_of_page

it_fieldcat = fieldcat

is_layout = gs_layout

i_save = g_save

is_variant = gs_variant

it_events = gt_events

importing

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = gs_exit_caused_by_user

tables

t_outtab = itabrep

exceptions

program_error = 1

others = 2.

elseif p_spl = 'X'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • i_background_id = 'DAK'

i_callback_program = g_repid

i_callback_user_command = g_user_command

i_callback_top_of_page = g_top_of_page

it_fieldcat = fieldcat1

is_layout = gs_layout

i_save = g_save

is_variant = gs_variant

it_events = gt_events

importing

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = gs_exit_caused_by_user

tables

t_outtab = itaboffer

exceptions

program_error = 1

others = 2.

endif.

endform. " display_alv_itab

Former Member
0 Kudos

Hi,

U keep two check box or radiobuttons like


PARAMETERS: cb_1 AS CHECKBOX,
            cb_2 AS CHECKBOX.

Then u can use this and change the layout for the two different output screens in the same screen itself.

DO that like

IF cb_1 = 'X'.
  perform....
ENDIF.

IF cb_2 = 'X'.
  perform....
ENDIF.

No need for two screens in the same screen u can change the layout and pass the different output structure in the same screen depending upon the selection made.

Hope u got it.GEt back if not.