Choose fields option in Selection Screen of report program.
Hi Experts,
Actually In my requirement , the user wants to display the output fields in ALV Grid and also in Block ALV format.They need 10 fields to be displayed by default and the additional fields has to be displayed based on the choose fields option
( i.e like SE11 choose fields option ) provided in the selection screen of this report program.So based on this the output has to be displayed.
Pls suggest ur ideas.....
Thanks in advance.
Regards,
Srinivas.
Hi ,
The following code will be helpful for your requirement...
REPORT ypm_hist_dyn.
* T Y P E - P O O L S *
TYPE-POOLS: slis.
* T Y P E S *
TYPES : BEGIN OF t_equz,
datbi TYPE datbi, " Valid To Date
equnr TYPE equnr, " Equipment Number
erdat TYPE erdat, " Date on Which Record Was Created
aedat TYPE aedat, " Changed On
iloan TYPE iloan, " Location and account assignment for technical object
gewrk TYPE lgwid, " Object ID of the Work Center
ingrp TYPE ingrp, " Planner Group for Customer Service and Plant Maintenance
END OF t_equz,
BEGIN OF t_equz1,
datbi TYPE datbi, " Valid To Date
equnr TYPE equnr, " Equipment Number
erdat TYPE erdat, " Date on Which Record Was Created
aedat TYPE aedat, " Changed On
END OF t_equz1,
BEGIN OF t_iloa,
iloan TYPE iloan, "Location and account assignment for technical object
tplnr TYPE tplnr, " Functional Location
msgrp TYPE raumnr, " Room
END OF t_iloa,
BEGIN OF t_iflotx,
tplnr TYPE tplnr, "Functional Location
pltxt TYPE pltxt, " Description of functional location
END OF t_iflotx,
BEGIN OF t_equi,
equnr TYPE equnr, " Equipment Number
eqart TYPE eqart, "Type of Technical Object
END OF t_equi,
BEGIN OF t_crhd,
objid TYPE cr_objid, "Object ID of the resource
arbpl TYPE arbpl, "Work center
END OF t_crhd,
BEGIN OF t_eqkt,
equnr TYPE equnr, "Equipment Number
eqktx TYPE ktx01, "Description of technical object
END OF t_eqkt,
BEGIN OF t_t370k_t,
eqart TYPE eqart, "Type of Technical Object
eartx TYPE eartx, "Text for Object Type
END OF t_t370k_t,
BEGIN OF t_t024i,
ingrp TYPE ingrp, "Planner Group for Customer Service and Plant Maintenance
innam TYPE innam, "Name of the Maintenance Planner Group
END OF t_t024i,
BEGIN OF t_viqmel,
equnr TYPE equnr, "Equipment Number
qmnum TYPE qmnum, "Notification No
qmdat TYPE qmdat, "Date of Notification
bequi TYPE bequi, "Equipment Affected
iloan TYPE iloan, "Location and account assignment for technical object
END OF t_viqmel,
BEGIN OF t_final,
equnr TYPE equz-equnr,
eqktx TYPE eqkt-eqktx,
tplnr TYPE iloa-tplnr,
pltxt TYPE iflotx-pltxt,
iloan TYPE iloan,
datbi TYPE equz-datbi,
ingrp TYPE t024i-ingrp,
erdat TYPE equz-erdat,
enddt1 TYPE char10,
aedat TYPE equz-aedat,
innam TYPE t024i-innam,
equart TYPE equi-eqart,
eartx TYPE t370k_t-eartx,
qmnum TYPE viqmel-qmnum,
arbpl TYPE crhd-arbpl,
msgrp TYPE iloa-msgrp,
dat_diff TYPE char10,
END OF t_final,
BEGIN OF t_final1,
equnr TYPE equz-equnr,
eqktx TYPE eqkt-eqktx,
tplnr TYPE iloa-tplnr,
pltxt TYPE iflotx-pltxt,
END OF t_final1.
DATA: it_equz TYPE STANDARD TABLE OF t_equz,
it_iloa TYPE STANDARD TABLE OF t_iloa,
it_iflotx TYPE STANDARD TABLE OF t_iflotx,
it_equi TYPE STANDARD TABLE OF t_equi,
it_crhd TYPE STANDARD TABLE OF t_crhd,
it_eqkt TYPE STANDARD TABLE OF t_eqkt,
it_t370k_t TYPE STANDARD TABLE OF t_t370k_t,
it_t024i TYPE STANDARD TABLE OF t_t024i,
it_viqmel TYPE STANDARD TABLE OF t_viqmel,
it_final TYPE STANDARD TABLE OF t_final,
it_final1 TYPE STANDARD TABLE OF t_final1,
it_equz1 TYPE STANDARD TABLE OF t_equz1.
DATA: wa_equz TYPE t_equz,
wa_iloa TYPE t_iloa,
wa_iflotx TYPE t_iflotx,
wa_equi TYPE t_equi,
wa_crhd TYPE t_crhd,
wa_eqkt TYPE t_eqkt,
wa_t370k_t TYPE t_t370k_t,
wa_t024i TYPE t_t024i,
wa_viqmel TYPE t_viqmel,
wa_final TYPE t_final,
wa_final1 TYPE t_final1,
wa_equz1 TYPE t_equz.
DATA: t_equnr TYPE equz-equnr, "EQUZ-EQUNR
t_tplnr TYPE iloa-tplnr, "Functional Location
t_datbi TYPE equz-datbi, "Date
t_ingrp TYPE equz-ingrp, "Planner Group
t_eqart TYPE equi-eqart, "Technical Object
w_diff TYPE p,
w_time TYPE t.
* ALV DATA DECLARATION *
* Field Catalog
TYPES: BEGIN OF t_fldnam,
fld TYPE fieldname,
desc TYPE char30,
END OF t_fldnam.
DATA: is_layout TYPE slis_layout_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
is_fieldcat TYPE slis_fieldcat_alv,
it_fldnam TYPE STANDARD TABLE OF t_fldnam,
wa_fldnam TYPE t_fldnam,
it_sort TYPE STANDARD TABLE OF slis_t_sortinfo_alv,
wa_sort LIKE LINE OF it_sort.
DATA: i_events TYPE slis_t_event,
ls_line TYPE slis_listheader,
gt_list_top_of_page TYPE slis_t_listheader, "FOR TOP OF PAGE
gt_list_end_of_page TYPE slis_t_listheader. "FOR END OF PAGE
DATA : formname_top_of_page TYPE slis_formname VALUE
'GENERATE_TOP_OF_PAGE',
formname_end_of_page TYPE slis_formname VALUE
'GENERATE_END_OF_PAGE',
formname_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
* C O N S T A N T S *
*CONSTANTS: c_top TYPE slis_formname VALUE 'TOP_OF_PAGE',
* c_final(40) TYPE c VALUE 'IT_FINAL',
* c_detail(15) TYPE c VALUE 'IT_FINAL1'.
DATA : g_save(1) TYPE c,
g_exit(1) TYPE c,
g_variant LIKE disvariant,
gx_variant LIKE disvariant.
* S E L E C T I O N S C R E E N *
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_equnr FOR t_equnr,
s_tplnr FOR t_tplnr,
s_datbi FOR t_datbi ,
s_ingrp FOR t_ingrp,
s_eqart FOR t_eqart.
SELECTION-SCREEN: END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(16) text-007.
SELECTION-SCREEN POSITION 22.
PARAMETERS : 11_flds RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND g1.
SELECTION-SCREEN COMMENT 39(13) text-009.
SELECTION-SCREEN POSITION 54.
PARAMETERS : 6_flds RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN : END OF BLOCK blk2.
SELECTION-SCREEN:BEGIN OF BLOCK b2 WITH FRAME TITLE text-003.
PARAMETERS: alv_list RADIOBUTTON GROUP gp1 DEFAULT 'X'.
PARAMETERS: alv_grid RADIOBUTTON GROUP gp1.
SELECTION-SCREEN:END OF BLOCK b2.
SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-005.
PARAMETERS : p_vari LIKE disvariant-variant.
SELECTION-SCREEN: END OF BLOCK b3.
AT SELECTION-SCREEN.
PERFORM date_range.
IF s_datbi[] IS INITIAL.
MESSAGE e398(00) WITH 'ENTER A VALUE FOR DATE'(012).
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
START-OF-SELECTION.
IF 11_flds EQ 'X'.
PERFORM fill_equz.
PERFORM fill_iloa.
PERFORM fill_iflotx.
PERFORM fill_equi.
PERFORM fill_t370k_t.
PERFORM fill_t024i.
PERFORM fill_crhd.
PERFORM fill_eqkt.
PERFORM fill_viqmel.
ELSE.
PERFORM fill_equz.
PERFORM fill_iloa.
PERFORM fill_iflotx.
PERFORM haha_final.
PERFORM dyn_tab.
ENDIF.
PERFORM fill_final.
PERFORM get_day_diff.
* END-OF-SELECTION *
END-OF-SELECTION.
*Display Output in ALV Format
* PERFORM populate_layout.
PERFORM populate_fcat.
PERFORM populate_events .
* PERFORM gen_top.
PERFORM display_alv .
*& Form FILL_EQUZ
* text
* --> p1 text
* <-- p2 text
FORM fill_equz .
IF s_datbi-high IS INITIAL.
s_datbi-high = '99990701'.
ENDIF.
* IF s_datbi-LOW IS INITIAL.
* s_datbi-LOW = '20071201'.
* ENDIF.
SELECT datbi
equnr
erdat
aedat
iloan
gewrk
ingrp
FROM equz
INTO CORRESPONDING FIELDS OF TABLE it_equz
* WHERE datbi IN s_datbi AND equnr IN s_equnr.
WHERE equnr IN s_equnr
AND ingrp IN s_ingrp
AND datbi LE s_datbi-high
AND datbi GE s_datbi-low.
ENDFORM. " FILL_EQUZ
*& Form FILL_ILOA
* text
* --> p1 text
* <-- p2 text
FORM fill_iloa .
SELECT iloan
tplnr
msgrp
INTO CORRESPONDING FIELDS OF TABLE it_iloa
FROM iloa
FOR ALL ENTRIES IN it_equz
WHERE iloan = it_equz-iloan.
ENDFORM. " FILL_ILOA
*& Form FILL_IFLOTX
* text
* --> p1 text
* <-- p2 text
FORM fill_iflotx .
SELECT tplnr
pltxt
INTO CORRESPONDING FIELDS OF TABLE it_iflotx
FROM iflotx
FOR ALL ENTRIES IN it_iloa
WHERE tplnr = it_iloa-tplnr.
ENDFORM. " FILL_IFLOTX
*& Form FILL_EQUI
* text
* --> p1 text
* <-- p2 text
FORM fill_equi .
SELECT equnr
eqart
INTO CORRESPONDING FIELDS OF TABLE it_equi
FROM equi
FOR ALL ENTRIES IN it_equz
WHERE equnr = it_equz-equnr.
ENDFORM. " FILL_EQUI
*& Form FILL_T370K_T
* text
* --> p1 text
* <-- p2 text
FORM fill_t370k_t .
SELECT eqart
eartx
INTO CORRESPONDING FIELDS OF TABLE it_t370k_t
FROM t370k_t
FOR ALL ENTRIES IN it_equi
WHERE eqart = it_equi-eqart.
ENDFORM. " FILL_T370K_T
*& Form FILL_T024I
* text
* --> p1 text
* <-- p2 text
FORM fill_t024i .
SELECT ingrp
innam
INTO CORRESPONDING FIELDS OF TABLE it_t024i
FROM t024i
FOR ALL ENTRIES IN it_equz
WHERE ingrp = it_equz-ingrp.
ENDFORM. " FILL_T024I
*& Form FILL_CRHD
* text
* --> p1 text
* <-- p2 text
FORM fill_crhd .
SELECT objid
arbpl
INTO CORRESPONDING FIELDS OF TABLE it_crhd
FROM crhd
FOR ALL ENTRIES IN it_equz
WHERE objid = it_equz-gewrk.
ENDFORM. " FILL_CRHD
*& Form FILL_EQKT
* text
* --> p1 text
* <-- p2 text
FORM fill_eqkt .
SELECT equnr
eqktx
INTO CORRESPONDING FIELDS OF TABLE it_eqkt
FROM eqkt
FOR ALL ENTRIES IN it_equz
WHERE equnr = it_equz-equnr.
ENDFORM. " FILL_EQKT
*& Form FILL_VIQMEL
* text
* --> p1 text
* <-- p2 text
FORM fill_viqmel .
ENDFORM. " FILL_VIQMEL
*& Form SHW_DATA
* text
* --> p1 text
* <-- p2 text
FORM shw_data .
LOOP AT it_final1 INTO wa_final1.
WRITE : wa_final1-equnr , wa_final1-eqktx , wa_final1-tplnr , wa_final1-pltxt.
CLEAR wa_final1.
ENDLOOP.
ENDFORM. " SHW_DATA
*& Form POPULATE_LAYOUT
* text
* --> p1 text
* <-- p2 text
*FORM populate_layout .
* is_layout-zebra = 'X'.
* is_layout-colwidth_optimize = 'X'.
* APPEND is_layout.
*ENDFORM. " POPULATE_LAYOUT
*& Form POPULATE_FCAT
* text
* --> p1 text
* <-- p2 text
FORM populate_fcat .
IF 11_flds EQ 'X'.
APPEND 'EQUNR EQUIP NUMBER ' TO it_fldnam.
APPEND 'EQKTX DESC OF EQUIP ' TO it_fldnam.
APPEND 'ERDAT START DATE ' TO it_fldnam.
APPEND 'DATBI END DATE ' TO it_fldnam.
APPEND 'AEDAT CHND ON ' TO it_fldnam.
APPEND 'ILOAN LOC ON ACCOUNT ' TO it_fldnam.
APPEND 'TPLNR FUNC LOC ' TO it_fldnam.
APPEND 'PLTXT DESC FUNC LOC ' TO it_fldnam.
APPEND 'INGRP PLANNER GRP ' TO it_fldnam.
APPEND 'INNAM MAINT PLN GRP ' TO it_fldnam.
APPEND 'DAT_DIFF DATE DIFF ' TO it_fldnam.
ENDIF.
IF 6_flds EQ 'X'.
APPEND 'TPLNR FUNC LOCATION ' TO it_fldnam.
APPEND 'PLTXT DESC OF FUC LOC ' TO it_fldnam.
APPEND 'DATBI END DATE ' TO it_fldnam.
APPEND 'EQUNR EQUIP NUMBER ' TO it_fldnam.
APPEND 'ERDAT START DATE ' TO it_fldnam.
APPEND 'AEDAT CHND ON ' TO it_fldnam.
ENDIF.
ENDFORM. " POPULATE_FCAT
*& Form DISPLAY_ALV
* text
* --> p1 text
* <-- p2 text
FORM display_alv .
*--------------------------------------------------Preparing the Layout*
is_layout-colwidth_optimize = 'X'.
is_layout-zebra = 'X'.
*-------------------------------------------Preparing the Field Catalog*
BREAK-POINT.
LOOP AT it_fldnam INTO wa_fldnam.
is_fieldcat-tabname = 'IT_FINAL'.
is_fieldcat-fieldname = wa_fldnam-fld.
is_fieldcat-seltext_l = wa_fldnam-desc.
is_fieldcat-col_pos = sy-tabix.
IF wa_fldnam-fld = 'EQKTX'.
is_fieldcat-lowercase = ' '.
ENDIF.
APPEND is_fieldcat TO it_fieldcat.
CLEAR : is_fieldcat, wa_fldnam.
ENDLOOP.
*-------------------------------------------------------Calling Display*
IF alv_list = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = is_layout
it_fieldcat = it_fieldcat
it_events = i_events[]
i_default = 'X'
TABLES
t_outtab = it_final
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.
ELSE.
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* i_callback_program = sy-repid
* i_callback_top_of_page = 'GEN_TOP'
* is_layout = is_layout
* it_fieldcat = it_fieldcat
* it_events = i_events[]
* i_save = g_save
* is_variant = g_variant
* i_default = 'A'
* TABLES
* t_outtab = it_final
* 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.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'GEN_TOP'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
is_layout = is_layout
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
i_save = 'A'
* IS_VARIANT = g_variant
* IT_EVENTS = i_events[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 20
* I_SCREEN_START_LINE = 30
* I_SCREEN_END_COLUMN = 100
* I_SCREEN_END_LINE = 40
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_final
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.
ENDIF.
ENDFORM. " DISPLAY_ALV
*& Form GET_DAY_DIFF
* text
* --> p1 text
* <-- p2 text
FORM get_day_diff .
w_time = '00:00:00'.
FIELD-SYMBOLS: <deb> LIKE LINE OF it_final.
LOOP AT it_final ASSIGNING <deb>.
CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
EXPORTING
date1 = <deb>-datbi
time1 = w_time
date2 = <deb>-erdat
time2 = w_time
IMPORTING
datediff = w_diff
* TIMEDIFF =
* EARLIEST =
* EXCEPTIONS
* INVALID_DATETIME = 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.
ELSEIF sy-subrc = 0.
<deb>-dat_diff = w_diff.
* MODIFY it_final FROM WA_FINAL TRANSPORTING dat_diff.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DAY_DIFF
*& Form HAHA_FINAL
* text
* --> p1 text
* <-- p2 text
FORM haha_final .
* FIELD-SYMBOLS: <deb> LIKE LINE OF it_final.
LOOP AT it_iflotx INTO wa_iflotx.
* wa_final1-equnr = wa_iflotx-equnr.
* wa_final1-eqktx = wa_iflotx-eqktx.
wa_final1-tplnr = wa_iflotx-tplnr.
wa_final1-pltxt = wa_iflotx-pltxt.
APPEND wa_final1 TO it_final1.
ENDLOOP.
ENDFORM. " HAHA_FINAL
*& Form DYN_TAB
* text
* --> p1 text
* <-- p2 text
FORM dyn_tab .
LOOP AT it_equz INTO wa_equz.
wa_equz1-datbi = wa_equz-datbi.
wa_equz1-equnr = wa_equz-equnr.
wa_equz1-erdat = wa_equz-erdat.
wa_equz1-aedat = wa_equz-aedat.
APPEND wa_equz1 TO it_equz1.
ENDLOOP.
ENDFORM. " DYN_TAB
*& Form FILL_FINAL1
* text
* --> p1 text
* <-- p2 text
FORM fill_final.
IF 11_flds EQ 'X'.
FIELD-SYMBOLS: <deb> LIKE LINE OF it_equz,
<deb1> LIKE LINE OF it_final.
CLEAR wa_equz.
REFRESH : it_final[].
LOOP AT it_equz ASSIGNING <deb>.
wa_final-equnr = <deb>-equnr.
wa_final-datbi = <deb>-datbi.
wa_final-erdat = <deb>-erdat.
wa_final-aedat = <deb>-aedat.
wa_final-iloan = <deb>-iloan.
wa_final-ingrp = <deb>-ingrp.
APPEND wa_final TO it_final.
CLEAR wa_final.
ENDLOOP.
LOOP AT it_final ASSIGNING <deb1>.
READ TABLE it_iloa INTO wa_iloa WITH KEY iloan = <deb1>-iloan.
<deb1>-tplnr = wa_iloa-tplnr.
ENDLOOP.
LOOP AT it_final ASSIGNING <deb1>.
READ TABLE it_iflotx INTO wa_iflotx WITH KEY tplnr = <deb1>-tplnr.
<deb1>-pltxt = wa_iflotx-pltxt.
ENDLOOP.
LOOP AT it_final ASSIGNING <deb1>.
READ TABLE it_eqkt INTO wa_eqkt WITH KEY equnr = <deb1>-equnr.
<deb1>-eqktx = wa_eqkt-eqktx.
ENDLOOP.
LOOP AT it_final ASSIGNING <deb1>.
READ TABLE it_t024i INTO wa_t024i WITH KEY ingrp = <deb1>-ingrp.
<deb1>-innam = wa_t024i-innam.
ENDLOOP.
ELSE.
REFRESH : it_final[].
LOOP AT it_equz INTO wa_equz.
wa_final-datbi = wa_equz-datbi.
wa_final-equnr = wa_equz-equnr.
wa_final-erdat = wa_equz-erdat.
wa_final-aedat = wa_equz-aedat.
wa_final-iloan = wa_equz-iloan.
APPEND wa_final TO it_final.
CLEAR wa_final.
ENDLOOP.
FIELD-SYMBOLS: <deb2> LIKE LINE OF it_final.
LOOP AT it_final ASSIGNING <deb2>.
READ TABLE it_iloa INTO wa_iloa WITH KEY iloan = <deb2>-iloan.
<deb2>-tplnr = wa_iloa-tplnr.
ENDLOOP.
LOOP AT it_final ASSIGNING <deb2>.
READ TABLE it_iflotx INTO wa_iflotx WITH KEY tplnr = <deb2>-tplnr.
<deb2>-pltxt = wa_iflotx-pltxt.
ENDLOOP.
ENDIF.
ENDFORM. " FILL_FINAL
*& Form DATE_RANGE
* text
* --> p1 text
* <-- p2 text
FORM date_range .
DATA :l_dat TYPE i.
IF s_datbi-high IS NOT INITIAL.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = s_datbi-high
i_datum_von = s_datbi-low
IMPORTING
e_tage = l_dat
EXCEPTIONS
days_method_not_defined = 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.
IF l_dat GT '31'.
MESSAGE e398(00) WITH 'Split Your Planning for a range of 31 Days'(012).
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ENDFORM. " DATE_RANGE
*& Form GEN_TOP
* text
* --> p1 text
* <-- p2 text
FORM gen_top .
DATA: info(60),
w_dt TYPE d.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = 'ALV DISPLAY'.
APPEND ls_line TO gt_list_top_of_page.
CONCATENATE 'Date :' s_datbi-low ' TO ' s_datbi-high INTO info SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-info = info.
APPEND ls_line TO gt_list_top_of_page.
CLEAR ls_line.
ls_line-typ = 'A'.
ls_line-info = 'By Debarshi Roy'.
APPEND ls_line TO gt_list_top_of_page.
* Generate the End of Page
* CLEAR ls_line.
* ls_line-typ = 'H'.
* ls_line-info = 'ECL'.
* APPEND ls_line TO gt_list_end_of_page.
CLEAR: ls_line.
* PERFORM generate_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_list_top_of_page
i_logo = 'DEB'.
ENDFORM. " GEN_TOP
*& Form POPULATE_EVENTS
* text
* --> p1 text
* <-- p2 text
FORM populate_events .
DATA: l_i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events[].
*----- Pass top-of-page
READ TABLE i_events WITH KEY name = slis_ev_top_of_page
INTO l_i_event.
IF sy-subrc = 0.
MOVE formname_top_of_page TO l_i_event-form.
APPEND l_i_event TO i_events.
ENDIF.
CLEAR l_i_event.
*----- Pass end-of-page
READ TABLE i_events WITH KEY name = slis_ev_end_of_page
INTO l_i_event.
IF sy-subrc = 0.
MOVE formname_end_of_page TO l_i_event-form.
APPEND l_i_event TO i_events.
ENDIF.
CLEAR l_i_event.
*----- Pass user-command
READ TABLE i_events WITH KEY name = slis_ev_user_command
INTO l_i_event.
IF sy-subrc = 0.
MOVE formname_user_command TO l_i_event-form.
APPEND l_i_event TO i_events.
ENDIF.
ENDFORM. " POPULATE_EVENTS
*& Form generate_top_of_page
* text
*FORM generate_top_of_page.
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* it_list_commentary = gt_list_top_of_page
* i_logo = 'DEB'.
*ENDFORM. "generate_top_of_page
*& Form generate_end_of_page
* text
FORM generate_end_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_list_end_of_page
* I_LOGO =
ENDFORM. "generate_end_of_page
*& Form F4_FOR_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM f4_for_variant .
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " F4_FOR_VARIANT
Similar Messages
-
REPORT PAINTER - Add a field to a selection screen - custom report
Hi,
I'm trying to add a field to a selection screen to a CUSTOM REPORT that has been made in REPORT PAINTER (Y_DVL_xxxxxxx). How should I proceed to do so?
Thanks a lot,
JulienHi Julien Girard ,
Could you please check the below link :
http://help.sap.com/saphelp_erp2005/helpdata/en/56/32e339b62b3011e10000000a11402f/frameset.htm
Regards,
S.Manu. -
User must fill at list one field in a selection screen in report
Hi experts,
i have a report that the user should choose between 2 fields or he can fill them both. but he must to fill at list one of them- at the selection screen.
how do i check that the user filled at list one of them.
any help will be appreciate it.
dana.Hi ,
You can check that in AT SELECTION-SCREEN event.
To validate that in the IF condition check whether any one of the parameters
filled or not.If both the fields are initial then give a error message to proceed further.
Check the code -
PARAMETERS : p_name(20) TYPE c,
p_id(10) TYPE c.
AT SELECTION-SCREEN.
IF p_name IS INITIAL AND p_id IS INITIAL .
MESSAGE 'Enter at least one field' TYPE 'E'.
ENDIF.
START-OF-SELECTION.
WRITE 'Test'.
Regards
Pinaki -
User option in selection screen of report
In a report, want to give user an initial option of Calendar year/month OR calendar year/week...
Only the one the user wants should be displayed on the selection screen.
1 Is there a way to give user an option while running the query before the selection screen(variables - uesr input) of the report appears
OR
2 Is there a way to give user a toggle option on the selection screen which displays either calendar year/month or calendar year/week based on user choice but not both.
I am aware that user can easily toggle once the report has been executed, but the purpose is to give user this option initially.
As of now, in the report at the selection screen there are four periods based on calendar year/month. (to facilitate comparison of periods)
eg (m- cal year/month, w - cal year/week)
P1(m)
P2(m)
P3(m)
P4(m)
If we add four more for week
then user will have a cluttered selection screen (as there are many other selection options apart from time)
eg 8 time choices
P1(m)
P2(m)
P3(m)
P4(m)
P1(w)
P2(w)
P3(w)
P4(w)
What I need is a way for at any time, either cal year/month or cal year/week is visible based on user choice.In a report, want to give user an initial option of Calendar year/month OR calendar year/week...
Only the one the user wants should be displayed on the selection screen.
1 Is there a way to give user an option while running the query before the selection screen(variables - uesr input) of the report appears
OR
2 Is there a way to give user a toggle option on the selection screen which displays either calendar year/month or calendar year/week based on user choice but not both.
I am aware that user can easily toggle once the report has been executed, but the purpose is to give user this option initially.
As of now, in the report at the selection screen there are four periods based on calendar year/month. (to facilitate comparison of periods)
eg (m- cal year/month, w - cal year/week)
P1(m)
P2(m)
P3(m)
P4(m)
If we add four more for week
then user will have a cluttered selection screen (as there are many other selection options apart from time)
eg 8 time choices
P1(m)
P2(m)
P3(m)
P4(m)
P1(w)
P2(w)
P3(w)
P4(w)
What I need is a way for at any time, either cal year/month or cal year/week is visible based on user choice. -
How to generage pop up screen on selection screen of report program?
Hi Guys,
I am having a requirement to generate the <b>pop up screen on the selection screen</b> of the report program.
Suggest me the best one with model programHi Chakradhar,
Refer this code :
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME TITLE TEXT-456.
PARAMETERS PO RADIOBUTTON GROUP RADI USER-COMMAND R.
SELECTION-SCREEN END OF BLOCK BL2.
AT SELECTION-SCREEN OUTPUT.
CALL SCREEN 100.
when user will click on this radio button , a pop up screen will appear dynamically.
Reward points if helpful.
Regards,
Hemant -
Layout Option on Selection Screen For Zreport
Hi All,
Plz explain how to do coding for using Layout option on selection screen of
report. Also i should be able to save and create new layout on selection screen.
Thnaks in advance.
Aniket Dayamahi,
creation of sub-screens.
selection-screen begin of tabbed block <name of the tab> for < height of the tab in no's> lines.
eg;
selection-screen tab(20) l1 <data element> user-comand <name of the funcion code>
selection-screen end of block <name of the tab strip>.
eg;
selection-screen begin of tabbed block mytab for 10 lines.
selection-screen tab(20) l1 user-command tab1.
selection-screen tab (20) l2 user-command tab2..
selection-screen end of block mytab.
Under initialization.
data element = text-01.
data element = text=02.
How to initialize the tab with default screen.
<name of the tab> - prog = sy-repid.
<name of the tab>- dynnr = '<subscreen no>'.
<nane of the tab>-activetab = '<user-command for the strip>
if this has solved ur problem then dont forget to reward with points.
with regards,
madhuri. -
Functional area(FKBER field in the selection screen of the report painter))
Hi,
I have a requirement to add functional area field in the selection screen for a report painter report. This report using library 1VK and table 'CCSS'. I added functional area field in the general data selection . After the execution of report with functional area field filled with value. report not giving any output. do i need to maintain any setting to achieve?
Regards,
Palani1. Call GR22 and click "Characteristics".
2. Check FKBER and assign a position number to it.
3. Save and close the library.
4. Call your report in GRR2 and you should now see FKBER as an available characteristic.
5. Use it in the General Data Selection or as a Lead Column, as per requirement.
Or,
1. Call GR21 and create a custom library. Provide a name and description and also provide a library you can copy from (scan for the best-fit library).
2. Now follow the steps 2 through 5 above to achieve your result.
Hope this helps.
Cheers. -
Field in the selection screen as a select option with two default values
Hi All,
can anybody tell me how to put field in the selection screen with two defaul values.
for ex: selection screen the Account Group KNA1-KTOKD as a select option. The defeault value should be Y001 and Y005.
please reply ASAP. Its urgent.
Thanks in advance,
MadhuHi Madhu,
Since Select options are nothing but ranges, you can use the following code to add two distinct values to the select options by default.
s_ktokd-sign = 'I'.
s_ktokd-option = 'EQ'.
s_ktokd-low = 'Y001'.
append s_ktokd.
s_ktokd-low = 'Y005'.
append s_ktokd.
clear s_ktokd.
However, if you want to mention a range like all the values between these given two values to be considered then u may use,
select-options : s_ktokd for KNA1-KTOKD default 'Y001' to 'Y005'.
or
s_ktokd-sign = 'I'.
s_ktokd-option = 'BT'.
s_ktokd-low = 'Y001'.
s_ktokd-high = 'Y005'.
append s_ktokd.
Reward if helpful. -
PS:Copy of MBBS report with Date(GR) selection option in selection screen.
Hi,
We are developing a report, which is Copy of MBBS report, addition as Date(GR) selection option in selection screen to view historical data {i.e.Project Stock(Q) on back dates}.
MBBS is showing Project Stock w.r.t. WBS. So pls suggest Table, which can fulfill the requirement to show the Project Stock from GR w.r.t. Purchase and Production order in back date w.r.t. that WBS.
Pls do the needful.
Thanks,
Amit Jain.Hi Amit ,
The Project Stock Table is MSPR , and the Project stock history table is MSPRH .
Though not through with your actual requirement , There is a standard Report MB5B -- Stock on Posting Date . In the selection screen , we can have the Special Stock Q (Project Stock ) .
If you can develop copying this report instead of MBBS , it would take care of receipts as well as issues ,and from the material Document you can build a relation to the account assignment WBS/Network Activity through MSEG Table .
Hope it helps .
thanks and regards
Kish -
REPORT PAINTER - Add a field to a selection screen to a CUSTOM REPORT
Hi,
I'm trying to add a field to a selection screen to a CUSTOM REPORT that has been made in REPORT PAINTER (Y_DVL_xxxxxxx). How should I proceed to do so?
Thanks a lot,
JulienHi Julien Girard ,
Could you please check the below link :
http://help.sap.com/saphelp_erp2005/helpdata/en/56/32e339b62b3011e10000000a11402f/frameset.htm
Regards,
S.Manu. -
How to validate a select-option field on the selection- screen
Hi,
I need to validate a selection-option field in the selection-screen.
Requirement is : i need to read each of customer number one by one and validateCan you please me in achieving this.
Best Regards
Mamatha.Bhi,
chk this sample code.
SELECT-OPTIONS : s_kunnr for kna1-kunnr.
AT SELECTION-SCREEN.
if 'S_KUNNR-HIGH' = "condition
"put your required validation here
endif.
rgds
Anver
Message was edited by:
Anversha s -
How to Modify the Selection Screen in Report Painter
Hi All,
I am working on Report painter and writer,
can any body helpme how to change the selection screen i.e i want add some more select options to the exisiting roport .
how can i add more select options to the exisiting one
please let me know the Procedure and provide some relevent documents .
Thanks and Best regards.
umaHello...
In the program ...we can find the following chunk of code..
selection-screen:begin of block B1 with frame title text-001.
Parameters : ....
select-options:.....
selection-screen:end of block b1.
if we need to add any more user inputs we can write the code inside the existing
selection screen....end of block .
or create a new block ..just the block name should be different...
if we are using select options...we need to declare the table name using the key word for the field on which we are giving select options ....
Tables : BSIK.
Please see the following code:
Imagine :- we have the current selection screen..
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_BUKRS LIKE BSIK-BUKRS DEFAULT SPACE.
SELECT-OPTIONS: S_LIFNR FOR BSIK-LIFNR.
SELECTION-SCREEN END OF BLOCK B1.
we need to add 2 more fields on the selection screen ..this we can do as the following
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_BUKRS LIKE BSIK-BUKRS DEFAULT SPACE.
SELECT-OPTIONS: S_LIFNR FOR BSIK-LIFNR,
S_HKONT FOR BSIK-HKONT.
PARAMETER: P_DATE LIKE BSIK-BUDAT OBLIGATORY DEFAULT
SY-DATUM.
SELECTION-SCREEN END OF BLOCK B1.
OR...create a new block...
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: S_HKONT FOR BSIK-HKONT.
PARAMETER: P_DATE LIKE RFPDO-ALLGSTID OBLIGATORY DEFAULT
SY-DATUM.
SELECTION-SCREEN END OF BLOCK B2.
there are many options available in selection screens..like creating check box,radio button etc..
for more info press F1 help on the Selection screen in the ABAP editor
Revert back if not clear and reward if helpful
Regards
Byju -
Adding field in the selection-screen of a zprogram
hi gurus,
i have to add field in the selection-screen of oppurtunities. in database i have a field salesvalues, some of oppurtunity guids have this field value. first i need to add in selection-screen in this alv report. and fetch the data from ztable into required field . if the input fields of the salesvalues field id filled, then filter the global guids(from global table which had the guid values already) with this guids related to salesvalues. and if one single guid mathes to 2 values of salesvalues then concatenate 2 values with comma and display in single field. if select-options are blank then fetch all opportunity guids which have salesvalues. pls give solution.Hi Srini,
Thanks for your Reply
I have kept 01 against the field BSEG-AUGDT and selected the preselect check box also.
But still that field is not visible in the dynamic selection screen.
Thanks
Ajay.D -
Disabling certain fields on the selection screen.
Hi all,
I want to disable certain fields on selection screen of my program, also i want to display certain fields on selection screen only if a particular field on the selection screen is checked or selected. Please guide me how this can be achieved via coding in a program.
Thanks & regards,
Chetan.Hi Chetan,
try this.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: pa_file TYPE rlgrap-filename MODIF ID abc,
pa_lifnr TYPE lfa1-lifnr MODIF ID abc,
pa_vkorg TYPE vbak-vkorg MODIF ID abc.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: pa_kunnr TYPE vbak-kunnr MODIF ID def.
SELECT-OPTIONS: s_lifnr FOR gs_lfa1-lifnr MODIF ID def,
s_date FOR gs_lfa1-erdat MODIF ID def,
s_augru FOR gs_vbak-augru MODIF ID def,
s_vbeln FOR gs_vbak-vbeln MODIF ID def.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: pa_upd RADIOBUTTON GROUP g1 USER-COMMAND uc01 DEFAULT 'X'."#EC *
SELECTION-SCREEN COMMENT 3(60) text-004 FOR FIELD pa_upd.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: pa_rep RADIOBUTTON GROUP g1 ."#EC *
SELECTION-SCREEN COMMENT 3(60) text-005 FOR FIELD pa_rep.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.
IF pa_rep EQ gc_x.
LOOP AT SCREEN.
IF screen-group1 = gc_abc.
screen-input = gc_zero_num.
ELSEIF screen-group1 = gc_def.
screen-active = gc_one_num.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ELSEIF pa_upd EQ gc_x.
*For Reprocessing
LOOP AT SCREEN.
IF screen-group1 = gc_def.
screen-input = gc_zero_num.
ELSEIF screen-group1 = gc_abc.
screen-active = gc_one_num.
ENDIF.
MODIFY SCREEN.
CLEAR pa_upd.
ENDLOOP.
ENDIF.
REPORT zrich_001.
PARAMETERS: p_rad1 RADIOBUTTON GROUP grp1 DEFAULT 'X'
user-command chk,
p_rad2 RADIOBUTTON GROUP grp1.
SELECT-OPTIONS: s_datum1 FOR sy-datum MODIF ID d1,
s_datum2 FOR sy-datum MODIF ID d2.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF p_rad1 = 'X'
AND screen-group1 = 'D2'.
screen-active = '0'.
ENDIF.
IF p_rad2 = 'X'
AND screen-group1 = 'D1'.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
reward if useful.
regards,
sravanthi. -
How to Add a new fields in the selection screen of LDB.
Hi All,
I want to add a new fields in the selection screen of LDB & then i need to select the data for that fields.
So could you please tell me for that where i need to add the code for selecting the data.
Thanks
RoliHi
welcome to SDN forum
If you are designing your own LDB with your own tables you can define tree structure and then the selection screen for the tables
if you wants to modify the std LDB of SAp means take the access key and to modify that code
if you add the extra field you have to modify the where conditions in the code also
see the doc
A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.
LDB offers an easy-to-use selection screens. You can modify the pre-generated selection screen to your needs. It offers check functions to check whether user input is complete, correct, and plausible. It offers reasonable data selections. It contains central authorization checks for data base accesses. Enhancements such as improved performance immediately apply to all report programs that use the logical database.
Less coding s required to retrieve data compared to normal internel tables.
Tables used LDB are in hierarchial structure.
Mainly we used LDBs in HR Abap Programming.
Where all tables are highly inter related so LDBs can optimize the performance there.
Check this Document. All abt LDB's
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=%2flibrary%2fabap%2fabap-code-samples%2fldb+browser.doc
GO THROUGH LINKS -
http://www.sap-basis-abap.com/saptab.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
Re: **LDB**
www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html
www.sap-img.com/abap/abap-interview-question.htm
www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm
Gothru the blog which provides info on LDB's:
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
Sample code
TABLES: SPFLI,
SFLIGHT,
SBOOK,
SCARR.
START-OF-SELECTION.
GET SPFLI.
WRITE:/ SPFLI: , SPFLI-CARRID, SPFLI-CONNID,
SPFLI-AIRPFROM, SPFLI-AIRPTO.
GET SFLIGHT.
WRITE:/ SFLIGHT: , SFLIGHT-CARRID, SFLIGHT-CONNID, SFLIGHT-FLDATE.
GET SBOOK.
WRITE:/ SBOOK: , SBOOK-CARRID, SBOOK-CONNID,
SBOOK-FLDATE, SBOOK-BOOKID.
GET SFLIGHT LATE.
WRITE:/ GET SFLIGHT LATE: , SFLIGHT-FLDATE.
Regards
anji
Maybe you are looking for
-
Equium L100-186 Graphic Resolution
This is a new Equium L100-186, that I have installed Win XP Proffesional. I'm steel not shore witch model it is, because at toshiba webpage it gives me two options L10 and L20 series, but the drives for the L10 do not work but the L20 works?!?! Anywa
-
Product Name: HP Touchsmart 23-f217c Edition: Windows 8.1 I have just purchased some new Beats Wireless bluetooth headphones and would like to connect them with my computer. I go into Settings/PC Settings/Devices and there is no option to enable or d
-
We are trying to use the Oracle supplied JDBC thin driver directly from within a jar file we add for our application. The classes in the jar file directly connect to an oracle database via the thin driver. The problem we've encountered is that if the
-
Dear Gurus I attempted to find those items from MB5S List of GR Balances those items which are matching on total and mis-matched on SERV Entry Sheet / GR QTY and Invoice QTY. They did not appear on the MR11 listing to allow clearing. Please s
-
How do you make charts in the Numbers app on the iPad?
I've followed the guides, asked Geniuses and spoken with AppleCare on how to implement charts within the iPad Numbers app. So far I haven't been able together any help or suggestions. I am trying to create a pie chart showing some data for an investm