Handling ALV Layout & Dynamic Columns
I have a custom report for Purchasing / Finance.
1) I create 5 dynamic columns for the purchase rder invoices based on the report run date.
Example:
Previous Quarter [Q4 2009] [Q1 2010] [Q2 2010] [Q3 2010]
My query is that this report has layouts defined. I want to add the dynamic columns to the report output.
Example: In the below scenario i have dynamic columns in the fieldcat[] but the report shows only the columns defined in the layout selected.
disvariant-VARIANT has the layout selected from the seelction screen of the report.
Also fieldcat-tabname = '<fs_table> '.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_variant = disvariant
i_save = 'A'
is_layout = layout
is_print = print
CHANGING
it_outtab = <fs_table>
it_fieldcatalog = fieldcat[]
it_sort = sort[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
Appreciate if anyone knows the solution.
I don't believe you can display the dynamic columns and still use the variant from the selection screen.
Have you considered using multiple table rows for the multiple time periods?
If you will always have 5 dynamic columns, maybe you can make them not dynamic and just make the column header text dynamic?
Similar Messages
-
ALV Display dynamic column with multiline header
Hi All.
I need to create alv display with dynamic number of columns. Also, it contains two header line. Kindly help me in coding.
The required format is this format.
Product | Week1 | Week2 |.......| WeekN
|--||---|--
| Sales | Sales |.......| Sales
|--| |---|--
PRD1 | value | Value |.......| Value
PRD2 | value | Value |.......| Value
PRD3 | value | Value |.......| Value
Thanks.
SadhnaHi Sadhana,
You mean to say that your internal Table contains
ABCDEF are the fields in your Internal table.
A--BCD---E-----F
1--12---13---a11----1
2--11---01---b9-----0
3--01---00---c32----0
4--14---01---d21----0
Now using Dynamic Internal Table it should display the output as follow :
A--BCF---a---b-c----d
1--12---13---111-9-32--21
Here you want to display the the fields of D as header and E as its corresponding values...?
Please let me knwo if you mean the same..
Regards,
Kittu -
ALV with dynamic columns and description labels in header titles
Hi everybody,
I have to implement an ALV whose columns are not defined until runtime. Is it possible to do that in some simple way? Is it necessary to use objects to define this kind of ALV's?
And another one query, is it possible to add description labels to column headers so that when the user points with the cursor in them he/she gets a little explanation about the detail of the column (for example, description name of the product hierarchy when pointing to the column named with one of the existing hierarchies, i.e 010102102)
Thanks in advance,for your first question check this
Just check this sample from one of the SAP site
ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
Applies To:
ABAP / ALV Grid
Article Summary
ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
Code Sample
REPORT zcdf_dynamic_table.
* Dynamic ALV Grid with Cell Coloring.
* Build a field catalog dynamically and provide the ability to color
* the cells.
* To test, copy this code to any program name and create screen 100
* as described in the comments. After the screen is displayed, hit
* enter to exit the screen.
* Tested in 4.6C and 6.20
* Charles Folwell - [email protected] - Feb 2, 2005
DATA:
r_dyn_table TYPE REF TO data,
r_wa_dyn_table TYPE REF TO data,
r_dock_ctnr TYPE REF TO cl_gui_docking_container,
r_alv_grid TYPE REF TO cl_gui_alv_grid,
t_fieldcat1 TYPE lvc_t_fcat, "with cell color
t_fieldcat2 TYPE lvc_t_fcat, "without cell color
wa_fieldcat LIKE LINE OF t_fieldcat1,
wa_cellcolors TYPE LINE OF lvc_t_scol,
wa_is_layout TYPE lvc_s_layo.
FIELD-SYMBOLS:
<t_dyn_table> TYPE STANDARD TABLE,
<wa_dyn_table> TYPE ANY,
<t_cellcolors> TYPE lvc_t_scol,
<w_field> TYPE ANY.
START-OF-SELECTION.
* Build field catalog based on your criteria.
wa_fieldcat-fieldname = 'FIELD1'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-coltext = 'My Field 1'.
wa_fieldcat-seltext = wa_fieldcat-coltext.
APPEND wa_fieldcat TO t_fieldcat1.
wa_fieldcat-fieldname = 'FIELD2'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-coltext = 'My Field 2'.
wa_fieldcat-seltext = wa_fieldcat-coltext.
APPEND wa_fieldcat TO t_fieldcat1.
* Before adding cell color table, save fieldcatalog to pass
* to ALV call. The ALV call needs a fieldcatalog without
* the internal table for cell coloring.
t_fieldcat2[] = t_fieldcat1[].
* Add cell color table.
* CALENDAR_TYPE is a structure in the dictionary with a
* field called COLTAB of type LVC_T_SCOL. You can use
* any structure and field that has the type LVC_T_SCOL.
wa_fieldcat-fieldname = 'T_CELLCOLORS'.
wa_fieldcat-ref_field = 'COLTAB'.
wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
APPEND wa_fieldcat TO t_fieldcat1.
* Create dynamic table including the internal table
* for cell coloring.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat1
IMPORTING
ep_table = r_dyn_table
EXCEPTIONS
generate_subpool_dir_full = 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.
* Get access to new table using field symbol.
ASSIGN r_dyn_table->* TO <t_dyn_table>.
* Create work area for new table.
CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
* Get access to new work area using field symbol.
ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
* Get data into table from somewhere. Field names are
* known at this point because field catalog is already
* built. Read field names from the field catalog or use
* COMPONENT <number> in a DO loop to access the fields. A
* simpler hard coded approach is used here.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'ABC'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'XYZ'.
APPEND <wa_dyn_table> TO <t_dyn_table>.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'TUV'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'DEF'.
APPEND <wa_dyn_table> TO <t_dyn_table>.
* Color cells based on your criteria. In this example, a test on
* FIELD2 is used to decide on color.
LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
* Get access to internal table used to color cells.
ASSIGN COMPONENT 'T_CELLCOLORS'
OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
CLEAR wa_cellcolors.
wa_cellcolors-fname = 'FIELD2'.
IF <w_field> = 'DEF'.
wa_cellcolors-color-col = '7'.
ELSE.
wa_cellcolors-color-col = '5'.
ENDIF.
APPEND wa_cellcolors TO <t_cellcolors>.
MODIFY <t_dyn_table> FROM <wa_dyn_table>.
ENDLOOP.
* Display screen. Define screen 100 as empty, with next screen
* set to 0 and flow logic of:
* PROCESS BEFORE OUTPUT.
* MODULE initialization.
* PROCESS AFTER INPUT.
CALL SCREEN 100.
* MODULE initialization OUTPUT
MODULE initialization OUTPUT.
* Set up for ALV display.
IF r_dock_ctnr IS INITIAL.
CREATE OBJECT r_dock_ctnr
EXPORTING
side = cl_gui_docking_container=>dock_at_left
ratio = '90'.
CREATE OBJECT r_alv_grid
EXPORTING i_parent = r_dock_ctnr.
* Set ALV controls for cell coloring table.
wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
* Display.
CALL METHOD r_alv_grid->set_table_for_first_display
EXPORTING
is_layout = wa_is_layout
CHANGING
it_outtab = <t_dyn_table>
it_fieldcatalog = t_fieldcat2.
ELSE. "grid already prepared
* Refresh display.
CALL METHOD r_alv_grid->refresh_table_display
EXPORTING
i_soft_refresh = ' '
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDMODULE. " initialization OUTPUT -
ALV with multiple header & dynamic columns
Hello All,
I have a requirement where in I need to print multiple header in alv.
For eg.
User Name : <Name_1>
Channel : <Channel_1>
Sale Org : <Sales Org_1>
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
User Name : <Name_2>
Channel : <Channel_2>
Sale Org : <Sales Org_2>
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
no of columns (Col1 , col2 ) are dynamic . Which would be the best alv type do I need do use? Is it possible using simple alv grid display. How to handle dynamic column.
Thnx.it is not possible with normal grid or list.
I guess it is possible by using ALV Block list
Modified below program to get mutiple header
REPORT z_alv_block_list.
Type-pools
TYPE-POOLS: slis.
Data declarations.
DATA: BEGIN OF t_vbak OCCURS 0,
vbeln TYPE vbeln,
bstnk TYPE vbak-bstnk,
erdat TYPE vbak-erdat,
kunnr TYPE vbak-kunnr,
END OF t_vbak.
DATA: BEGIN OF t_vbap OCCURS 0,
vbeln TYPE vbeln,
matnr TYPE vbap-matnr,
netpr TYPE vbap-netpr,
waerk TYPE vbap-waerk,
kwmeng TYPE vbap-kwmeng,
meins TYPE vbap-meins,
END OF t_vbap.
DATA: t_fieldcatalog1 TYPE slis_t_fieldcat_alv.
DATA: t_fieldcatalog2 TYPE slis_t_fieldcat_alv.
DATA: v_repid TYPE syrepid.
DATA: s_layout TYPE slis_layout_alv.
DATA: v_tabname TYPE slis_tabname.
DATA: t_events TYPE slis_t_event.
start-of-selection event.
START-OF-SELECTION.
v_repid = sy-repid.
Get the fieldcatalog for the first block
PERFORM get_fieldcat1 CHANGING t_fieldcatalog1.
Get the fieldcatalog for the second block
PERFORM get_fieldcat2 CHANGING t_fieldcatalog2.
Get the data for the first block
SELECT vbeln bstnk erdat kunnr UP TO 10 ROWS
INTO TABLE t_vbak
FROM vbak WHERE vbeln > '0060000100'.
Get the data for the second block
SELECT vbeln matnr netpr waerk kwmeng meins UP TO 10
ROWS
INTO TABLE t_vbap
FROM vbap WHERE vbeln > '0060000100'.
init
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid.
First block
v_tabname = 'ITAB1'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = s_layout
it_fieldcat = t_fieldcatalog1
i_tabname = v_tabname
it_events = t_events
TABLES
t_outtab = t_vbak.
Second block
v_tabname = 'ITAB2'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = s_layout
it_fieldcat = t_fieldcatalog2
i_tabname = v_tabname
it_events = t_events
TABLES
t_outtab = t_vbap.
*Display
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
FORM GET_FIELDCAT1
Get the field catalog for the first block
FORM get_fieldcat1 CHANGING lt_fieldcatalog TYPE
slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
Order number
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'VBELN'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Customer purchase order.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BSTNK'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'BSTNK'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Creation date.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'ERDAT'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Customer
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'KUNNR'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
ENDFORM.
FORM GET_FIELDCAT2
Get the field catalog for the second block
FORM get_fieldcat2 CHANGING lt_fieldcatalog TYPE
slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
Order number
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'VBELN'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Material number
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'MATNR'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Net price
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'NETPR'.
s_fieldcatalog-cfieldname = 'WAERK'.
s_fieldcatalog-ctabname = 'T_VBAP'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Currency.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'WAERK'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'WAERK'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Quantity
s_fieldcatalog-col_pos = '5'.
s_fieldcatalog-fieldname = 'KWMENG'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'KWMENG'.
s_fieldcatalog-qfieldname = 'MEINS'.
s_fieldcatalog-qtabname = 'T_VBAP'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
UOM
s_fieldcatalog-col_pos = '6'.
s_fieldcatalog-fieldname = 'MEINS'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'MEINS'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
ENDFORM. -
Hi Experts,
I save an ALV layout with some filtered columns. Now I would like to take the columns through program giving the variant name as input. I get variant info from LTDX table, but no the columns of ALV. Could u please tell me any FM to find out the columns or any table which stores those details?
Thanks and regards,
Venkat.Hi Venkat,
Now as you have the variant into some varaible. Pass this varaint name to FM 'LT_FC_LOAD' with IS_VARAINT = variant variable name, I_TABNAME = '1', and import your fields into the field catalog.
You will get the fields according to your variant.
Now after having fields in field catalog, you can easily create dynamic internal table from the same field catalog. -
halo fellow SAPiens,
i need to show dynamic columns for a particular material........the scenario is as follows....
1) there r 7 fixed columns describing the material...
2)when the material returns back to the plant for some reason , i need to insert a column which shows the date and reason(char) of return.
3)again after dispatching the material for some reason it comes back again a new column shld be displayed showin the date and reason(char).
4)if the material doesnt come back...the report shows only 7 columns.
any solution?try <a href="http://www.alvrobot.com.ar/home.php">here</a> ......its a useful tool for dealing with ALV
<b>reward points if useful</b> -
Hello friends,
Can any1 pls tell me if there is a function module available which can be used for dynamic column change in ALV.
Pls also elaborate how to use it.....While filling the field catalog you can specify witht IFcondition.
Just see a example below...
FORM field_fill USING pt_fieldcat TYPE slis_t_fieldcat_alv.
DATA : ls_fieldcat TYPE slis_fieldcat_alv,
pos TYPE i VALUE 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'C_ICON'.
ls_fieldcat-seltext_m = 'Change Status'.
ls_fieldcat-tabname = 'IT_OUTPUT'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'BUKRS'.
ls_fieldcat-ref_fieldname = 'BUKRS'.
ls_fieldcat-ref_tabname = 'ANLA'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'ANLN1'.
ls_fieldcat-ref_fieldname = 'ANLN1'.
ls_fieldcat-ref_tabname = 'ANLA'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'ANLN2'.
ls_fieldcat-ref_fieldname = 'ANLN2'.
ls_fieldcat-ref_tabname = 'ANLA'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
IF p_farea = 'X'. " Conditional Based OUTPUT
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'GRUFL'.
ls_fieldcat-ref_fieldname = 'GRUFL'.
ls_fieldcat-ref_tabname = 'ANLA'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'GRUFL_N'.
ls_fieldcat-seltext_l = 'New Floor Area'.
ls_fieldcat-tabname = 'IT_OUTPUT'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ENDIF.
IF p_ldate = 'X'. " Conditional Based OUTPUT
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'LEABG'.
ls_fieldcat-ref_fieldname = 'LEABG'.
ls_fieldcat-ref_tabname = 'ANLA'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'LEABG_N'.
ls_fieldcat-seltext_l = 'New Lease St.Date'.
ls_fieldcat-tabname = 'IT_OUTPUT'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ENDIF.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'MESSAGE'.
ls_fieldcat-seltext_l = 'Status Message'.
ls_fieldcat-tabname = 'IT_OUTPUT'.
APPEND ls_fieldcat TO pt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ENDFORM. " field_fill
Regards
Gopi -
Alle experts:
In ALV layout report, how to dynamic change the layout int ABAP porgram?
e.g. I have save 5 layout, I need to change them base the my selection in ABAP program? How to do this?
Thanks in advance!Try to call fieldcatlog dymnamically. Refer tofollowing code. Reward if helpful.
REPORT zfir0001 MESSAGE-ID ztax.
Tables
TABLES : glt0, t001, skat.
Internal Tables
DATA: BEGIN OF itab OCCURS 0,
racct LIKE glt0-racct, "Account number
txt20 LIKE skat-txt20, "G/L account short text
co_1000 LIKE glt0-hslvt, "Balance carried forward for company code 1000
co_1100 LIKE glt0-hslvt, "Balance carried forward for company code 1100
co_1200 LIKE glt0-hslvt, "Balance carried forward for company code 1200
DATA : BEGIN OF itab1 OCCURS 0,
bukrs LIKE glt0-bukrs,
waers LIKE t001-waers,
END OF itab1.
DATA : BEGIN OF it_itab1 OCCURS 0.
INCLUDE STRUCTURE glt0.
DATA : END OF it_itab1.
Data Declarations
DATA : w_total LIKE glt0-hslvt,
w_count LIKE glt0-bukrs,
w_flg TYPE c,
lv_count TYPE i.
w_slash TYPE c VALUE ' '.
Selection screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit1.
SELECT-OPTIONS : s_bukrs FOR glt0-bukrs OBLIGATORY,
s_racct FOR glt0-racct OBLIGATORY,
s_ryear FOR glt0-ryear OBLIGATORY,
s_rldnr FOR glt0-rldnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
tit1 = 'Please select:'(004).
TYPE-POOLS: slis. "ALV Declarations
DATA: i_fieldcat 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.
********Geting the selected company code in table itab1****
START-OF-SELECTION.
IF NOT s_bukrs-high IS INITIAL.
itab1-bukrs = s_bukrs-low.
APPEND itab1.
w_count = s_bukrs-low.
DO.
IF s_bukrs-high = w_count.
EXIT.
ELSE.
w_count = w_count + 1.
ENDIF.
SELECT SINGLE * FROM t001
WHERE bukrs = w_count.
IF sy-subrc = 0.
itab1-bukrs = w_count.
APPEND itab1.
CLEAR itab1.
ENDIF.
ENDDO.
ELSE.
itab1-bukrs = s_bukrs-low.
APPEND itab1.
ENDIF.
SELECT * FROM glt0 INTO CORRESPONDING FIELDS OF TABLE it_itab1
WHERE rldnr IN s_rldnr
AND bukrs IN s_bukrs
AND ryear IN s_ryear
AND racct IN s_racct.
SORT it_itab1 BY bukrs.
LOOP AT it_itab1.
AT END OF racct.
w_flg = 'X'.
ENDAT.
SELECT SINGLE txt20 INTO (itab-txt20) FROM skat
WHERE spras = sy-langu
AND saknr = it_itab1-racct.
PACK it_itab1-racct TO it_itab1-racct.
itab-racct = it_itab1-racct.
w_total = it_itab1-hsl01 + it_itab1-hsl02 + it_itab1-hsl03 + it_itab1-hsl04 +
it_itab1-hsl05 + it_itab1-hsl06 + it_itab1-hsl07 + it_itab1-hsl08 +
it_itab1-hsl09 + it_itab1-hsl10 + it_itab1-hsl11 + it_itab1-hsl12 +
w_total + it_itab1-hslvt.
IF w_flg = 'X'.
READ TABLE itab1 WITH KEY bukrs = it_itab1-bukrs.
IF sy-subrc = 0.
SELECT SINGLE * FROM t001
WHERE bukrs = itab1-bukrs.
IF t001-waers = 'JPY' OR
t001-waers = 'HUF'.
w_total = w_total * 100.
ENDIF.
CASE it_itab1-bukrs.
WHEN '1000'.
itab-co_1000 = w_total.
WHEN '1100'.
itab-co_1100 = w_total.
WHEN '1200'.
itab-co_1200 = w_total.
ENDCASE.
COLLECT itab.
CLEAR: itab, w_flg, w_total.
ENDIF.
ENDIF.
ENDLOOP.
SORT itab BY racct.
IF NOT itab[] IS INITIAL.
PERFORM field_cat1.
lv_count = 1.
LOOP AT itab1.
PERFORM field_cat USING itab1-bukrs.
ENDLOOP.
PERFORM display_alv_report .
ELSE.
MESSAGE s000 WITH 'No records Found'(003).
ENDIF.
*& Form display_alv_report
text
FORM display_alv_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = i_fieldcat[]
i_save = 'X'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_alv_report
*& Form field_cat1
text
FORM field_cat1 .
i_fieldcat-col_pos = 0.
i_fieldcat-fieldname = 'RACCT'.
i_fieldcat-seltext_m = 'Account'(001).
i_fieldcat-fix_column = 'X'.
i_fieldcat-emphasize = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-col_pos = 1.
i_fieldcat-fieldname = 'TXT20'.
i_fieldcat-seltext_m = 'Description'(002).
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
ENDFORM. "field_cat1
*& Form field_cat
text
-->XV_BURKS text
FORM field_cat USING xv_burks TYPE char4.
lv_count = lv_count + 1.
i_fieldcat-col_pos = lv_count.
CONCATENATE 'CO_' xv_burks INTO i_fieldcat-fieldname.
i_fieldcat-seltext_m = xv_burks.
i_fieldcat-just = 'C'.
i_fieldcat-no_zero = 'X'.
i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
ENDFORM. "field_cat
Edited by: dhanashree wadkar on Apr 30, 2008 6:00 AM -
Difficult to achive the report layout with dynamic column names
I have a report layout as below.
So here the column names are dynamic.And each fixed row group has different calculations. I have a date parameter. If I select July 2013, then I need to show data from July 2012 to July 2013 with Columns(Jul-12, Aug-12...Jul-13). How to achive below layout
with dynamic columns?Hi Sarayu_CM,
According to your description, you want to filter the records of prior year based on only one parameter selection. Right?
In this scenario, we can create two parameters. The first one is for user to select. The second parameter is based on the first parameter selection. We don't need to specify Available Values for the second parameter, but we should use expression to specify
Default Values based on the first parameter selection. Use the expression below:
=DateAdd("m",-12,FormatDateTime(Parameters!param1.Value))
Then we just need to apply a filter on the matrix/dataset to get the records which the date is between values in these two parameters.
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
How to find all the columns in an ALV Layout?
Hi all
Here's what I need to do. When I run a program (with ALV output in online mode) in the background mode, I need to save the data to a file. And this file is supposed to contain only those columns in a specified ALV Layout.
Any suggestion how to achieve this?
Thank you so much!!!hi,
u are appending to a field catlog.
eg:
int_fieldcatalog-fieldname = 'CHECT'.
int_fieldcatalog-seltext_m = 'Check No'.
int_fieldcatalog-col_pos = 0.
int_fieldcatalog-outputlen = 13.
int_fieldcatalog-emphasize = 'X'.
int_fieldcatalog-key = 'X'.
APPEND int_fieldcatalog TO int_fieldcatalog.
CLEAR int_fieldcatalog.
so chk this int_fieldcatalog internal table.
it will containthe field in the field in the ALV display.
rgds
anver -
Dragging one cell value(copy) across columns or across rows in ALV layout
Hi friends,
In bps layouts, data is displayed in ALV grid as interface. At plng folder level, can i incorporate excel feature like dragging one cell value across columns or across rows? Simply if user enter one value in cell of ALV grid, that should be copied automatically across rows/columns while dragging?
Second question, even i chose in layout builder excel as interface, that layout showed in plng folder as ALV grid layout. Why it happens so. I read documentation in UPSPM of that particular plng folder, it tells same thing(even if u choose excel, it will show in ALV only). So how can i get excel interface in plng folder?
Regards,
Kumarrequested property is not possible at ALV layout level. Provided text document load facility to user. So user can directly load excel to plng folder.
Issue resolved. -
Generating dynamic column in planning layout
Hi Guys,
I am new to BPS.. My task is user inputs calendar year thru variable, based on the year it has generate dynamic columns as month of the year entered by the user.
Dnt know i am right or wrong based on the sdn threads. i think i have to create user input variable, and create a FM to read the user input value. Upto to this i can understand, after reading the user input how to calculate the months and generate 12 columns dynamically for each month...
Kindly help me in this scenario..
Edited by: kevin peterson on Jun 6, 2008 5:23 AMHi,
I hope you are using calendar year/month and calendar year characteristics. Create an user input variable for calendar year,
create one exit variable for calendar year month.
Inside this exit, read the value of the user input variable, append the year with all 12 months, so u get 12values for this exit variable.
Now keep calendar year in header, restricted by user input variable, create one data column dynamic for calendar year month restricted by this exit variable. This will generate 12columns dynamically.
Bindu -
Dynamic ALV Layout - Immediate help required
I have a Summary and a Detailed ALV layout screen. Now when i get to detailed screen from summary screen; I choose a layout say L1 here. Then I press F3(back) this would get me back to the summary screen.Now my requirement is when i click on detailed view from here now; the previously chosen layout L1 needs to be used for the report output. Can this be done?
Note : This needs to be done without choosing layout from selection screen.
Require help urgently on this.
Regards
SwamyYes you can do that.
When you are backing out of detailed screen, store the name of the layout in a variable. When you are coming in the detailed screen again, pass this layout name in the IS_VARIANT-LAYOUT variable along with other values.
Before backing out of the detailed screen you can get the layout chosen using the function REUSE_ALV_GRID_LAYOUT_INFO_GET or calling the method GET_FRONTEND_LAYOUT of the class CL_GUI_ALV_GRID, depending on how you are displaying the report.
Regards,
Ravi
Note - Please mark all the helpful answers -
How to create alv table dynamically by performing action on the button.
Hi all,
my requirement is to create alv table dynamically.
that is i will create two buttons
1) show alv table
2) close alv table
if user selects show alv table then the alv table should be displayed.
and if user selects clsoe alv table then the alv table should be closed.
to create alv table dynamically i have followed this procedure.
under view properties i have added salv_wd_table component. then under the action of showalvbutton i went to code wizard and i have selected instantiate used component component use salv_wd_table. the following code will be generated
with this code i am unable to display alv table dynamically correct me where i went wrong kindly send me the necessary steps how to create alv table dynamically
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
to close table i have used the following code. with this code i am able to achieve the functionality to delete the alv table
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).
if lo_cmp_usage->has_active_component( ) is initial.
else.
lo_cmp_usage->Delete_component( ).
endif.
Thanks & Regards,
Naveen
Edited by: naveen.webhelp on Feb 10, 2011 5:52 AMHi
ALV table will be shown in the viewcontainerUI element.
it is shown there empty if you dont fill the node bound to the data node of the interface controller of the comp usage
SALV_WD_TABLE.
and if you are not getting the table filled in the first place.
then check have you mapped the DATA node to some node in the comp controller
wht basically is your requirment is that you want to show ALV gird on click of one button and delete it on click of other button.
there are many ways to do so.
best way is control the visiblity of the viewcontainer UI element which containes the TABLE view of SALV_WD_table comp.
create an attribute of type WDUI_VISIBILITY name say VIS.
now go to the layout and bound hte visible property of the viewcontainer to this attribute VIS.
then in the showalv grid button's eventhandler write
wd_context->set_attribute(
name = 'VIS'
value = '02'
and in the wddoinit and delete alv grid button's event handler write
wd_context->set_attribute(
name = 'VIS'
value = '01'
thanks
sarbjeet singh -
ALV layout variant missing in background job.
hi guys,
Having problem on getting the default ALV layout variant when run the job in backgorund. Please advise any correction needed in the following code.
Thanks.
*& Include Z_MM_KBR_AGSUBCONINV_MOD2 *
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR '100'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module display_data OUTPUT
text
MODULE display_data OUTPUT.
IF sy-batch IS INITIAL. "Foreground
IF w_container IS INITIAL.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
*Creating the container
CREATE OBJECT w_container
EXPORTING
container_name = c_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
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.
*Creating the ALV GRID
CREATE OBJECT w_grid
EXPORTING
i_parent = w_container
i_appl_events = c_check
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
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.
exit.
ENDIF.
ELSE.
*Creating the ALV GRID
CREATE OBJECT w_grid
EXPORTING
i_parent = go_dock_container
i_appl_events = c_check
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
WRITE:/ 'Error in grid'.
ENDIF.
CREATE OBJECT w_grid
EXPORTING i_parent = go_dock_container.
ENDIF.
*getting the variant option
wa_variant-report = sy-repid.
wa_variant-username = sy-uname.
wa_layout-grid_title = sy-title.
wa_layout-cwidth_opt = c_check.
wa_layout-zebra = c_check.
wa_layout-no_f4 = c_check.
wa_layout-sel_mode = 'D'.
*Excluding the unwanted buttons
PERFORM exclude_toolbar_buttons.
build field catalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = c_check
i_structure_name = c_fcat_str
i_bypassing_buffer = c_check
CHANGING
ct_fieldcat = t_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
loop at t_fieldcat into w_fieldcat.
if w_fieldcat-FIELDNAME = 'AGING1'.
W_FIELDCAT-NO_ZERO = 'X'.
MODIFY t_fieldcat FROM W_FIELDCAT INDEX SY-TABIX.
ENDIF.
endloop.
Generate sort critria
PERFORM generate_sort.
Create object of class lcl_event_receiver.
CREATE OBJECT w_event.
Handler for events.
SET HANDLER w_event->handle_top_of_page FOR w_grid.
SET HANDLER w_event->handle_print_top_of_page FOR w_grid.
SET HANDLER w_event->handle_print_end_of_list FOR w_grid.
SET HANDLER w_event->handle_hotspot_click FOR w_grid.
*Displaying the alv
IF NOT sy-batch IS INITIAL.
PERFORM create_snp.
ENDIF.
t_data = i_final.
CALL METHOD w_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = wa_layout
is_variant = wa_variant
CHANGING
it_outtab = t_data
it_fieldcatalog = t_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE. " display_data OUTPUT
*& Module user_command_0100 INPUT
text
MODULE user_command_0100 INPUT.
DATA: lt_rows TYPE lvc_t_row,
w_rows TYPE lvc_s_row.
CASE sy-ucomm.
WHEN c_back.
LEAVE TO SCREEN 0.
WHEN c_exit.
LEAVE TO SCREEN 0.
WHEN c_cancel.
LEAVE TO SCREEN 0.
WHEN 'BILDET'.
CALL METHOD w_grid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc EQ 0.
READ TABLE lt_rows INTO w_rows INDEX 1.
READ TABLE i_vbfa INTO w_vbfa INDEX w_rows-index.
IF sy-subrc EQ 0.
CLEAR i_zbw_br_nf4.
LOOP AT i_zbw_br_nf3 INTO w_zbw_br_nf3 WHERE
refkey = w_vbfa-v_vbeln.
APPEND w_zbw_br_nf3 TO i_zbw_br_nf4.
ENDLOOP.
call dialog screen and display new alv control
CALL SCREEN 101 STARTING AT 10 5.
ENDIF.
ENDIF.
WHEN 'NOTAF'.
CALL METHOD w_grid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc EQ 0.
READ TABLE lt_rows INTO w_rows INDEX 1.
READ TABLE i_zbw_br_nf3 INTO w_zbw_br_nf3 INDEX w_rows-index.
DATA docnum LIKE j_1bdydoc-docnum.
docnum = w_zbw_br_nf3-docnum.
SET PARAMETER ID 'JEF' FIELD docnum.
CALL TRANSACTION 'J1B3N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDMODULE. " user_command_0100 INPUT
*& Form modify_col_name
text
-->P_<FCAT> text
-->P_TEXT_H01 text
FORM modify_col_name USING pwa_fcat TYPE lvc_s_fcat
value(pw_text) TYPE any.
pwa_fcat-coltext = pw_text.
pwa_fcat-scrtext_l = pw_text.
pwa_fcat-scrtext_m = pw_text.
pwa_fcat-scrtext_s = pw_text.
ENDFORM. " modify_col_name
FORM display_hotspot *
FORM display_hotspot USING pw_row_id TYPE lvc_s_row
pw_column_id TYPE lvc_s_col.
FIELD-SYMBOLS <l_data> TYPE zbrforecast.
READ TABLE t_br_nf_acum ASSIGNING <l_data> INDEX pw_row_id-index.
CHECK sy-subrc = 0.
IF pw_column_id = ' '.
ENDIF.
ENDFORM. "display_hotspot
*& Form generate_sort
Genereate Sort criteria
FORM generate_sort.
Local variables
DATA: wal_sort TYPE lvc_s_sort,
wl_pos TYPE numc2.
wl_pos = 01.
sort ORDER
wal_sort-spos = wl_pos.
wal_sort-fieldname = c_aufnr.
wal_sort-up = c_check.
APPEND wal_sort TO t_sort.
ENDFORM. "generate_sort
*& Form f4_variant
text
<--PW_VARI text
FORM f4_variant CHANGING pw_vari TYPE disvariant-variant.
wa_variant-report = sy-cprog.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = wa_variant
i_save = c_u
IMPORTING
es_variant = wa_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc IS INITIAL.
pw_vari = wa_variant-variant.
ELSE.
MESSAGE s208(00) WITH text-t04.
ENDIF.
ENDFORM. " f4_variant
*& Form validate_layout
*This subroutine is to validate the layout
No parameters are passed to this subroutine
FORM validate_layout.
IF NOT p_layout IS INITIAL.
Check Layout
wa_variant-report = sy-repid.
wa_variant-username = sy-uname.
wa_variant-variant = p_layout.
CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK'
EXPORTING
i_save = c_u
CHANGING
cs_variant = wa_variant
EXCEPTIONS
OTHERS = 01.
IF NOT sy-subrc IS INITIAL.
SET CURSOR FIELD 'P_LAYOUT'.
MESSAGE s001(00) WITH text-t06 p_layout.
STOP.
ENDIF.
ELSE.
clear wa_variant.
ENDIF.
ENDFORM. " validate_layout
*& Form validate_data
text
FORM validate_data .
PERFORM validate_layout.
ENDFORM. " validate_dataHi,
Before the call to method set_table_for_first_display, populate
wa_variant-report = sy-repid.
Best regards,
Prashant
Maybe you are looking for
-
Ricoh mp c3001 not printing in color after upgrading to yosemite
After upgrading to Yosemite, not able to print in color to a Ricoh MP C3001 on the network.
-
Replicat Abendend on mapping tables
Hello all, I´m having oracle goldengate 11.2.1.0.1 with uni-directional replication, running on RHEL 5.3 64bits and Oracle Database 11.2.0.3.0 on both nodes. Worked properly for a few weeks and today, the replication process abended with this error m
-
Load data warehouse from non-Oracle database
Hi I need to load a data warehouse (in a Oracle database 8.1.6) using Post Gree database tables. The question is: Oracle Warehouse Builder can identify this database like a source module? Or is better I generate txt files from Post Gree tables, load
-
Adobe form development using WD ABAP
Hi, I am a begineer to ABAP PDF Form development. Anyone could help me to develop Adobe interactive forms (online and offline cases) using ABAP WebDynpro. I would need step by step procedures to develop quickly. I have found the material mostly relat
-
Miracast not working on BDX5400KU with Surface Pro win 8.1
I have attempeted use the wireless display on the the surface with the toshiba BDX5400 but I cannot connect because the Surface indicates that I need to press a button on the Toshiba, which I believe is some sort of WPS requirement, but the Toshiba d