Dynamic columns in report... NON ALV REPORT
Hey Guys,
I have a internal table which has abt 50 columns now i wanna show only the columns that have any value in it...
Now this is not an ALV report... this is a basic report....
So anyideas as to where i can start on this.... i dont want to write if conditions...
i am tryin to make this as elegent as possible...
all help will be appreciated
Thanks
Hi,
Try this..
In this example..I have an internal table with the columns MATNR, WERKS, LGORT & MENGE...The ITAB is having value only for matnr and werks..It will print only MATNR and WERKS in the output..
<b>* Data declarations.</b>
DATA: BEGIN OF itab OCCURS 0,
matnr TYPE matnr,
werks TYPE werks_d,
lgort TYPE mard-lgort,
menge TYPE ekpo-menge,
END OF itab.
DATA: BEGIN OF itab_desc OCCURS 0,
compname(30),
text(20),
END OF itab_desc.
DATA: v_repid TYPE syrepid.
DATA: t_comp LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS: <fs>.
DATA: t_allowed_fields(30) OCCURS 0 WITH HEADER LINE.
<b>* Program.</b>
v_repid = sy-repid.
<b>* Sample data.</b>
itab-matnr = 'TEST'. itab-lgort = '0001'.APPEND itab.
itab-matnr = 'TEST12'. itab-lgort = '0001'.APPEND itab.
itab-matnr = 'TEST123'.itab-lgort = '0001'.APPEND itab.
<b>* Store the columns texts.</b>
itab_desc-compname = 'MATNR'. itab_desc-text = 'Material'.
APPEND itab_desc.
itab_desc-compname = 'WERKS'. itab_desc-text = 'Plant'.
APPEND itab_desc.
itab_desc-compname = 'LGORT'. itab_desc-text = 'Sto. Loc'.
APPEND itab_desc.
itab_desc-compname = 'MENGE'. itab_desc-text = 'Quantity'.
APPEND itab_desc.
<b>* Get the components for that internal table.</b>
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = v_repid
fieldname = 'ITAB'
TABLES
components = t_comp.
<b>* Get the columns that has some value.</b>
LOOP AT t_comp.
LOOP AT itab.
ASSIGN COMPONENT t_comp-compname OF STRUCTURE itab TO <fs>.
IF NOT <fs> IS INITIAL.
EXIT.
ENDIF.
ENDLOOP.
Allowed columns.
IF NOT <fs> IS INITIAL.
t_allowed_fields = t_comp-compname.
APPEND t_allowed_fields.
ENDIF.
ENDLOOP.
<b>* Print the Header.</b>
LOOP AT t_allowed_fields.
READ TABLE t_comp WITH KEY compname = t_allowed_fields.
READ TABLE itab_desc WITH KEY compname = t_allowed_fields.
WRITE: AT (t_comp-olen) itab_desc-text COLOR COL_HEADING.
ENDLOOP.
<b>* Print the data.</b>
LOOP AT itab.
WRITE: / space.
LOOP AT t_allowed_fields.
READ TABLE t_comp WITH KEY compname = t_allowed_fields.
ASSIGN COMPONENT t_comp-compname OF STRUCTURE itab TO <fs>.
WRITE: AT (t_comp-olen) <fs>.
ENDLOOP.
ENDLOOP.
Thanks,
Naren
Similar Messages
-
How many lines we can print using Non-alv report list ?
Hi Experts,
How many lines we can print using Non-alv report list ?
regards
vishnuHi,
It depends on the page size according to the page size we can set the no. of lines as follows,
REPORT program_name NO STANDARD PAGE HEADING
LINE-SIZE 290
LINE-COUNT 65.
Hope it helps you,
Regards,
Abhijit G. Borkar -
Lowercase first letter in column name of non-interactive report..Again
A couple of days ago a posted a question on how to make the column name in a non-interactive report
come out as lowercase. (original post: Lowercase first letter in column name of non-interactive report
I am using Theme13, which is probably the only theme that forces the first letter
of a column name in a report to uppercase.
Anyway, I received several responses including the answer which I applied to my page.
Then I went back to make the column sortable and that negates the CSS override and
the first letter in the column name is back to uppercase...arrrggghhh!
Are there any further suggestions on how to force this to lowercase with theme 13 and a sortable column?
Thanks
DonnaHi,
Try style to page HTML header
th.t13ReportHeader,th.t13ReportHeader a:link,th.t13ReportHeader a:visited{
text-transform:none!important;
}Br,Jari
Edited by: jarola on Feb 4, 2010 8:00 PM -
Can we control Font and Font size in Non-alv report list ?
Hi Experts,
Can we control Font and Font size in Non-alv report list ?
Regards
vishnuHi,
see if this is useful to you,
PRINT-CONTROL SIZE 2 COLOR BLACK FONT 5.
you can go through this link,
http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba62335c111d1829f0000e829fbfe/frameset.htm
Regards,
Abhijit G. Borkar -
Normal report and ALV report, where exactly both are differs?
For Normal report and ALV report, where exactly both are differs, I mean from which part the process / coding will differ, pls le me know..?
Akshitha.Hi Akshitha,
In Normal reports we use formatting techniques to display the report list. We define heading and size everything to display report list. But where as in alv we need not to use any formating there are some function modules which will automatically display output list in LIST and GRID format.
In Normal report we cannot make changes to the output list where in ALV report we can change the ALV output display dynamically. You can find lots of options for the ALV list such as you can download output list into Excel sheet and Sorting options Acending and decending order in ALV but in normal report We need to write syntax in the report to display output list in sorting order. The ALV report is very easy way to display the output compared to Ordinary report.
Check below some links which will help you to understand about ALV. If you know about Normal report you can campare by userself the difference.
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
<b>Please Reward if useful<b>
Regards,
sunil kairam. -
Hi experts,
How to convert an interactive report to ALV report..plz suggest me an example...
thanks in advance,
Varsha.hi varsha,
chk this link.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm
you will get good idea.
use this FM.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
I_callback_user_command = 'USER_COMMAND'
is_layout = gd_layout
it_fieldcat = fieldcatalog[] "create a field catlog.
i_save = 'X'
tables
t_outtab = it_tab "pass the final internal table.
exceptions
program_error = 1
others = 2.
Regards
Anver -
Hi Techies,
I need to display data like the following way :
Material | Quotation : | 6000000019 | 6000000020
Sh. Text | Bidder : | 1210003 | 1210004
Qty in Base Unit | Name : | vendor 1 | vendor 5
96 | Discount
material 1 | freight
10 g | Packing and Forward
| Vat 10%
Like this way I have to generate the Report for any Number of Vendors. Presently my client is having 10 Vendors... This Report possible may be in Normal Report or it may be in ALV Report?...... How can I acieve the above report
Thanks in Advance
Muralikrishna
Edited by: muralipsharma on Aug 17, 2010 12:55 PM
Moderator message: "spec dumping", please work yourself first on your requirement.
Moderator message: second time I have to lock this, don't try again!
locked by: Thomas Zloch on Aug 17, 2010 5:50 PMHi,
If you want to display the output like this. Then, you need to display it using 'Write' statements.
ALV list/Grid will not be useful for this.
Thanks,
Archana -
Lowercase first letter in column name of non-interactive report
I have a report from this query:
SELECT DISTINCT
v.isotope, v.location,
v.activity_in_ucuries as "uCi"
FROM inventory v
where v.location = 'IN PROCESS'
and v.activity_in_ucuries > 0
Note 'as "uCi"' - when the report displays the lowercase u is displayed as an uppercase U
In the column attributes , I have set the column heading as lowercase. In the report attributes I have Heading Type set as custom
and the column heading shows lowercase. I have also tried using the a heading type of Column Names. With all of these changes the
report still comes out with an uppercase U.
Is there a way to prevent the automatic set of the first letter to Uppercase or alternatively, force the first letter to lowercase?
Thanks
DonnaI am using theme 13. I don't have any experience changing the templates, so the report template has the following in Column Headings:
<th#ALIGNMENT# id="#COLUMN_HEADER_NAME#" class="t13ReportHeader">#COLUMN_HEADER#</th>
Can I make a change in here to prevent the transformation of the 1st character to uppercase? (I would also love to change the u to mu!)
I do have a test application in theme 3 that seems to preserve whatever case I enter it in...I suppose I can change themes, but I would like to stick with theme 13 if possible.
Thanks for any additional help.
Donna -
How to make column editable in Normal ALV report
Hi experts,
I Have one push button In ALV tool bar like Fields to be change..when i click this..i need to get one pop up with all fields which is having in Filedcatalog..so i need to doule click on any field which i want to be midified..then in ALV that particular entire column should be editable.Can anybody please help me what is procedure to get pop up with fields..
Thanks & regards,
Veena..here is the required code
type-pools: slis.
types: BEGIN OF TY_MKPF,
MBLNR TYPE MKPF-MBLNR,
MJAHR TYPE MKPF-MJAHR,
VGART TYPE MKPF-VGART,
BLART TYPE MKPF-BLART,
BLAUM TYPE MKPF-BLAUM,
END OF TY_MKPF.
TYPES: BEGIN OF TY_WA, "STRUCTURE FOR POP UP ALV
CHECK TYPE C,
FIELDNAME TYPE DFIES-FIELDNAME,
FIELDTEXT TYPE DFIES-FIELDTEXT,
END OF TY_WA.
data: lt_mkpf type table of ty_mkpf,
ls_mkpf type mkpf,
IT TYPE TABLE OF TY_WA, "INTERNAL TABLE FOR POP UP ALV
WA TYPE TY_WA, "WA FOR POP UP ALV
IT_FCATP TYPE SLIS_T_FIELDCAT_ALV, "FCAT FOR POP UP ALV
WA_FCATP LIKE LINE OF IT_FCATP, "WA FOR POP UP ALV
ok_code type sy-ucomm,
lt_fcat type lvc_t_fcat,
ls_fcat type lvc_s_fcat.
data: o_alv type ref to cl_gui_alv_grid,
o_doc type ref to cl_gui_docking_container.
start-of-selection.
select MBLNR
MJAHR
VGART
BLART
BLAUM
into corresponding fields of table lt_mkpf from mkpf up to 100 rows.
*---create fieldcatalog
clear ls_fcat.
ls_FCAT-FIELDNAME = 'MBLNR'.
*WA_FCAT-TABNAME = WA-TABNAME.
ls_FCAT-REF_TABLE = 'MPKPF'.
ls_FCAT-REF_FIELD = 'MBLNR'.
APPEND ls_FCAT TO lT_FCAT.
clear ls_fcat.
ls_FCAT-FIELDNAME = 'MJAHR'.
*WA_FCAT-TABNAME = WA-TABNAME.
ls_FCAT-REF_TABLE = 'MPKPF'.
ls_FCAT-REF_FIELD = 'MJAHR'.
APPEND ls_FCAT TO lT_FCAT.
clear ls_fcat.
ls_FCAT-FIELDNAME = 'VGART'.
*WA_FCAT-TABNAME = WA-TABNAME.
ls_FCAT-REF_TABLE = 'MPKPF'.
ls_FCAT-REF_FIELD = 'VGART'.
APPEND ls_FCAT TO lT_FCAT.
clear ls_fcat.
ls_FCAT-FIELDNAME = 'BLART'.
*WA_FCAT-TABNAME = WA-TABNAME.
ls_FCAT-REF_TABLE = 'MPKPF'.
ls_FCAT-REF_FIELD = 'BLART'.
APPEND ls_FCAT TO lT_FCAT.
clear ls_fcat.
ls_FCAT-FIELDNAME = 'BLAUM'.
*WA_FCAT-TABNAME = WA-TABNAME.
ls_FCAT-REF_TABLE = 'MPKPF'.
ls_FCAT-REF_FIELD = 'BLAUM'.
APPEND ls_FCAT TO lT_FCAT.
*---collect the field names of alv in a itab
clear wa.
WA-FIELDNAME = 'MBLNR'.
WA-FIELDTEXT = 'Number of Material Document'.
APPEND WA TO IT.
clear wa.
WA-FIELDNAME = 'MJAHR'.
WA-FIELDTEXT = 'fiscical year'.
APPEND WA TO IT.
clear wa.
WA-FIELDNAME = 'VGART'.
WA-FIELDTEXT = 'Transaction/Event Type'.
APPEND WA TO IT.
clear wa.
WA-FIELDNAME = 'BLART'.
WA-FIELDTEXT = 'Document Type'.
APPEND WA TO IT.
clear wa.
WA-FIELDNAME = 'BLAUM'.
WA-FIELDTEXT = 'Document type of revaluation document'.
APPEND WA TO IT.
*----------create field catalog
CLEAR WA_FCATP.
WA_FCATP-FIELDNAME = 'CHECK'.
WA_FCATP-SELTEXT_M = 'Selection Field'.
WA_FCATP-TABNAME = 'IT'.
APPEND WA_FCATP TO IT_FCATP.
CLEAR WA_FCATP.
WA_FCATP-FIELDNAME = 'FIELDNAME'.
WA_FCATP-TABNAME = 'IT'.
WA_FCATP-REF_TABNAME = 'DFIES'. "CHECK IN SE11 TYPE GROUP SLIS
WA_FCATP-REF_FIELDNAME = 'FIELDNAME'. "CHECK IN SE11 TYPE GROUPB u201CSLIS
APPEND WA_FCATP TO IT_FCATP.
CLEAR WA_FCATP.
WA_FCATP-FIELDNAME = 'FIELDTEXT'.
WA_FCATP-TABNAME = 'IT'.
WA_FCATP-REF_TABNAME = 'DFIES'. "CHECK IN SE11 TYPE GROUP SLIS
WA_FCATP-REF_FIELDNAME = 'FIELDNAME'. "CHECK IN SE11 TYPE GROUPB SLIS
APPEND WA_FCATP TO IT_FCATP.
CLEAR WA_FCATP.
call screen 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
* SET TITLEBAR 'xxx'.
if o_doc is not bound.
CREATE OBJECT O_DOC
EXPORTING
RATIO = 95.
CREATE OBJECT O_ALV
EXPORTING
I_PARENT = o_doc.
endif.
CALL METHOD O_ALV->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = lt_mkpf
IT_FIELDCATALOG = lt_fcat.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'BACK'.
CLEAR :O_ALV,
O_DOC.
LEAVE TO SCREEN 0.
when 'CHNG'.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'select fields to make it editable'
I_ZEBRA = 'X'
I_CHECKBOX_FIELDNAME = 'CHECK'
I_TABNAME = 'IT'
IT_FIELDCAT = IT_FCATP
TABLES
T_OUTTAB = it.
loop at it into wa where check = 'X'.
*---change fieldcatalog dynamacally
case wa-fieldname.
when 'MBLNR'.
read table lt_fcat into ls_fcat with key fieldname = wa-fieldname.
if sy-subrc = 0.
ls_fcat-edit = 'X'.
endif.
when 'MJAHR'.
read table lt_fcat into ls_fcat with key fieldname = wa-fieldname.
if sy-subrc = 0.
ls_fcat-edit = 'X'.
endif.
when 'VGART'.
read table lt_fcat into ls_fcat with key fieldname = wa-fieldname.
if sy-subrc = 0.
ls_fcat-edit = 'X'.
endif.
when 'BLART'.
read table lt_fcat into ls_fcat with key fieldname = wa-fieldname.
if sy-subrc = 0.
ls_fcat-edit = 'X'.
endif.
when 'BLAUM'.
read table lt_fcat into ls_fcat with key fieldname = wa-fieldname.
if sy-subrc = 0.
ls_fcat-edit = 'X'.
endif.
endcase.
modify lt_fcat from ls_fcat index sy-tabix transporting edit.
clear ls_fcat.
endloop.
*---change fieldcatalog dynamically
CALL METHOD O_ALV->SET_FRONTEND_FIELDCATALOG
EXPORTING
IT_FIELDCATALOG = lt_fcat
*CALL METHOD O_ALV->REFRESH_TABLE_DISPLAY
** EXPORTING
** IS_STABLE =
** I_SOFT_REFRESH =
** EXCEPTIONS
** FINISHED = 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.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Edited by: zjason on Dec 29, 2010 7:47 AM
Edited by: zjason on Dec 29, 2010 7:52 AM
Edited by: zjason on Dec 29, 2010 7:54 AM -
Show normal report or alv report for the radiobutton that was selected
Hello... i'm a begginer on Abap, so I hope to writly espose my question...
I'm trying to modifie an report i have to, when the user choose the values for selection, he also can choose if the output is shown as a normal view or as an alv. I want to do it by using radiobuttons, but I don´t no how to organise my code for the selected radiobutton...
ThanksHi,
Copy and paste this code. undestand the logic.
TABLES: vbrp.
TYPE-POOLS: slis.
TYPES: BEGIN OF gs_vbrp,
vbeln TYPE vbrp-vbeln, "sales order
matnr TYPE vbrp-matnr, "material no
arktx TYPE vbrp-arktx, "material description
ntgew TYPE vbrp-ntgew, "quantity
gewei TYPE vbrp-gewei, "quantity unit
netwr TYPE vbrp-netwr, "currency
werks TYPE vbrp-werks, "plant
END OF gs_vbrp.
DATA: it_vbrp TYPE STANDARD TABLE OF gs_vbrp,
wa_vbrp TYPE gs_vbrp.
DATA: fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv.
DATA: lyout TYPE slis_layout_alv,
event TYPE slis_t_event,
wa_event TYPE slis_alv_event.
select-options: s_vbeln for vbrp-vbeln.
parameters: p_alv type c radiobutton group AA,
P_NORMAL TYPE C RADIOBUTTON GROUP AA.
SELECT vbeln
matnr
arktx
ntgew
gewei
netwr
werks
FROM vbrp
INTO TABLE it_vbrp
FOR ALL ENTRIES IN IT_VBRP
WHERE vbeln EQ IT_VBRP-VBELN.
IF P_ALV = 'X'.
define imacro.
wa_fcat-fieldname = &1.
wa_fcat-tabname = &2.
wa_fcat-reptext_ddic = &3.
wa_fcat-col_pos = &4.
append wa_fcat to fcat.
clear wa_fcat.
end-of-definition.
imacro 'VBELN' 'it_vbrk' 'PO Document' '1'.
imacro 'MATNR' 'it_vbrk' 'material no.' '2'.
imacro 'ARKTX' 'it_vbrk' 'Mat. description' '3'.
imacro 'NTGEW' 'it_vbrk' 'quantity' '4'.
imacro 'GEWEI' 'it_vbrk' 'quantity unit' '5'.
imacro 'NETWR' 'it_vbrk' 'net price' '6'.
imacro 'WERKS' 'it_vbrk' 'plant' '7'.
****************DEFINE LAYOUT
lyout-zebra = 'X'.
lyout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-cprog
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER'
I_CALLBACK_TOP_OF_PAGE = 'MY NAME'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'I M THAT'
I_GRID_SETTINGS =
IS_LAYOUT = lyout
IT_FIELDCAT = fcat
TABLES
T_OUTTAB = IT_VBRP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
ELSE.
LOOP AT IT_VBRP INTO WA_VBRP.
WRITE: /5 WA_VBRP-VBELN, WA_VBRP-MATNR.
ENDLOOP.
ENDIF.
Cheers,
Rudhir -
Hierarhical reports in alv reporting
I dont know what is the use of hierarhical reports.
explain it. if possible give one example.
thanks®ards
G.ANJAN KUMARhi,
REPORT Zxxx NO STANDARD PAGE HEADING.
TABLES: VBAK,VBAP.
TYPE-POOLS: SLIS.
TYPE-POOLS: ICON.
***DATA DECLN.
DATA: V_VBELN LIKE VBAK-VBELN,
V_AUART LIKE VBAK-AUART,
V_TABIX LIKE SY-TABIX.
***FIELD CATALOG.
DATA: ITAB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
ITAB_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
IT_COLOR TYPE SLIS_COLTYPES occurs 0 with header line,
WA_COLOR TYPE SLIS_COLTYPES.
***SORTING
DATA: ITAB_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV.
***events
DATA: IT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,
***VARIANTS
IT_VARIANT LIKE DISVARIANT OCCURS 0 WITH HEADER LINE.
FOR LAYOUT
DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_KEYINFO TYPE SLIS_KEYINFO_ALV,
WA_USER TYPE SLIS_EXIT_BY_USER.
DATA : V_REPID TYPE SY-REPID,
V_CALL TYPE C.
***INTERNAL TABLE DECLN.
DATA: BEGIN OF IT_VBAK OCCURS 0,
VBELN LIKE VBAK-VBELN,
AUDAT LIKE VBAK-AUDAT,
AUART LIKE VBAK-AUART,
NETWR LIKE VBAK-NETWR,
EXPAND(1),
END OF IT_VBAK.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
PSTYV LIKE VBAP-PSTYV,
CHARG LIKE VBAP-CHARG,
END OF IT_VBAP.
***SELECTION-SCREEN.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
SELECT-OPTIONS: S_AUART FOR VBAK-AUART.
SELECTION-SCREEN: END OF BLOCK B1.
***AT SELECTION-SCREEN.
AT SELECTION-SCREEN.
IF S_VBELN IS NOT INITIAL.
SELECT SINGLE VBELN
INTO V_VBELN
FROM VBAK
WHERE VBELN IN S_VBELN.
ENDIF.
IF S_AUART IS NOT INITIAL.
SELECT SINGLE AUART
INTO V_AUART
FROM VBAK
WHERE AUART IN S_AUART.
ENDIF.
*****START-OF-SELECTION.
START-OF-SELECTION.
V_REPID = SY-REPID.
PERFORM GET_DATA_VBAK.
PERFORM GET_DATA_VBAP.
***END-OF-SELECTION.
END-OF-SELECTION.
PERFORM GET_FIELCAT.
PERFORM MODIFY_FLDCAT.
PERFORM MOD_LAYOUT.
PERFORM COL_TYPES.
PERFORM SORT_TAB.
PERFORM HIER_DISP.
*& Form GET_DATA_VBAP
text
--> p1 text
<-- p2 text
FORM GET_DATA_VBAK .
SELECT VBELN
AUDAT
AUART
NETWR FROM VBAK
INTO TABLE IT_VBAK
WHERE VBELN IN S_VBELN
AND AUART IN S_AUART.
ENDFORM. " GET_DATA
*& Form GET_DATA_VBAP
text
--> p1 text
<-- p2 text
FORM GET_DATA_VBAP .
SELECT VBELN
POSNR
MATNR
PSTYV
CHARG
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FOR ALL ENTRIES IN IT_VBAK
WHERE VBELN = IT_VBAK-VBELN.
ENDFORM. " GET_DATA_VBAP
*& Form GET_FIELCAT
text
--> p1 text
<-- p2 text
FORM GET_FIELCAT .
CLEAR WA_FLDCAT.
WA_FLDCAT-FIELDNAME = 'Sales Doc.No.'.
WA_FLDCAT-TABNAME = it_vbap.
WA_FLDCAT-NO_OUT = 'X'.
WA_FLDCAT-NO_SUM = 'X'.
APPEND WA_FLDCAT TO ITAB_FIELDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-FIELDNAME = 'Sales Item No.'.
WA_FLDCAT-TABNAME = it_vbap.
WA_FLDCAT-NO_OUT = 'X'.
WA_FLDCAT-NO_SUM = 'X'.
APPEND WA_FLDCAT TO ITAB_FIELDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-FIELDNAME = 'Material No.'.
WA_FLDCAT-TABNAME = it_vbap.
WA_FIELDCAT-TECH = 'X'.
APPEND WA_FLDCAT TO ITAB_FIELDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-FIELDNAME = 'PSTYV'.
WA_FLDCAT-TABNAME = it_vbap.
WA_FLDCAT-NO_OUT = 'X'.
APPEND WA_FLDCAT TO ITAB_FIELDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-FIELDNAME = 'CHARG'.
WA_FLDCAT-TABNAME = it_vbap.
WA_FLDCAT-NO_OUT = 'X'.
APPEND WA_FLDCAT TO ITAB_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_VBAK'
I_STRUCTURE_NAME = VBAK
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = ITAB_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.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'IT_VBAP'
I_STRUCTURE_NAME = 'VBAP'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = ITAB_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.
ENDFORM. " GET_FIELCAT
*& Form HIER_DISP
text
--> p1 text
<-- p2 text
FORM HIER_DISP .
IT_VARIANT-REPORT = SY-REPID.
SORT IT_VBAK BY VBELN.
SORT IT_VBAP BY VBELN.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = ITAB_FIELDCAT[]
IT_SORT = ITAB_SORT
IS_VARIANT = IT_VARIANT
IT_EVENTS = IT_EVENTS[]
I_TABNAME_HEADER = 'IT_VBAK'
I_TABNAME_ITEM = 'IT_VBAP'
IS_KEYINFO = WA_KEYINFO
TABLES
T_OUTTAB_HEADER = IT_VBAK
T_OUTTAB_ITEM = IT_VBAP
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. " HIER_DISP
*& Form MODIFY_FLDCAT
text
--> p1 text
<-- p2 text
FORM MODIFY_FLDCAT .
LOOP AT ITAB_FIELDCAT INTO WA_FLDCAT.
IF WA_FLDCAT-FIELDNAME = 'EXPAND'.
IF WA_FLDCAT-TABNAME = 'IT_VBAK'.
WA_FLDCAT-NO_OUT = 'X'.
ENDIF.
ENDIF.
MODIFY ITAB_FIELDCAT FROM WA_FLDCAT.
CLEAR WA_FLDCAT.
ENDLOOP.
ENDFORM. " MODIFY_FLDCAT
*& Form MOD_LAYOUT
text
--> p1 text
<-- p2 text
FORM MOD_LAYOUT .
WA_LAYOUT-DEFAULT_ITEM = 'X'.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.
ENDFORM. " MOD_LAYOUT
*& Form SORT_TAB
text
--> p1 text
<-- p2 text
FORM SORT_TAB .
CLEAR WA_SORT.
WA_SORT-SPOS = '01'.
WA_SORT-FIELDNAME = 'VBELN' .
WA_SORT-TABNAME = 'IT_VBAK'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO ITAB_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = '02'.
WA_SORT-FIELDNAME = 'POSNR' .
WA_SORT-TABNAME = 'IT_VBAP'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO ITAB_SORT.
ENDFORM. " SORT_TAB
*& Form COL_TYPES
text
--> p1 text
<-- p2 text
FORM COL_TYPES .
clear wa_color.
wa_color-hearowfir-col = '6'.
wa_color-hearownex-col = '5'.
append wa_color to it_color.
ENDFORM. " COL_TYPES
Re: ALV Hierarchical Example
http://www.sap-img.com/abap/how-to-use-alv-for-hierarchical-lists.htm
Re: How to use ALV for Hierarchical Lists
hope this helps,
do reward if it helps,
priya. -
Hi there,
I added a column to an existing alv report which uses method 'set_table_for_first_display' to display the output.
The method is called via:
grid1 TYPE REF TO cl_gui_alv_grid,
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MAT_DATA'
is_layout = lt_layout
is_variant = lt_variant
i_default = lt_default
i_save = 'A'
it_toolbar_excluding = lt_exclude[]
CHANGING it_outtab = mat_data[]
it_fieldcatalog = w_fieldcat[]
EXCEPTIONS
program_error = 1.
The extra columns are in the field catalog and mat_data.
The lt_variant-report field has the report name in it.
When I run the report the new column does NOT appear.
I cleared out the lt_variant-report value and now the new column DOES appear.
Any idea why this is happening?
Is there some way I can leave the report name in there and see the new columns?
Thanks.thanks.
no_out is initial.
But, in this case, I am not passing any variant.
It works if I don't pass the report name in the
is_variant-report
field.The columns will not display if I pass the report name. -
Change column headers in ALV report
Hi experts,
I have created a new simple ALV report (it uses only internal tables, no structures). I would like to change the names of column headers in the ALV report. Is this possible? How can I do it?
Thanks in advanced.Thanks for your reply,
I am trying to use the code mentioned in the link but I think that something
is missing, probably a CASE statement before WHEN in the LOOP.
Can you help me? What do I have to put before WHEN statement?
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = <program name>
i_structure_name = <DDIC structure>
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = gi_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3. "#EC *
LOOP AT gi_fieldcat INTO wa_fieldcat.
WHEN 'XXXX'.
wa_fieldcat-seltext_s = 'Fac'.
wa_fieldcat-seltext_m = 'Factory'.
wa_fieldcat-seltext_l = 'Factory'.
wa_fieldcat-reptext_ddic = 'Factory'.
MODIFY gi_fieldcat FROM wa_fieldcat.
ENDLOOP. -
Reg : Dynamic Drown list in ALV Report
Hi Guru's,
Please help on showing Dynamic drop down list in ALV Report.
My requirement is to show sales partner function in ALV report for each and every line.Every line item may have different partner function.
Regards
P.Senthil Kumarok
-
Hi all,
I use top of page to print page number for ALV report. When i run my report in backgrond and see the spool, the page is always started from page 2.
These does not happen when I use non-ALV report, report prints the header starting from page 1 normally. It is weird.
does anyone of you ever face such of that problem ?
thanks alots
AliaHi Alia,
Page number is usually not set in an ALV display, as compared to List processing.
r u sure this is a requirement?
chk this:
ALV Print page numbers
Regards,
Anjali
Maybe you are looking for
-
Just upgraded to ios5, but now there is no speed button on the music player, so all the podcast play at slowww speed. The iphone still has the speed button. The repeat buttons still exist for the music, but for podcast no buttons. I have restored and
-
Hello. I have a problem working on one project. I have created a concordance search engine. My problem is: For e.g. now in real time one user is searching for a word and at the same time I'm or anybody else is searching for a word too. I put results
-
ITunes 8: still the same album artwork problem
hi! it seems that this is still an open question. the problem is that after installing iTunes 7.7.1 some of my (manually added) album artworks dissapeared and cannot fix this because no matter how hard i try i cannot recover the artworks (the same wa
-
Bamboo tablet stops working? USB uses too much power?
Dear sirs, Converted to macbook a year ago and so far I haven't had any problems, until this happened... I bought my new bamboo tablet less than three months ago and recently it has stopped working at random times- and then, this message pops up. "US
-
No third-party upgrades with smartphone loyalty plan?
Hi, I recently took VZW up on the offer of a $60 smartphone loyalty plan with a 1-year contract extension. They told me several times that I would keep my device upgrade option. Sounded like a great deal. I just tried to upgrade my device through Bes