Disposition variable ALV
Hi experts!!
I need to create a disposition variable in the toolbar of my ALV, does anybody know how can I do this?
Thanks a lot!!
Regards,
Rebeca
What exactly is a "disposition variable", never heard of it...
Similar Messages
-
ALV GRID WITH SUMMATORIES DEPEND OF THE SELECTION
Hi Experts.
I have a form, in which depend of the selection, I show to user a fieldcatalog with the data (query) that the user want to see in that moment ...
The problem is that the user want to see one field (amount, sum total (money) ...etc) with summatories, group by date, person...or other depend of the selection he has done in the select dynpro.
How can I do it when I show the ALV??... The user don't want to use the option to make a lot of select dispositions in the ALV..., he want to see the disposition of the data depend the selection he do in the select dynpro.
I see when I create the fieldcatalog to the ALV GRID, there is a field ... do_sum, I have marked it, in the field which I want to do a summatory but don't do anything in the ALV when display.... and don't find how indicate in the fieldcatalog the field which I wan't group by...
Other options, that I have thought it's to make a lot of dispositions in ALV, and when display de ALV try to get the disposition that I want ... but I haven't did it.
Thanks.Hi all,
it is maybe too late to answer this question but I hope it can serve someone who bumps into this problem in the future.
I managed to activate the functions with the following code:
DATA alv TYPE REF TO cl_salv_table.
DATA: lo_functions TYPE REF TO cl_salv_functions_list.
DATA: lo_funcs TYPE salv_t_ui_func.
DATA: lo_func TYPE salv_s_ui_func.
cl_salv_table=>factory(
IMPORTING r_salv_table = alv
CHANGING t_table = <fs> ).
* Default Functions
lo_functions = alv->get_functions( ).
lo_funcs = lo_functions->get_functions( ).
* loop through all functions and enable them and set them visible.
* here u can also activate separate functions if you check the name with the method from r_function (CL_SALV_FUNCTION->GET_NAME)
LOOP AT lo_funcs INTO lo_func.
lo_func-r_function->set_enable( value = 'X' ).
lo_func-r_function->set_visible( value = 'X' ).
ENDLOOP.
alv->display( ).
Cheers,
Ilina -
Code for hr-abap report in alv display
Hi Gurus,
I am new to hr-abap and I want some sample code to display a hr report in an alv.
Thanks,
Raj.This is one such...
REPORT yh_rep_hr_certified_instructor MESSAGE-ID yh_messages NO STANDARD
PAGE
HEADING .
Program : YH_REP_HR_CERTIFIED_INSTRUCTOR *
Description : Certified Instructor Eligibility Criteria *
TABLES *
TABLES :hrp1000 ,hrp1001, pa0000.
TYPE-POOLS *
*Type Pool for ALV display
TYPE-POOLS :slis. " Global types for generic cunning components
INTERNAL TABLES *
*Internal Table to keep Selection Screen field values
DATA : BEGIN OF t_validation OCCURS 0.
INCLUDE STRUCTURE dynpread.
DATA END OF t_validation.
*Internal Table for Business Event Groups
DATA : BEGIN OF t_bgrp OCCURS 0,
objid TYPE hrobjid,
blank(1),
stext TYPE stext,
END OF t_bgrp.
*Internal Table for Business Event Type IDs with text for selected Event
*GROUPS
DATA : BEGIN OF t_btyp OCCURS 0,
objid TYPE hrobjid,
blank(1),
stext TYPE stext,
END OF t_btyp.
*Internal Table for Business Event Type IDs for selected Event Groups
DATA : BEGIN OF t_eventtypelist OCCURS 0,
objid TYPE hrobjid,
END OF t_eventtypelist.
*Internal table to store the business Groups
DATA : BEGIN OF t_group OCCURS 0,
objid LIKE hrp1001-objid,
sobid LIKE hrp1001-sobid,
sclas LIKE hrp1001-sclas,
END OF t_group.
*Internal table to hold the business event group and/or bus. event types
DATA : BEGIN OF t_eventgroup OCCURS 0,
objid LIKE hrp1001-objid,
END OF t_eventgroup.
*Internal Table for FieldCatalog used for ALV Display
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*Work Area for Checking Business Event Group Validity
DATA: BEGIN OF wa_bgrp,
objid TYPE hrobjid,
stext TYPE stext,
END OF wa_bgrp.
*Internal table to fetch object id for Qualification
DATA: BEGIN OF t_objid OCCURS 0,
objid TYPE hrp1000-objid,
sobid TYPE hrp1001-sobid,
sobid_copy TYPE hrp1001-objid,
END OF t_objid.
*Internal table to fetch Id of related object
*Fetches Pernr of Certified Instructors
DATA: BEGIN OF t_sobid OCCURS 0,
objid TYPE hrp1000-objid,
sobid TYPE hrp1001-sobid,
adatanr TYPE hrpad31-adatanr,
sobid_copy TYPE hrp1001-objid,
END OF t_sobid.
*Internal table to fetch skill rating
*of the Instructor
DATA: BEGIN OF t_prof OCCURS 0,
adatanr TYPE hrpad31-adatanr,
chara TYPE hrpad31-chara,
END OF t_prof.
*Internal table to fetch grade
*of the Insturctor
DATA: BEGIN OF t_grade OCCURS 0,
pernr TYPE pa0008-pernr,
yysalgr TYPE pa0008-yysalgr,
END OF t_grade.
*Internal table which contains all information about the Person like
*Name Project Project Manager Name Account and Vertical Name
DATA: t_projdetails TYPE zbapi_projdetails OCCURS 0 WITH HEADER LINE.
*Final Internal table which contains all information
*about the Instructors
DATA: BEGIN OF t_final OCCURS 0,
empid TYPE pa0000-pernr,
empname(84) TYPE c,
grade TYPE pa0008-yysalgr,
atndttt(3) TYPE c,
sklrate TYPE hrpad31-chara,
pgmng TYPE pa0001-ename,
accname TYPE hrp1000-stext,
vertname TYPE hrp1000-stext,
END OF t_final.
VARIABLES *
*ALV layout
DATA: gs_layout TYPE slis_layout_alv, "alvtot test
gt_events TYPE slis_t_event,
gt_list_top_of_page TYPE slis_t_listheader,
gs_variant LIKE disvariant, "For Layout
g_save. "For Layout Save
DATA: w_pos TYPE i VALUE 1, " Position of Fields in ALV
w_sort TYPE slis_t_sortinfo_alv, "ITab for Sorting Options
w_flag TYPE i,
w_repid TYPE sy-repid,
w_lineno TYPE sy-tabix.
DATA: l_short TYPE hrp1000-short. "variable to check the heirarchy
SELECTION-SCREEN DESIGN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. "NO INTERVALS .
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-009 MODIF ID xyz.
PARAMETERS : p_bgrp TYPE hrobjid OBLIGATORY,
p_bgrp1 TYPE stext .
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS :s_btyp FOR hrp1000-objid OBLIGATORY NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION *
INITIALIZATION.
*Assign Program Name into a variable
w_repid = sy-repid.
*Build layout for list display
gs_layout-detail_popup = 'X'.
*To get All Events in TOP-OF-PAGE
perform eventtab_build using gt_events[].
gs_variant-report = w_repid.
g_save = 'A'.
AT SELECTION SELECTION *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bgrp.
PERFORM get_bgrp.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_btyp-low.
IF NOT p_bgrp IS INITIAL .
PERFORM get_btyp USING 'l'.
ELSE .
MESSAGE s999 WITH text-e09.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_btyp-high.
IF NOT p_bgrp IS INITIAL .
PERFORM get_btyp USING 'h'.
ELSE .
MESSAGE s999 WITH text-e09.
ENDIF.
AT SELECTION-SCREEN ON p_bgrp.
SELECT SINGLE objid stext
FROM hrp1000
INTO wa_bgrp
WHERE objid = p_bgrp AND
otype = 'L' AND
plvar = '01' AND
( short = 'ROLE' OR
short = 'TECH_PROGRAM' ).
IF sy-subrc EQ 0.
p_bgrp1 = wa_bgrp-stext.
ELSE.
MESSAGE e999 WITH text-e09.
ENDIF.
AT SELECTION-SCREEN ON s_btyp.
CLEAR : t_eventtypelist, t_group, t_eventgroup.
REFRESH : t_eventtypelist, t_group, t_eventgroup.
CLEAR : w_flag.
*Fetch all the subordinates under given Event Group - L/D
SELECT objid
sobid
sclas
FROM hrp1001
INTO TABLE t_group
WHERE objid = p_bgrp
AND plvar = '01'
AND rsign = 'B'
AND relat = '003'
AND ( sclas = 'L' OR sclas = 'D' ).
WHILE w_flag <> 1.
PERFORM get_objids.
ENDWHILE.
IF NOT t_eventtypelist[] IS INITIAL.
*Get only valid Event Types from input Event Types, for given Event
*Group - by deleting others..
LOOP AT t_eventtypelist.
IF t_eventtypelist-objid IN s_btyp.
EXIT.
ELSE.
DELETE t_eventtypelist.
ENDIF.
AT LAST.
*since we r checking Event Types, All other fields will be locked
*but we need Event Group field to be unlocked to edit again,
*if theres no theres no valid Event Types in given input
LOOP AT SCREEN.
CHECK screen-name = 'P_bgrp'.
screen-input = '1'.
MODIFY SCREEN.
ENDLOOP.
MESSAGE e999 WITH text-e04.
EXIT.
ENDAT.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
CHECK screen-name = 'P_bgrp'.
screen-input = '1'.
MODIFY SCREEN.
ENDLOOP.
MESSAGE e999 WITH text-e03.
ENDIF.
FORM get_bgrp *
FORM get_bgrp .
SELECT objid stext
FROM hrp1000
INTO CORRESPONDING FIELDS OF TABLE t_bgrp
WHERE plvar = '01' AND
otype = 'L' AND
short = 'ROLE' OR
short = 'TECH_PROGRAM' .
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 75
endpos_row = 20
startpos_col = 30
startpos_row = 05
titletext = 'Select Business Event Group'
IMPORTING
choise = w_lineno
TABLES
valuetab = t_bgrp
EXCEPTIONS
break_off = 1
OTHERS = 2.
IF sy-subrc EQ 0 .
READ TABLE t_bgrp INDEX w_lineno.
IF sy-subrc EQ 0.
p_bgrp = t_bgrp-objid.
p_bgrp1 = t_bgrp-stext.
ENDIF .
CLEAR t_bgrp .
REFRESH t_bgrp .
ENDIF .
ENDFORM . "get_bgrp
****subroutine for business eventtype input criteria
FORM get_btyp USING f_range.
CLEAR : t_validation,
t_btyp,
t_eventtypelist,
t_group,
t_eventgroup,
w_flag.
REFRESH : t_validation,
t_btyp,
t_eventtypelist,
t_group,
t_eventgroup.
t_validation-fieldname = 'P_BGRP'.
APPEND t_validation.
CLEAR t_validation.
*Getting Screen Values
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = w_repid
dynumb = '1000'
TABLES
dynpfields = t_validation
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE t_validation WITH KEY fieldname = 'P_BGRP'.
IF NOT t_validation-fieldname IS INITIAL.
*Getting Event Group ID that entered
LOOP AT t_validation.
IF t_validation-fieldname = 'P_BGRP'.
p_bgrp = t_validation-fieldvalue.
ENDIF.
ENDLOOP.
CLEAR t_validation.
REFRESH t_validation.
*To fetch the business event groups and business event types that belong
to the input business event group.Since a business group can have a
*business groups as well as business event types we have pick all of
*them
*Getting all subordinates - Event Group/Type under given Event Group
SELECT objid
sobid
sclas
FROM hrp1001
INTO TABLE t_group
WHERE objid = p_bgrp
AND plvar = '01'
AND rsign = 'B'
AND relat = '003'
AND endda = '99991231'
AND ( sclas = 'L' OR sclas = 'D' ).
*Getting all Event Types
WHILE w_flag <> 1.
PERFORM get_objids.
ENDWHILE.
IF NOT t_eventtypelist[] IS INITIAL.
SORT t_eventtypelist BY objid.
*Getting Names of Event Types
SELECT objid
stext
FROM hrp1000
INTO CORRESPONDING FIELDS OF TABLE t_btyp
FOR ALL ENTRIES IN t_eventtypelist
WHERE objid = t_eventtypelist-objid
AND otype = 'D' AND plvar = '01'
AND endda = '99991231'.
IF sy-subrc = 0.
*PopUp Display for Event Types
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 75
endpos_row = 20
startpos_col = 30
startpos_row = 05
titletext = 'Select Business Event Type ID'
IMPORTING
choise = w_lineno
TABLES
valuetab = t_btyp
EXCEPTIONS
break_off = 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.
ELSE.
*Since the Table returned by function module will have data in Header,
*clear the Header
*Retreive Selected Event Type into Select Option
READ TABLE t_btyp INDEX w_lineno.
IF sy-subrc EQ 0.
IF f_range = 'l'.
s_btyp-low = t_btyp-objid.
ELSE.
s_btyp-high = t_btyp-objid.
ENDIF.
ENDIF.
ENDIF.
ELSE.
MESSAGE s999 WITH text-e03.
ENDIF.
ELSE.
MESSAGE s999 WITH text-e01.
ENDIF.
ENDIF.
ENDFORM. " EVNTTY
FORM get_objids *
FORM get_objids.
*To delete the business event types that are found and push it in
*another table
IF NOT t_group[] IS INITIAL.
LOOP AT t_group.
*If event type
IF t_group-sclas = 'D'.
t_eventtypelist-objid = t_group-sobid.
APPEND t_eventtypelist.
CLEAR t_eventtypelist.
DELETE t_group.
*If event group
ELSEIF t_group-sclas = 'L'.
t_eventgroup-objid = t_group-sobid.
APPEND t_eventgroup.
CLEAR t_eventgroup.
DELETE t_group.
CLEAR t_group.
ENDIF.
ENDLOOP.
ELSE.
w_flag = 1.
ENDIF.
IF NOT t_eventgroup[] IS INITIAL.
*To get the second level of business groups and business event type
SELECT objid sobid sclas
FROM hrp1001
INTO TABLE t_group
FOR ALL ENTRIES IN t_eventgroup
WHERE objid = t_eventgroup-objid
AND plvar = '01'
AND rsign = 'B'
AND relat = '003'
AND endda = '99991231'
AND ( sclas = 'L' OR sclas = 'D' ).
CLEAR t_eventgroup.
REFRESH t_eventgroup.
ENDIF.
ENDFORM. " GET_OBJIDS
Start of Selection *
START-OF-SELECTION.
*Pass the Event Type and fetch the Related Id
*for the Qualification imparted by the Event
SELECT objid sobid
FROM hrp1001
INTO TABLE t_objid
WHERE objid IN s_btyp AND
otype = 'D' AND
plvar = '01' AND
relat = '028' AND
rsign = 'A' AND
sclas = 'Q'.
IF sy-subrc EQ 0.
*Pass the Qualification Id and fetch Object Id of the
*person who fulfills this Qualification
SELECT objid sobid adatanr
FROM hrp1001
INTO TABLE t_sobid FOR ALL ENTRIES IN t_objid
WHERE sobid = t_objid-sobid AND
otype = 'P' AND
plvar = '01' AND
relat = '032' AND
rsign = 'A' AND
sclas = 'Q' .
IF sy-subrc = 0.
*Fetch only the Person along with the skillrating
*who has skill rating as '0001' or '0003'
SELECT adatanr chara
FROM hrpad31
INTO TABLE t_prof
FOR ALL ENTRIES IN t_sobid
WHERE adatanr = t_sobid-adatanr AND
( chara = '0001' OR chara = '0003' ).
IF sy-subrc NE 0.
MESSAGE s999 WITH text-s01.
EXIT .
ELSE .
*Fetch only Employee Id's who meets the required skill rating
*which inturn has the EMPID who are all are Certified Instructors
LOOP AT t_sobid.
READ TABLE t_prof WITH KEY adatanr = t_sobid-adatanr.
IF sy-subrc NE 0.
DELETE t_sobid .
ENDIF.
ENDLOOP.
SORT t_sobid BY objid.
DELETE ADJACENT DUPLICATES FROM t_sobid.
ENDIF.
ENDIF.
ENDIF.
IF NOT t_sobid[] IS INITIAL.
data: begin of it_trgpernr occurs 0,
objid type hrp1000-objid,
sobid type hrp1001-sobid,
end of it_trgpernr.
select objid sobid
from hrp1001
into table it_trgpernr for all entries in t_sobid
where otype ='P' and
objid = t_sobid-objid and
sclas = 'D' and
sobid = '50008220'.
*Fetch Grade of the Certified Instructors by passing their EmpId's
SELECT pernr yysalgr
FROM pa0008
INTO TABLE t_grade
FOR ALL ENTRIES IN t_sobid
WHERE pernr = t_sobid-objid AND endda = '99991231'.
ENDIF.
For Heading in the Output Display Layout
PERFORM heading USING gt_list_top_of_page[].
End of Selection *
END-OF-SELECTION.
Populating data into Final Table which contains all information aboutthe Certified Instructors
*Retrieve Employee Id for the Certified Instructors only if he is active
LOOP AT t_sobid.
SELECT SINGLE *
FROM pa0000
WHERE pernr = t_sobid-objid AND
begda <= sy-datum AND
endda >= sy-datum AND
stat2 ='3'.
IF sy-subrc = 0.
t_final-empid = t_sobid-objid.
SELECT SINGLE *
FROM hrp1001
WHERE otype = 'P' AND
objid = t_sobid-objid AND
rsign = 'B' AND
relat = '25' AND
sclas = 'D' AND
sobid = '50008220'.
*DATA:W_SOBID TYPE HRP1001-SOBID.
*W_SOBID = t_sobid-objid. .
SELECT SINGLE *
FROM hrp1001
WHERE otype = 'D' AND
objid = '50008220' AND
rsign = 'B' AND
relat = '25' AND
sclas = 'P' AND
sobid = W_SOBID.
IF sy-subrc EQ 0.
t_final-atndttt = 'YES'.
ELSE.
t_final-atndttt = 'NO'.
ENDIF.
*Retrieve Employee SkillRating for the Certified Instructors
*by passing the adatanr value which inturn is fetched based on the empid
READ TABLE t_prof WITH KEY adatanr = t_sobid-adatanr.
IF sy-subrc EQ 0.
t_final-sklrate = t_prof-chara.
ENDIF.
*Retrieve Employee Grade for the given id
READ TABLE t_grade WITH KEY pernr = t_sobid-objid.
IF sy-subrc EQ 0.
t_final-grade = t_grade-yysalgr.
ENDIF.
REFRESH t_projdetails.
CLEAR t_projdetails.
*function which fetches the name project name account and
*vertical name of the person for the given empid
CALL FUNCTION 'ZBAPI_PROJDETAILS'
EXPORTING
pernr = t_sobid-objid
TABLES
it_finaltab = t_projdetails.
IF NOT t_projdetails[] IS INITIAL.
SHIFT t_sobid-objid LEFT DELETING LEADING '0'.
READ TABLE t_projdetails WITH KEY pernr = t_sobid-objid.
IF sy-subrc EQ 0.
t_final-empname = t_projdetails-ename.
IF NOT t_projdetails-proj IS INITIAL.
t_final-pgmng = t_projdetails-pmname.
ELSE.
t_final-pgmng = t_projdetails-gmname.
ENDIF.
t_final-accname = t_projdetails-accname.
t_final-vertname = t_projdetails-vertname.
ENDIF.
ENDIF.
APPEND t_final.
ENDIF.
CLEAR t_final.
ENDLOOP.
SORT t_final BY empid.
DELETE ADJACENT DUPLICATES FROM t_final.
*Enabling Sort by PERNR & Global ID in ALV display
PERFORM sub_sort_info.
*Form to Populate Field Catalog
PERFORM populate_fieldcatalog.
For the ALV ROW Optimize Width
gs_layout-colwidth_optimize = 'X' .
*perform alv_display tables final fieldcatalog.
IF NOT t_final[] IS INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
is_layout = gs_layout
it_fieldcat = t_fieldcatalog[]
it_sort = w_sort
i_save = 'A'
it_events = gt_events[]
TABLES
t_outtab = t_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.
MESSAGE s000(vz) WITH 'No Records found for Given Input Criteria'.
ENDIF.
TOP OF PAGE *
*Outputs formatted simple header information at TOP-OF-PAGE.
TOP-OF-PAGE.
PERFORM top_of_page.
Subroutines *
*& Form eventtab_build
text`
-->P_GT_EVENTS[] text
FORM eventtab_build USING rt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
DATA: g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = rt_events.
READ TABLE rt_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE g_top_of_page TO ls_event-form.
APPEND ls_event TO rt_events.
ENDIF.
ENDFORM. " eventtab_build
*& Form HEADING
text
FORM heading USING lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
*Layout Display Text - "Caritor ( India ) Pvt.Ltd "
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = text-h01.
APPEND ls_line TO lt_top_of_page.
*Layout Display Text - "Certified Instructor Eligibility List "
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = text-h02.
APPEND ls_line TO lt_top_of_page.
ENDFORM. " HEADING
*& Form top_of_page
text
--> p1 text
<-- p2 text
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_list_top_of_page.
ENDFORM. " top_of_page
*& Form sub_sort_info
text
--> p1 text
<-- p2 text
FORM sub_sort_info.
DATA : l_sort TYPE slis_sortinfo_alv .
CLEAR l_sort.
Employee ID
l_sort-fieldname = 'EMPID'.
l_sort-up = 'X'.
APPEND l_sort TO w_sort.
ENDFORM. " sub_sort_info
*& Form populate_fieldcatalog
text
--> p1 text
<-- p2 text
FORM populate_fieldcatalog.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'EMPID' ' ' text-011 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'EMPNAME' ' ' text-002 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'GRADE' ' ' text-003 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'ATNDTTT' ' ' text-004 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'PGMNG' ' ' text-006 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'ACCNAME' ' ' text-007 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'VERTNAME' ' ' text-008 20 w_pos.
PERFORM fill_fields_of_fieldcatalog
TABLES t_fieldcatalog
USING 'T_FINAL' 'SKLRATE' ' ' text-005 20 w_pos.
ENDFORM. " populate_fieldcatalog
*& Form FILL_FIELDS_OF_FIELDCATALOG
text
-->P_T_FIELDCATALOG text
-->P_0870 text
-->P_0871 text
-->P_0872 text
-->P_TEXT_001 text
-->P_20 text
-->P_W_POS text
FORM fill_fields_of_fieldcatalog TABLES fp_t_fieldcatalog STRUCTURE
t_fieldcatalog
USING fp_table
fp_field
fp_key
fp_text
fp_out_len
fp_pos.
fp_t_fieldcatalog-tabname = fp_table.
fp_t_fieldcatalog-fieldname = fp_field.
fp_t_fieldcatalog-seltext_l = fp_text.
fp_t_fieldcatalog-key = fp_key.
fp_t_fieldcatalog-outputlen = fp_out_len.
fp_t_fieldcatalog-col_pos = fp_pos.
APPEND fp_t_fieldcatalog.
CLEAR: fp_t_fieldcatalog.
fp_pos = fp_pos + 1.
ENDFORM. " FILL_FIELDS_OF_FIELDCATALOG
10.249.11.136\SAP-StudyMaterial -
Trying to send the alv's information to excel file
Hello iam trying to send the alv's information, when i execute my program sent an alv with that information that i have selected and then i would like to sent that information that the alv containe to an excel file, that why i press the button located top of alv, this sent an excel screen but this screen appears plain,without information but doesn't send an error.
thanks a lot for you helpMr Heilman:
I am really sorry for to many question and this troubles
this is the segment fo code that i am using:
*& Report ZREPORTE_PA9011
REPORT zreporte_pa9011 NO STANDARD PAGE HEADING MESSAGE-ID 02.
*Tables declaration
TABLES pa9011.
TYPES BEGIN OF prueba.
INCLUDE STRUCTURE pa9011.
TYPES END OF prueba.
DATA prueba TYPE STANDARD TABLE OF prueba WITH HEADER LINE.
*declaracion de las variables para el alv
TYPE-POOLS: slis.
DATA: repname LIKE sy-repid, "variables alv
heading TYPE slis_t_listheader,
layout TYPE slis_layout_alv,
fieldtab TYPE slis_t_fieldcat_alv.
*Sections parameters
SELECTION-SCREEN: BEGIN OF BLOCK bi WITH FRAME TITLE text-001.
SELECT-OPTIONS subtipo FOR pa9011-subty.
PARAMETER: pbegda LIKE pa9011-begda.
SELECTION-SCREEN: END OF BLOCK bi.
START-OF-SELECTION.
repname = sy-repid.
PERFORM selecciona_datos.
PERFORM transfer_to_alv.
*& Form selecciona_datos
text
FORM selecciona_datos.
REFRESH prueba.
SELECT * INTO CORRESPONDING FIELDS OF TABLE prueba FROM pa9011
WHERE subty IN subtipo
AND begda GT pbegda.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Aun no existen datos cargados'.
ENDIF.
ENDFORM. "selecciona_datos
*& Form transfer_to_alv
send the information from prueba into alv
FORM transfer_to_alv.
PERFORM initialize_fieldcat USING fieldtab[].
PERFORM build_layouts USING layout.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repname
i_callback_user_command = 'AT_USER_COMMAND'
i_callback_top_of_page = 'BUILD_COMMENT'
i_structure_name =
is_layout = layout
it_fieldcat = fieldtab[]
i_default = 'X'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = PRUEBA
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. "transfer_to_alv
*& Form initialize_fieldcat
text
-->P_FIELDTAB text
FORM initialize_fieldcat USING p_fieldtab TYPE slis_t_fieldcat_alv.
DATA: l_fieldcat TYPE slis_fieldcat_alv.
REFRESH p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'PRUEBA'.
l_fieldcat-ref_tabname = 'PA9011'.
l_fieldcat-sp_group = 'A'.
l_fieldcat-fieldname = 'SUBTY'.
l_fieldcat-seltext_m = text-t01.
l_fieldcat-col_pos = 1.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'BEGDA'.
l_fieldcat-seltext_m = text-t02.
l_fieldcat-col_pos = 2.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ENDDA'.
l_fieldcat-seltext_m = text-t03.
l_fieldcat-col_pos = 3.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'AEDTM'.
l_fieldcat-seltext_m = text-t04.
l_fieldcat-col_pos = 4.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'UNAME'.
l_fieldcat-seltext_m = text-t05.
l_fieldcat-col_pos = 5.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'PREAS'.
l_fieldcat-seltext_m = text-t06.
l_fieldcat-col_pos = 6.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ZDESCRSEGURO'.
l_fieldcat-seltext_m = text-t07.
l_fieldcat-col_pos = 7.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ZASEGURADORA'.
l_fieldcat-seltext_m = text-t08.
l_fieldcat-col_pos = 8.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ZCOBERTURA'.
l_fieldcat-seltext_m = text-t09.
l_fieldcat-col_pos = 9.
APPEND l_fieldcat TO p_fieldtab.
ENDFORM. "initialize_fieldcat
*& Form build_layouts
text
FORM build_layouts USING p_layout TYPE slis_layout_alv.
p_layout-colwidth_optimize = 'X'.
p_layout-zebra = 'X'.
p_layout-f2code = '&ETA'.
p_layout-detail_popup = 'X'.
ENDFORM. "build_layouts
*& Form build_comment
text
FORM build_comment.
DATA: hline TYPE slis_listheader,
text(60) TYPE c.
REFRESH heading.
CLEAR: hline, text.
hline-typ = 'H'.
text = text-h01.
hline-info = text.
APPEND hline TO heading.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = heading.
ENDFORM. "build_comment -
How doi print Any variable at the end of page in ALV report?
Hi,
Anyone can tell me that How do i print Any variable at the end of page in ALV report?
Exmale: at the ende of alv report i want to print total no of employee who has taken house loan or education loan.Hi,
Go through these links
Thread in sdn regarding FOOTER IN ALV
[ALV FOOTER;
Wiki in sdn regarding HEADER AND FOOTER IN ALV
[https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP%20Objects%20-%20ALV%20Model%20-%20Using%20Header%20and%20Footer]
Header and Footer in ALV
[http://www.sap-img.com/abap/test-alv-display-with-header-footer.htm]
Hope this helps.
Thank you,
Pavan. -
HOW TO ADD NEW VARIABLE DATAS ON ALV REPORT
Hi gurus,
I have cretaed one alv report using
REUSE_ALV_GRID_DISPLAY.
I HAVE CALCULATED SOME TOTALS AND STORED ON
ONE VARIABLE .
that variable name is 'toterror'.
now i want to add this variable on first line OF ALV REPORT.
that is i should get LIKE THIS.
PERNR TEXT ACTION [ TITLES OF FIELDS ].THEN
TOTAL ERROR RECORDS '900'.
THEN THE CORRESPONDING FIELDS DATA SHOULD BE DISPLAYED.
HELP ME.
THANKS IN ADVANCE.Hi
Thanks Ajeet.
The scenario is that I have to create a formula (contract end date-current date) and have to display the result using exeption to highlight the contracts ending in 30-60 days.
The problem is that the info provider does not have any infoobject for date(only valid to and validity start date)
I have created a formula variable on valid to date using replacement path. But dont have any variable to use for current date.
The only time char in the cube is Fiscal yera variant.
How should I go futher creating such formula? Shall I user customer exit variable? But I dont have any date char to create on.
Can you shed some light on this problem
Thanks -
Dynamic creation of variables and alv grid output/internal table
Dear Experts
I am stuck in an inventory ageing report which is to be done year wise. the scenario is as follow.
selection screen i enter the year 2011 or 2010 or 2009.
the output should show me 2011-2007 or 2010-2007 or 2009-2007. the alv grid should always start from 2007 and end at the year that is entered in the selection screen.
Now how can i create a dynamic variables to store the values of the corresponding yr and also how can i create a dynamic internal table to store these values.
Thanks & Regards
Zamir ParkarHi Zamir,
if you are new to ABAP you may leave old and buggy techniques behind.
If you want to create the table dynamically, please do not use l_alv_table_create=>create_dynamic_table because it is limited and always triggers a possibly unwanted database commit.
You better use RTTS dynamic runtime type services, i.e. check the example for [Creating Flat and Complex Internal Tables Dynamically using RTTI|http://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI].
As done here, leave all outdated ALV technologies behind and start with CL_SALV_TABLE. It is following the object-oriented approach and does not need a field catalog.
You will get used to field-symbols that can be compared to the data referenced by a pointer. For dynamic fields, you may build the field names dynamically, i.e.
DATA:
lo_structdescr TYPE REF TO cl_abap_structdescr,
lo_typedescr TYPE REF TO cl_abap_typedescr,
lo_tabledescr TYPE REF TO cl_abap_tabledescr,
lr_data TYPE REF TO data,
lt_comp_all TYPE cl_abap_structdescr=>component_table,
lv_index TYPE numc2.
FIELD-SYMBOLS:
<any> TYPE ANY,
<component> TYPE LINE OF abap_component_tab,
<table> TYPE table.
DO nnn TIMES.
lv_index = sy-index.
lo_typedescr = cl_abap_typedescr=>describe_by_name( <name of data element> ).
APPEND INITIAL LINE TO lt_comp_all ASSIGNING <component>.
<component>-type ?= lo_typedescr.
CONCATENATE 'YEARVAL' lc_underscore lv_index INTO <component>-name.
<component>-as_include = abap_true.
CONCATENATE lc_underscore lv_index INTO <component>-suffix.
ENDDO.
* create description object for structured type
lo_structdescr = cl_abap_structdescr=>create( lt_comp_all ).
* create table description object for this
lo_tabledescr = cl_abap_tabledescr=>create(
p_line_type = lo_structdescr
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
* create data object
CREATE DATA lr_data TYPE HANDLE lo_tabledescr.
ASSIGN lr_data->* to <table>.
This is a fragment. Please adapt to your needs.
Regards,
Clemens -
Header variable: Content Disposition for downloading file over HTTP?
Hi All,
I have a general content server question...Is there anyway to pass a parameter or set a setting on the content server to send the file with the header variable content-disposition set so that when a user selects a file within a browser, it doesn't open in place but asks the user whether they want to open or save the document?
Note - I'm actually using this with ArchiveLink and displaying the link in the Portal but this forum seems the closest I can get to asking this question.
Regards,
MattThanks Athol.
Although there's quite a bit of configuration options there for displaying files, there doesn't appear to be anything that let's you manipulate the HTTP header variables to set content-disposition.
Any other ideas?
Cheers,
Matt
ps. If you want to artificially see the behaviour I'm after, within IIS, you can predefine this header variable for the contentserver.dll but this makes every HTTP request act like a file that wants to be downloaded, and it calls every file contentserver.<suffix>. From a user perspective, there's nothing worse than a document opening in place in your window (losing the underlying application), or within another IE window, hence why I'd like it to act like a file download. -
Hi all,
I want to print variable text in the top-of-page in the ALV.
Suppose, I am making customer wise sales report.
A new page is triggered when customer changes. I have done this.
I want to print customer name and code in the top of page whenever the customer changes. I have done coding for this like I have made list header which changes when the customer changes.It is working well when the user sees the report output on the screen but when he prints it , the headers are not printed.
Please give me the solution of this problem.
Thnaks and Regards
Gurpreet SinghCheck that whether u
<b>handle_print_top_of_page</b>
Or else it wont work.
Sample for TOP-OF-PAGE and PRINT-TOP-OF-PAGE
* Class definition :
* CLASS v_lcl_event_receiver DEFINITION
CLASS v_lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_print_top_of_page FOR EVENT print_top_of_page OF
cl_gui_alv_grid,
handle_top_of_page FOR EVENT top_of_page OF
cl_gui_alv_grid.
ENDCLASS.
* CLASS V_LCL_EVENT_RECEIVER IMPLEMENTATION
CLASS v_lcl_event_receiver IMPLEMENTATION.
METHOD handle_print_top_of_page.
IF sy-pagno = 1.
PERFORM top_of_page.
ENDIF.
ENDMETHOD.
METHOD handle_top_of_page.
PERFORM top_of_page.
ENDMETHOD.
ENDCLASS.
DATA: v_event_receiver TYPE REF TO v_lcl_event_receiver.
FORM top_of_page.
WRITE: text-020,
ENDFORM. " top_of_page
<u>In PBo of the screen</u>
DATA: v_split TYPE REF TO cl_gui_easy_splitter_container,
v_contnr_top TYPE REF TO cl_gui_container,
v_contnr_bot TYPE REF TO cl_gui_container,
v_grid_02 TYPE REF TO cl_gui_alv_grid,
v_html TYPE REF TO cl_dd_document,
v_text20(255) TYPE c,
v_text16(255) TYPE c,
FORM f9000_objects_create.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
Create a container
CREATE OBJECT o_dockingcontainer
EXPORTING
ratio = '95'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-e01."Error in creating Docking container
LEAVE LIST-PROCESSING.
ENDIF.
CREATE OBJECT v_split
EXPORTING
parent = o_dockingcontainer
* ORIENTATION = 0
sash_position = 25
with_border = 0
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-e01."Error in creating Docking container
LEAVE LIST-PROCESSING.
ENDIF.
* Get the containers of the splitter control
v_contnr_top = v_split->top_left_container.
v_contnr_bot = v_split->bottom_right_container.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_dockingcontainer.
* Create an instance of alv control
CREATE OBJECT o_alvgrid
EXPORTING i_parent = v_contnr_bot.
* Object for display of selection parameters in HTML top container
CREATE OBJECT v_html
EXPORTING
style = 'ALV_GRID'.
* Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
CALL METHOD o_alvgrid->list_processing_events
EXPORTING i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = v_html.
v_text20 = text-020(summary Record counts)Any text.
CALL METHOD v_html->add_gap
EXPORTING
width = 120.
CALL METHOD v_html->add_text
EXPORTING
text = v_text20.
CALL METHOD v_html->new_line.
** Display Text-016
v_text16 = text-016.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
CALL METHOD v_html->add_text
EXPORTING
text = v_text16.
v_text16 = v_sap_recon.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
CALL METHOD v_html->add_text
EXPORTING
text = v_text16.
CALL METHOD v_html->new_line.
<b>* Display the data
CALL METHOD v_html->display_document
EXPORTING
parent = v_contnr_top.
* Handle the event
CALL METHOD o_alvgrid->list_processing_events
EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.</b>
IN PBO while populating in the output table
FORM f9004_display_data TABLES p_report_tab
p_fieldcat.
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = c_a
is_layout = w_layout
CHANGING
it_outtab = p_report_tab[]
it_fieldcatalog = p_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i000 WITH text-e06."Error in ALV report display
LEAVE LIST-PROCESSING.
ENDIF.
* Create object
IF v_event_receiver IS INITIAL.
CREATE OBJECT v_event_receiver.
ENDIF.
SET HANDLER v_event_receiver->handle_print_top_of_page FOR o_alvgrid.
<b> SET HANDLER v_event_receiver->handle_top_of_page FOR o_alvgrid</b>.
Hope this helps u. -
Hi All,
I have to do a ALV with variable no. of columns. i.e Depending on the data , the columns should get populated.
Thanks in advance.
DnyaneshHi Dnyanesh,
If you know the no. of columns to be used in the ALV before hand then you can change the field catalog.
but if you dont know the no. of columns then you can create dynamic table.
eg:
1. Create your field catalog either manually or automatically using the function module, LVC_FIELDCATALOG_MERGE. Add more rows to the field catalog table (T_FIELDCAT) at run time.
2. Use the field catalog to create a table dynamically using the method below.
DATA: T_OUTPUT TYPE REF TO DATA
FIELD-SYMBOLS: <T_OUTPUT> TYPE TABLE
Call Method CL_ALV_TABLE_CREATE->CREATE_DYNAMIC_TABLE
Exporting
IT_FIELDCATALOG = T_FIELDCAT
Importing
EP_TABLE = T_OUTPUT
ASSIGN T_OUTPUT->* TO <T_OUTPUT>.
Now the field symbol <T_OUTPUT> is pointing to an output table of the structure that contains the fields which were determined at runtime. Now fill this table with the data and pass <T_OUTPUT> to the method SET_TABLE_FOR_FIRST_DISPLAY and the ALV grid should show the data properly.
Example:
*the content of itab will be fields of the new table
loop at itab1 into wa1.
Gs_FIELDCAT-TABNAME = 'itab2'.
GS_FIELDCAT-FIELDNAME = wa1-packid.
GS_FIELDCAT-OUTPUTLEN = 2.
GS_FIELDCAT-KEY = space.
GS_FIELDCAT-SELTEXT_L = wa1-packid.
GS_FIELDCAT-COL_POS = 1.
GS_FIELDCAT-JUST = 'L'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
endloop.
LOOP AT GT_FIELDCAT INTO GS_FIELDCAT.
MOVE-CORRESPONDING GS_FIELDCAT TO ls_fcat.
APPEND ls_fcat TO lt_fieldcat.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = lt_fieldcat
IMPORTING ep_table = t_output.
you can refer the following link also.
ALV grid
hope this helps.
do get back if you need further clarification.
Regards,
Kinshuk -
To display variable date in the ALV field header
HI all,
I have an ALV list and one of the field headers is "Total received till 14.03.2008".
Now the date field here is variable. it is being fetched from an internal table and displayed in thee field header of an ALV list.
cud y'all pls tell me how to display this variable date.
thanx,
pkHi,
Just have a look on the following code,i hope this is enough to
meet your requirement.
type-pools: slis.
data: x_fieldcat type slis_fieldcat_alv,
it_fieldcat type slis_t_fieldcat_alv,
l_layout type slis_layout_alv,
x_events type slis_alv_event,
it_events type slis_t_event.
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
posnr like vbap-posnr,
male type i,
female type i,
end of itab.
select vbeln
posnr
from vbap
up to 20 rows
into table itab.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
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 = 2.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
x_fieldcat-fieldname = 'MALE'.
x_fieldcat-seltext_l = 'MALE'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
x_fieldcat-fieldname = 'FEMALE'.
x_fieldcat-seltext_l = 'FEMALE'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
x_events-name = slis_ev_top_of_page.
x_events-form = 'TOP_OF_PAGE'.
append x_events to it_events.
clear x_events .
l_layout-no_colhead = 'X'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = sy-repid
is_layout = l_layout
it_fieldcat = it_fieldcat
it_events = it_events
tables
t_outtab = itab
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 top_of_page.
*-To display the headers for main list
format color col_heading.
write: / sy-uline(103).
write: / sy-vline,
(8) ' ' ,
sy-vline,
(8) ' ' ,
sy-vline,
(27) '***'(015) centered,
sy-vline.
write: / sy-vline,
(8) 'VBELN'(013) ,
sy-vline,
(8) 'POSNR'(014) ,
sy-vline,
(8) 'MALE'(016) ,
sy-vline,
(5) 'FMALE'(017) ,
(10) sy-datum,
sy-vline.
format color off.
endform.
Reward points,if it is useful.
Thanks,
Chandu. -
How to develop variable column in alv report
Hi all,
I want to develop a alv report where the column will be variable and created in runtime as per data.Is it possible in SAP ALV grid display?If possible tell me how I develop such type of report.
For example
MATERIAL BATCH QTY
M1 B1 Q1
M1 B2 Q2
M1 B3 Q3
M2 B4 Q1
This is normal display. I want the following
MATERIAL BATCH1 BATCH2 BATCH3 BATCH4
M1 Q1 Q2 Q3 --
M2 --- -- -- Q4
Please advise and provide your valuable suggestion.
Thanks & Regards
NirmalHi Frn
The Below code will Create the dyanmic internal table ....what you need to do is only pass this internal table and field catalog to Function module "Reuse_alv_display" .
REPORT zhrrt_retention.
TYPE-POOLS : abap.
TABLES: pa0001 , pa0003 .
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,<dyn_wa>,<dyn_field>.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data .
DATA : xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
SELECT-OPTIONS:s_pernr FOR pa0003-pernr .
SELECT-OPTIONS:s_orgeh FOR pa0001-orgeh .
SELECT-OPTIONS:s_date FOR sy-datum .
SELECTION-SCREEN END OF BLOCK b1.
DATA: BEGIN OF it_itab OCCURS 0 ,
depid LIKE pa0001-orgeh ,
pernr LIKE pa0003-pernr,
subty LIKE pa9260-subty,
date LIKE sy-datum,
END OF it_itab .
DATA: BEGIN OF it_date OCCURS 0,
date TYPE sy-datum ,
len TYPE i,
ty TYPE c,
END OF it_date .
SELECT a~orgeh
b~pernr
b~subty
b~begda
FROM pa0001 AS a INNER JOIN pa9260 AS b
ON apernr = bpernr
INTO TABLE it_itab
WHERE a~orgeh IN s_orgeh AND
a~pernr IN s_pernr AND
b~begda IN s_date.
WHILE s_date-low <= s_date-high.
it_date-date = s_date-low .
it_date-len = 8 .
it_date-ty = 'c'.
APPEND it_date.
s_date-low = s_date-low + 1.
ENDWHILE.
PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM proc_data .
FORM get_structure.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
xfc-fieldname = 'pernr' . " XDETAILS-NAME .
xfc-datatype = 'c'. "XDETAILS-TYPE_KIND.
xfc-inttype = 'c'. "XDETAILS-TYPE_KIND.
xfc-intlen = 8 . "XDETAILS-LENGTH.
APPEND xfc TO ifc.
xfc-fieldname = 'empname' . " XDETAILS-NAME .
xfc-datatype = 'c'. "XDETAILS-TYPE_KIND.
xfc-inttype = 'c'. "XDETAILS-TYPE_KIND.
xfc-intlen = 30 . "XDETAILS-LENGTH.
APPEND xfc TO ifc.
LOOP AT it_date .
CLEAR xfc.
xfc-fieldname = it_date-date . " XDETAILS-NAME .
xfc-datatype = it_date-ty. "XDETAILS-TYPE_KIND.
xfc-inttype = it_date-ty. "XDETAILS-TYPE_KIND.
xfc-intlen = it_date-len . "XDETAILS-LENGTH.
APPEND xfc TO ifc.
ENDLOOP.
ENDFORM. "get_structure
FORM create_dynamic_itab.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. "create_dynamic_itab
FORM proc_data .
DATA: l_tabix TYPE sy-tabix .
SORT it_itab BY depid .
LOOP AT it_itab .
READ TABLE it_date WITH KEY date = it_itab-date .
l_tabix = sy-tabix.
IF sy-subrc = 0 .
ASSIGN COMPONENT l_tabix OF STRUCTURE dy_table TO <dyn_field>.
ENDIF.
ENDLOOP.
ENDFORM. " PROC_DATA
Thanks and regards
Priyank -
Variable Columns Dispaying in ALV Report
Hi ,
I am working on ALV report . I am displaying 40 static fields and variable fields . Those varaible fields dependent on internal table . In the internal table 3 fields are available
if it contains 1 row then in report variable fields are 3 OR
if it contains 2 rows then in report variable fields are 6 OR
if it contains 3 rows then in report variable fields are 9 OR
if it contains n rows then in report variable fields are 3n.
Example : 1) Internal table have 3 fields sd_active , sd_close , sd_term .
Internal table is i_a936 , Work area w _a936 .
w_a936-sd_active = 'A1'.
w_a936-sd_close = 'B1'.
w_a936-sd_term = 'C1'.
append w_a936 to i_a936.
w_a936-sd_active = 'A2'.
w_a936-sd_close = 'B2'.
w_a936-sd_term = 'C2'.
append w_a936 to i_a936.
Then in final internal table it should display 6 columns like w_final-sd_Active1 ,w_final-sd_close1,w_final-sd_term1 , w_final-sd_Active2 ,w_final-sd_close2,w_final-sd_term2 . Columns in Internal table varies from i_a936 rows .
I am trying to use Dynamic internal table .
Regards
Srihari NerellaHi,
I think this may help you . Use CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
see the link
Dynamic fields to be displayed in ALV
Dynamic column change in Alv
Dynamic Number of Columns in ALV -
ALV column with variable number of decimals to be displayed
Hi,
I've an ALV where I need to display a numeric column with a variable number of decimal row-by-row, from 0 (no decimals) to 4.
I've declared the numeric field as TYPE P DECIMALS 4.
I've tried with DECMLFIELD in ALV catalog, and this works for 1 to n decimals, but when I leave the field indicated in DECMLFIELD equal to 0, ALV shows the default number of decimals of the field (4 in that case).
Any help will be very appreciated.
Thanks.
JordiNo, I didn't try EDIT_MASK.
How should I use it to format output to display decimals or not depending on the row?
I have 2 kinds of values, all stored in a TYPE P DECIMALS 4: Those that really are an integer (decimals should not be displayed for that ones) and the values that really have 4 decimals (which should be displayed with decimals in ALV).
Example:
13,0000 should be displayed as 13
0,4567 should be displayed as 0,4567
With EDIT_MASK could I do that?
Thank you very much. -
Variable company code in alv top of page
Dear Experts,
I have a report, in which selection screen having company code (bukrs), so based on company code, the company name should appear in the top of page in alv output. Please help me. highly appreciable for who are given the solution.
Moderator message : Spec dumping not allowed, show the work you have already done. Thread locked.
Edited by: Vinod Kumar on Feb 13, 2012 12:32 PMHi,
You can still create a table like this..
DATA: V_DATE TYPE CHAR2.
DATA: V_YEAR TYPE CHAR4.
DATA: V_MONTH TYPE CHAR2.
V_DATE = SY-DATUM+6(2).
V_MONTH = SY-DATUM+4(2).
V_YEAR = SY-DATUM+(4).
WRITE: / '----
WRITE: / '| YEAR | ', V_YEAR, ' |'.
WRITE: / '| MONTH | ', V_MONTH, ' |'.
WRITE: / '| DATE | ', V_DATE', ' |'.
WRITE: / '----
Thanks,
Naren
Maybe you are looking for
-
Need help in creating a sample application using Oracle I\PM 10gR3.
I am a new to Oracle I\PM 10gR3 and I need a guide to create a sample application using Filer and a sample Process. I have searched the net and was unable to find any documents. If any body has any kind of guide to create an application please let me
-
I can't figure out how to delete the blank page at the bottom of my spreadsheet.
I am new to Numbers and not very experienced in spreadsheets period. Anyway, I made a what is supposed to be a one page spreadsheet and it worked out fine but there is this second page that has about a half page worth of blank cells and I cant figure
-
Change the default row maximum in an Analysis report?
I'm using OBIEE 11.1.1.3 (and testing this on 11.1.1.5) and am curious how to change this setting: On all our Analysis reports we can view Rows 1 - 25 in the Results tab for the report. I want to change this so I can see more than 25 rows as my defau
-
Toshiba doesn't recognise laptop or tablet when using HDMI
I have a toshiba (Model#46G310U) and when try to connect a laptop or tablet using HDMI cable. It says no signal. But when i connect the laptop using VGA cable, it works. i want to know my Tv is compatible with tablet or laptop using HDMI cable or if
-
Slow video playback in Photoshop Elements 11
Playback of videos directly in Photoshop Elements Organizer is very slow. Video is stuttering. Playing the same video outside of PSE11 with Windows Media Player is much better. Video plays without any stuttering. Looks like the internal video player