ALV list with 2 header lines
Dear gurus,
Need help in displaying ALV list report. the below report is an example of AR aging report. The report output is as below:
DEC
NOV
OCT
SEP
0-30
31-60
61-90
90+
xx
xx
xx
xx
SUBTOTAL
The first 2 lines are the list header. While the 'x' is the amount.
How can i display the above output with 2 header lines? I was thinking of using the REUSE_ALV_FIELDCATALOG_MERGE function. But it will have 2 lines of body row too. In fact, i only one one row in the body. But if i define the header lines manually, i would not able to do the subtotal at the end of the alv list. I need to have the subtotal too.
Thanks in advance!
Hi,
For this requirement you need to populate the fld catalog using row_pos and col_pos fields specifing proper position.
See this code snippet ..... this is only possible for ALV list.
TYPE-POOLS: slis.
DATA: ld_fieldcat TYPE slis_fieldcat_alv.
DATA: t_alv_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv.
DATA : it_fld TYPE slis_t_fieldcat_alv,
wa_fld TYPE slis_fieldcat_alv.
data: BEGIN OF itab OCCURS 0,
carrid like sflight-carrid,
connid like sflight-connid,
planetype like sflight-planetype,
seatsmax like sflight-seatsmax,
END OF itab.
START-OF-SELECTION.
SELECT carrid connid planetype seatsmax
FROM sflight
INTO TABLE itab.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '1'.
ld_fieldcat-col_pos = '1'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'CARRID'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '1'.
ld_fieldcat-col_pos = '2'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'CONNID'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '2'.
ld_fieldcat-col_pos = '1'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'PLANETYPE'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '2'.
ld_fieldcat-col_pos = '2'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'SEATSMAX'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = t_alv_fieldcat[]
TABLES
t_outtab = ITAB. "internal table
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Amitava
Similar Messages
-
Hierarchical ALV list with control of printout and Excel download
Hello everybody,
i have to write a program, that has to generate a hierarchical master/client list. The list should
have the same functionality, that a standard ALV Grid
offers (sorting, grouping, OLE export to Excel). The printout must show a new sheet for every master group.
ALV grid does not allow to display hierarchical lists. The ALV hierarchical list and blocklist view switches to
text mode with no "single click Excel activation". I have tried to implement the &XXL ok_code, but in text mode, there is no chance to activate this single-table functionality.
Another possibility seems to be ALV tree, but there is no
possibility to control the printout (new sheet at group level) and the given practice, to load child nodes at selection, is not acceptable for my kind of program (all childs have to be expanded and the printout must contain a dialog to print i.e. a "from to group" selection).
Does anyone have an idea, to solve this problem in an easy object oriented way? my only thought at this time is, to use a standard ABAP list and to integrate Excel via document office integration. This gives me the fullcontrol about printout and export, but it needs far more time then ALV.
Another possibility may be, to develop a custom control, based on VS with Flexgrid, Singray or ComponentOne tools, but ich have to go as near as possible to SAP standard, without using 3rd party programming systems or controls.
I'm glad about tip's!
Greets from germany
JensJens,
Take a look at this for ideas:
REPORT Zsandbox_prog .
INCLUDE OLE2INCL.
field-symbols: <Val> type any.
data: row_cnt type i.
types: begin of t_Excel,
Material_Info(20),
Sugg_Price(20),
Cost(20),
Comments(100),
end of t_Excel.
data: r_Excel type t_Excel.
data: i_Excel type table of t_Excel with header line.
constants: xlCenter type i value '-4108',
xlBottom type i value '-4107',
xlLeft type i value '-4131',
xlRight type i value '-4152'.
constants: xlContinuous type i value '1',
xlInsideVertical type i value '11',
xlThin type i value '2',
xlLandscape type i value '2',
xlPortrait type i value '1',
xlLetter type i value '1',
xlLegal type i value '5',
xlThick type i value '4',
xlNone type i value '-4142',
xlAutomatic type i value '-4105'.
DATA: hExcel TYPE OLE2_OBJECT, " Excel object
hWorkBooks TYPE OLE2_OBJECT, " list of workbooks
hWorkbook TYPE OLE2_OBJECT, " workbook
hSheet TYPE OLE2_OBJECT, " worksheet object
hRange TYPE OLE2_OBJECT, " range object
hRange2 TYPE OLE2_OBJECT, " range object
hBorders TYPE OLE2_OBJECT, " Border object
hInterior TYPE OLE2_OBJECT, " interior object - for coloring
hColumn TYPE OLE2_OBJECT, "column
hCell TYPE OLE2_OBJECT, " cell
hFont TYPE OLE2_OBJECT, " font
hSelected TYPE OLE2_OBJECT, " range object
hPicture TYPE OLE2_OBJECT, "picture object
hLogo TYPE OLE2_OBJECT. "Logo object
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECTION-SCREEN skip 1.
parameter: wraptext as checkbox.
SELECTION-SCREEN END OF BLOCK b1.
row_cnt = 1.
Perform Build_Dummy_Vals.
Perform Start_Excel.
Perform Build_Header_Line using row_cnt.
Perform Pass_Records using row_cnt.
Perform Release_Excel.
FORM Build_Dummy_Vals .
data: matnum(5) type n.
data: baseprice(3) type n.
do 5 times.
matnum = matnum + 50.
clear r_Excel.
concatenate 'Material ' matnum into r_Excel-material_info
separated by space.
r_excel-Sugg_Price = baseprice * matnum.
r_excel-Cost = ( baseprice * matnum ) / 2.
concatenate 'Comments for Material ' matnum into r_excel-Comments
separated by space.
append r_excel to i_Excel.
enddo.
ENDFORM. " Build_Dummy_Vals
Form Start_Excel.
CREATE OBJECT hExcel 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
get list of workbooks, initially empty
CALL METHOD OF hExcel 'Workbooks' = hWorkbooks.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF hWorkbooks 'Add' = hWorkbook.
PERFORM ERR_HDL.
Get Worksheet object.
get property of hWorkbook 'ActiveSheet' = hSheet.
EndForm.
FORM Build_Header_Line using p_row_cnt.
data: l_range(30).
data: row_start(10).
PERFORM Fill_The_Cell USING p_row_cnt 1 1 'Material'.
PERFORM Fill_The_Cell USING p_row_cnt 2 1 'Suggested Price'.
PERFORM Fill_The_Cell USING p_row_cnt 3 1 'Cost'.
PERFORM Fill_The_Cell USING p_row_cnt 4 1 'Comments'.
Perform Format_Column using 1 15 xlCenter ' ' xlCenter 0.
Perform Format_Column using 2 10 xlCenter ' ' xlCenter 1.
Perform Format_Column using 3 35 xlCenter ' ' xlCenter 0.
if WrapText = 'X'.
Perform Format_Column using 4 35 xlLeft ' ' xlCenter 1.
else.
Perform Format_Column using 4 100 xlLeft ' ' xlCenter 0.
endif.
Build the range object.
row_start = p_row_cnt.
concatenate 'A' row_start ':D' row_start into l_range.
condense l_range no-gaps.
Set row color to yellow.
CALL METHOD OF hExcel 'RANGE' = hRange EXPORTING #1 = l_range.
call method of hRange 'Interior' = hInterior.
set property of hInterior 'ColorIndex' = 6. "yellow
p_row_cnt = p_row_cnt + 1.
ENDFORM. " Build_Header_Line
FORM Format_Column USING p_ColNum
p_ColWidth
p_ColHAlign
p_ColFormat
p_ColVAlign
p_WrapText.
CALL METHOD OF hExcel 'COLUMNS' = hColumn
EXPORTING #1 = p_ColNum . "column number
SET PROPERTY OF hColumn 'HorizontalAlignment' = p_ColHAlign.
SET PROPERTY OF hColumn 'VerticalAlignment' = p_ColVAlign.
SET PROPERTY OF hColumn 'ColumnWidth' = p_ColWidth.
SET PROPERTY OF hColumn 'WrapText' = p_WrapText.
ENDFORM. " Format_Column
Form Pass_Records using p_row_cnt.
data: col_cnt type i.
data: l_range(30).
data: row_start(10).
col_cnt = 1.
*Pass the internal table values to the spreadsheet.
loop at i_Excel into r_Excel.
do 4 times.
assign component sy-index of STRUCTURE r_excel TO <Val>.
PERFORM Fill_The_Cell USING p_row_cnt col_cnt 0 <Val>.
col_cnt = col_cnt + 1. "increment column
enddo.
Build the range object.
row_start = p_row_cnt.
concatenate 'A' row_start ':D' row_start into l_range.
condense l_range no-gaps.
Set row color to yellow.
CALL METHOD OF hExcel 'RANGE' = hRange EXPORTING #1 = l_range.
call method of hRange 'Interior' = hInterior.
set property of hInterior 'ColorIndex' = 7. "yellow
p_row_cnt = p_row_cnt + 1. "increment row
col_cnt = 1. "reset column to A (ie. col 1)
endloop.
EndForm.
FORM Release_Excel .
SET PROPERTY OF hExcel 'Visible' = 1.
FREE OBJECT hExcel.
PERFORM ERR_HDL.
ENDFORM. " Release_Excel
FORM Fill_The_Cell *
Sets cell at coordinates i,j to value val boldtype bold *
BOLD --> 1 = true, set bold ON 0 = false, set bold OFF
FORM Fill_The_Cell USING I J BOLD TheValue.
CALL METHOD OF hExcel 'Cells' = hCell EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF hCell 'Value' = TheValue.
PERFORM ERR_HDL.
GET PROPERTY OF hCell 'Font' = hFont.
PERFORM ERR_HDL.
SET PROPERTY OF hFont 'Bold' = BOLD.
PERFORM ERR_HDL.
ENDFORM.
FORM ERR_HDL.
IF SY-SUBRC <> 0.
message i000(zz) with 'OLE Automation error: ' SY-SUBRC.
exit.
ENDIF.
ENDFORM. " ERR_HDL -
With header line & with out header line ?
what is difference between with header line & without header line ?
When you create an internal table object you can also declare a header line with the same name. You can use the header line as a work area when you process the internal table. The ABAP statements that you use with internal tables have short forms that you can use if your internal table has a header line. These statements automatically assume the header line as an implicit work area. The following table shows the statements that you must use for internal tables without a header line, and the equivalent statements that you can use for internal tables with a header line:
Operations without header line
Operations with header line
Operations for all Table Types
INSERT <wa> INTO TABLE <itab>.
INSERT TABLE ITAB.
COLLECT <wa> INTO <itab>.
COLLECT <itab>.
READ TABLE <itab> ... INTO <wa>.
READ TABLE <itab> ...
MODIFY TABLE <itab> FROM <wa> ...
MODIFY TABLE <itab> ...
MODIFY <itab> FROM <wa> ...WHERE ...
MODIFY <itab> ... WHERE ...
DELETE TABLE <itab> FROM <wa>.
DELETE TABLE <itab>.
LOOP AT ITAB INTO <wa> ...
LOOP AT ITAB ...
Operations for Index Tables
APPEND <wa> TO <itab>.
APPEND <itab>.
INSERT <wa> INTO <itab> ...
INSERT <itab> ...
MODIFY <itab> FROM <wa> ...
MODIFY <itab> ...
Using the header line as a work area means that you can use shorter statements; however, they are not necessarily easier to understand, since you cannot immediately recognize the origin and target of the assignment. Furthermore, the fact that the table and its header line have the same name can cause confusion in operations with entire internal tables. To avoid confusion, you should use internal tables with differently-named work areas.
The following example shows two programs with the same function. One uses a header line, the other does not.
With header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
WITH HEADER LINE.
DO 4 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
INSERT TABLE ITAB.
ENDDO.
ITAB-COL1 = 2.
READ TABLE ITAB FROM ITAB.
ITAB-COL2 = 100.
MODIFY TABLE ITAB.
ITAB-COL1 = 4.
DELETE TABLE ITAB.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.
Without header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
WA LIKE LINE OF ITAB.
DO 4 TIMES.
WA-COL1 = SY-INDEX.
WA-COL2 = SY-INDEX ** 2.
INSERT WA INTO TABLE ITAB.
ENDDO.
WA-COL1 = 2.
READ TABLE ITAB FROM WA INTO WA.
WA-COL2 = 100.
MODIFY TABLE ITAB FROM WA.
WA-COL1 = 4.
DELETE TABLE ITAB FROM WA.
LOOP AT ITAB INTO WA.
WRITE: / WA-COL1, WA-COL2.
ENDLOOP.
The list, in both cases, appears as follows:
1 1
2 100
3 9
The statements in the program that does not use a header line are easier to understand. As a further measure, you could have a further work area just to specify the key of the internal table, but to which no other values from the table are assigned.
Internal table with header line
you can use anywhere except obkect oriented concept.
Internal table without header line :
You should use in Object oriented concept..
Always try to use without header line,performance point of view it is best..
Example :
Without header line.
Structure
types : begin of ty_itab ,
matnr type mara-matnr,
end of ty_itab.
Internal table
data i_itab type standard table of ty_itab .
Work area
data wa_itab like line of i_itab
With header line
data : begin of i_itab occurs 0,
matnr like mara-matnr,
end of i_itab
itab with header lines are obsolete, anyway it will work but not recommended. instead use work area or more effiecient is field symbols. so donot use itab with header line.
i will explain use of itab w/o header line.
Data: itab1 type standard table of mara with header line occurs 0,
itab2 type standard table of mara,
wa_itab2 type mara.
loop at itab1.
"This will work fine.
endloop.
loop at itab2.
"This will give erro that itabd does not hav workarea
endloop.
"so write
loop at itab2 into wa_itab2.
"This will work
endloop.
<b>The difference between
whih header line and with out heater line of internal table.
ex:-
a) Data : itab like mara occurs 0 with header line.
b) Data: itab like mara occurs 0.
-While adding or retrieving records to / from internal table we have to keep the record temporarily.
-The area where this record is kept is called as work area for the internal table.
-The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
-Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
a) Data : itab like mara occurs 0 with header line.
table is with header line
b) Data: itab like mara occurs 0.
table is without header line</b>
regards,
srinivas
<b>*reward for useful answers*</b> -
Hi guru's,
I want to create an ALV list with only a char255 field.
<all_table> contains data of sflight and is of type sflight(dynamically).
I want to show the data as one line.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = 'TPPARFIL'
fieldname = 'LINE'
TABLES
dfies_tab = it_dfies.
READ TABLE it_dfies INDEX 1.
IF sy-subrc IS INITIAL.
MOVE-CORRESPONDING it_dfies TO wa_fieldcat.
wa_fieldcat-scrtext_s = 'Results:'.
APPEND wa_fieldcat TO gt_fieldcat.
ENDIF.
t_output[] = <all_table>.
CALL FUNCTION 'LVC_TRANSFER_TO_SLIS'
EXPORTING
it_fieldcat_lvc = gt_fieldcat
IMPORTING
it_fieldcat_alv = it_fieldcat_alv.
PERFORM fill_alv_layout.
* Show list
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = lv_repid
i_grid_title = sy-title
is_layout = gs_layout
it_fieldcat = it_fieldcat_alv[]
TABLES
t_outtab = t_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form fill_alv_layout
FORM fill_alv_layout.
CLEAR: gs_layout.
gs_layout-max_linesize = 160.
gs_layout-min_linesize = 160.
gs_layout-detail_initial_lines = 'X'.
gs_layout-zebra = 'X'.
gs_layout-edit_mode = 'A'.
gs_layout-numc_sum = 'X'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-window_titlebar = sy-title.
gs_layout-totals_only = 'X'.
ENDFORM. " fill_alv_layout
When I run this it only gives an empty view of the fields with type char255.
Regards,
Wimhi,
As per your code I think your internal table is empty. Please set debugger after internal table fill and check. If the data is there then please check your field catalog entry.
Regards,
Sachin -
BADI cant use an internal table with header line
hi,
In BADI, we cant use an internal table with header line, and I am calling a function module which requires internal table as import parameter, now, the table I am passing is without a header line, So how to solve this problem ?You can use a type and then create an internal table of that type.
types :
begin of t_<example>
*field list
end of t_<example>
data :
gt_<table> type standard table of t_<example>
pass this to the FM -
Printing ALV list with ADS (pdf printer) in non-english charset
Hello!
I have an issue about printing alv list with pdf printer in non-english charset. We have two printers. One for alv lists (SWINCF: Casc.Fonts SAPWIN Unicode) and one for pdf forms(adobe document service). I want to use one printer for any documents. But PDF printer prints non-english charset like ########.
What can I do ?Hi, Roman!
I want to use PDF printer for both types of output. I have a dedicated java instance for ADS.
There is a device type for our Kyocera Printer. My pdf printer prints ALV list good exept russian charset.
It prints like ##### -
Passing an internal table WITH HEADER LINE to abap object
Hi. In another thread, it was explained how to pass an internal table to an abap object method. Is it possible to pass an internal table that has a header line, and RETAIN the header line once the table has been passed?
My problem is, that I can pass the table, update it, but the read buffer is not populated when returning from the object's method. This is the result of being able to pass a STANDARD TABLE type, but not a STANDARD TABLE WITH HEADER LINE.
This means that I have to read the table into a work area instead of doing a READ TABLE LKNA1 within the method, which is what I need to do.
Thanks.Please check this sample program, notice that it is modifing the internal table and passing it back modified as well as passing the "work area" or "header line" back thru the exporting parameter.
report zrich_0001.
* CLASS lcl_app DEFINITION
class lcl_app definition.
public section.
types: t_t001 type table of t001.
class-data: it001 type table of t001.
class-data: xt001 like line of it001.
class-methods: change_table
exporting ex_wt001 type t001
changing im_t001 type t_t001.
endclass.
data: w_t001 type t001.
data: a_t001 type table of t001 with header line.
start-of-selection.
select * into table a_t001 from t001.
call method lcl_app=>change_table
importing
ex_wt001 = w_t001
changing
im_t001 = a_t001[] .
check sy-subrc = 0.
* CLASS lcl_app IMPLEMENTATION
class lcl_app implementation.
method change_table.
loop at im_t001 into xt001.
concatenate xt001-butxt 'Changed'
into xt001-butxt separated by space.
modify im_t001 from xt001.
endloop.
ex_wt001 = xt001.
endmethod.
endclass.
Regards,
Rich Heilman -
Receiver file Content Conversion with Header line
Hi,
Here I am doing receiver file content conversion with header line.
I am able to get the output file correct, when I open the file in notepad the header line and data appearing in the same line (not accepted).
But when I tried to open the name file in internet explorer I can see the header line and data in two different lines (accepted).
What should I do I want to see the same output in the notepad?
Please help me out.
Thanks in advance,
Srikanth.You can use NameA.addHeaderLine.
Specify whether the text file will have a header line with column names. The following values are permitted:
0 u2013 No header line
1 u2013 Header line with column names from the XML document
2 u2013 As for 1, followed by a blank line
3 u2013 Header line is stored as NameA.headerLine in the configuration and is applied
4 u2013 As for 3, followed by a blank line
The below weblinks will help you to know the other paramters.
http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
http://help.sap.com/saphelp_nwpi71/helpdata/en/44/686e687f2a6d12e10000000a1553f6/content.htm -
Getting error of Defining an internal table with header line, SELECT-OPTIO
Hi all,
i have a coding for my smart form,In this coding i have define an structure which being used,but when i execute it it give me
error of Defining an internal table with header line, SELECT-OPTIONS, and RANGES is not allowed within a structure.Even tough you can see that in my coding im not using SELECT-OPTION or RANGES,but can't understand why it gives me this error.
Following are the code:
DATA: BEGIN OF traptab OCCURS 50.
INCLUDE STRUCTURE mseg.
DATA: vgart LIKE mkpf-vgart,
blart LIKE mkpf-blart,
blaum LIKE mkpf-blaum,
bldat LIKE mkpf-bldat,
budat LIKE mkpf-budat,
cpudt LIKE mkpf-cpudt,
cputm LIKE mkpf-cputm,
aedat LIKE mkpf-aedat,
usnam LIKE mkpf-usnam,
tcode LIKE mkpf-tcode,
xblnr LIKE mkpf-xblnr,
bktxt LIKE mkpf-bktxt,
frath LIKE mkpf-frath,
frbnr LIKE mkpf-frbnr,
wever LIKE mkpf-wever,
END OF traptab.
Thanks & Regards,
sappk25thanks
-
Dynamicly creating an internal table with header line
Hi experts,
I am trying to do a read on an internal table using field symbols of type any table. To be able to read more than one row at once, I'd like to read it into another internal table (instead of just one line and instead of looping through them one by one).
So far the following line rendered an error that the target internal table doesn't have a header line
read table <fs_v_tab> WITH KEY (<fs_comp>) = <fs_param>-low INTO <fs_v_tab>.
(also attempted using "<fs_v_tab>->*" & "<fs_v_tab>[]" to be silly)
Based on the following article, I was wondering if it were possible to dynamicly create an internal table with header line.
[http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html|http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html]
Any help or tips on how to dynamicly filter an internal table field-symbol is greatly appreciated!Just read the online help:
This statement reads a row from internal table itab.
Or more exact:
This statement reads one row from internal table itab.
Therefore you can not read multiple lines into another table. The header line is needed to put the result in. And this is not what you intended, the result will be in the header line, not in the table itself.
If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
At least you have to do what you dont wanna do: looping. -
Alternative for 'WITH HEADER LINE' ?
Hello All,
In BSP's I gues we can't use table with header lines and occurs 0.
SO whts the alternative for this ?
I want to use the FM 'GET_COMPONENT_LIST' .
To this FM I need to pass the table which is declared with occurs 0 or with header line .
Eg:
DATA: lt_cols TYPE STANDARD TABLE OF it_cols with header line.
DATA: v_count TYPE i.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'LT_COLS'
TABLES
components = itab[].
DESCRIBE TABLE itab LINES v_count.
WRITE v_count.
" I've used the following code :
DATA: ls_final_t TYPE STANDARD TABLE OF mara initial size 10 ,
lt_rstrucinfo TYPE TABLE OF rstrucinfo .
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = 'CL_O243NHIEBSRAZZG8RPTVGL3YAH9CP'
fieldname = 'LS_FINAL_T'
TABLES
components = lt_rstrucinfo[].
But it's not working .
I guess the problem is wid passage of parameter for program.
Bcoz i tried the same in the ABAP Program and it's working !
SO can any one tell me what to pass for the program ?
I tried with sy-repid , hardcoded my BSP application name , but none of them worked !!!
Can anyone help me out ?
Regards,
Deepu.KHi Depp,
The problem with your code example is that you should not have used the [] addition to the table name.
Try this...
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = 'CL_O243NHIEBSRAZZG8RPTVGL3YAH9CP'
fieldname = 'LS_FINAL_T'
TABLES
components = lt_rstrucinfo. "Note change here!
It is a good idea to get used to working with tables without header lines. I like to use data references where possible.
For example...
DATA: i_tab TYPE TABLE OF sflight,
w_ref TYPE REF TO sflight.
* Append line to table
APPEND INITIAL LINE TO i_tab REFERENCE INTO w_ref.
w_ref->carrid = 'AA'.
w_ref->connid = '123'.
* Loop through table
LOOP AT i_tab REFERENCE INTO w_ref.
WRITE: / `ConnID is `, w_ref->connid.
ENDLOOP.
* Read line
READ TABLE i_tab REFERENCE INTO w_ref WITH KEY connid = '123'.
Cheers
Graham Robbo -
Occurs & with header line in Data definition
Hi,
i did an slin-check for one of my includes and got the following errors shown:
Abap-command is obsolete
1st: tables with headers are not supported in OO-context anymore. (message G1D)
2nd: the appendix occurs is not supported in OO-context. use "table of.... initial size" instead.
the line were the error occurs is:
DATA: BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.
what should i do here?
\[removed by moderator\]
Edited by: Jan Stallkamp on Jul 17, 2008 12:33 PMHi
Use
DATA: BDCDATA TYPE TABLE OF BDCDATA.
(OR)
DATA: BDCDATA TYPE <table_kind> TABLE OF BDCDATA.
(<table_kind> = Standard / Sorted / Hashed )
Hope this would help you.
Murthy -
Why does my internal table(with header line) ignore 4 of its fields?
Hi Gurus,
I am a newbie to ABAP how has spent far to much of my weekend time trying to solve the following problem;
when trying to insert data from table cdpos into my internal table, I only get the two object* fields, the other 3 are not even part of the internal table according to the debugger.
my select code is:
SELECT fname tabkey changenr objectclas objectid
FROM cdpos
INTO CORRESPONDING FIELDS OF i_cd_index
WHERE tabname = 'XXX'
AND fname = 'XXX'
AND chngind = 'U'
ENDSELECT.
IF sy-subrc <> 0.
ENDIF.
- If I use a wa like line of i_cd_index the other fields will show up.
- I have tried with including 'TABLE' in the INTO statement, same result.
Please help out, getting very frustrated here....
/MikeHi Magdic,
I have completely coded for but i have taken as parameters rather direct values (XXXX). Under stand the code and select statement you will get it. Program which i have shown is working fine.
Do one thing first go the table CDPOS take one entry of Objectid, Tabname, fname and chngind and then enter in the selection and find whether the values are fetched correctly or not.
To my knowledge there might be no data in your table.
Anyhow try the below code.
TABLES: CDPOS.
DATA: ITAB LIKE CDPOS OCCURS 0 WITH HEADER LINE.
parameters: p_CHGID like CDPOS-chngind,
p_TAB like CDPOS-TABNAME,
P_FNAM LIKE CDPOS-FNAME.
SELECT OBJECTID TABNAME FNAME CHNGIND FROM CDPOS INTO CORRESPONDING FIELDS OF ITAB WHERE OBJECTID = P_CHGID
AND TABNAME = P_TAB
AND FNAME = P_FNAM.
APPEND ITAB.
ENDSELECT.
WRITE: ITAB-OBJECTID, ITAB-TABNAME, ITAB-FNAME, ITAB-CHNGIND.
Cheers!!
Balu -
Error: Tables with Header line No longer Supported In WD-ABAP
Hi folks,
I am working on WD4A functionality.I have to use Abap code to retrive data from database and i am doing it by declaring internal table with header line in one of the Methods.I have to do manipulation on table before i can bind table to result node.I can do manipulation in Header in ABAP,but now it is no longer supported in WD4A.What can i do for this?
Nirad.hi nirad.
The example is not of much sense
but explains the funtionality. Hope this is what you are searching for.
data:
lt_flights type table of sflight.
data:
ls_flight type sflight.
select * from sflight
into corresponding fields of table lt_flights.
loop at lt_flights into ls_flight.
ls_flight-price = 1000.
modify lt_flights from ls_flight.
endloop.
Cheers,
Sascha -
Dynamic Creation of Internal table WITH HEADER LINE
Dear,
Please show me the way of creating Internal table WITH HEADER LINE dynamically..
Thanks,
Nirav<font color='blue'>Hi Parekh,
Have a look at the sample program for Dynamic internal table
This program has been developed to update any table data in the dictionary. We give table name and File name as Input fields.
<pre>
REPORT znpmmm0201.
*Types
TYPES:
BEGIN OF ty_file,
data(4096) TYPE c,
END OF ty_file.
*Type-pools
TYPE-POOLS:
truxs.
*Work areas
DATA:
wa_file TYPE ty_file.
*Internal tables
DATA:
it_file TYPE STANDARD TABLE OF ty_file,
it_data TYPE truxs_t_text_data.
DATA:
gv_dref TYPE REF TO data,
file_name TYPE string.
*FIELD-SYMBOLS
FIELD-SYMBOLS:
<gf_itab> TYPE STANDARD TABLE,
<wa> TYPE ANY.
*& Selection-screen
PARAMETERS:
p_table TYPE rsrd1-tbma_val,
p_file TYPE ibipparms-path.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_for_p_file CHANGING file_name .
*& START-OF-SELECTION
START-OF-SELECTION.
CREATE DATA gv_dref TYPE TABLE OF (p_table).
ASSIGN gv_dref->* TO <gf_itab>.
PERFORM upload_data USING file_name.
MODIFY (p_table) FROM TABLE <gf_itab>.
*& Form UPLOAD_DATA
FORM upload_data USING file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
TABLES
data_tab = it_file.
APPEND LINES OF it_file TO it_data.
CLASS cl_abap_char_utilities DEFINITION LOAD.
DATA: l_field_seperator.
l_field_seperator = cl_abap_char_utilities=>horizontal_tab.
REPLACE ALL OCCURRENCES OF '|' IN TABLE it_data WITH l_field_seperator.
CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
EXPORTING
i_field_seperator = l_field_seperator
i_tab_raw_data = it_data
TABLES
i_tab_converted_data = <gf_itab>.
ENDFORM. " UPLOAD_DATA
*& Form F4_FOR_p_file
FORM f4_for_p_file CHANGING file.
DATA:
l_field_name LIKE dynpread-fieldname VALUE 'P_FILE'.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = l_field_name
IMPORTING
file_name = p_file.
file = p_file.
ENDFORM. " F4_FOR_p_file </pre>
Thanks,
Venkat.O</font>
Maybe you are looking for
-
What PC to build? An update...
What PC to build, updated January 2012 A question often asked is what system to build for NLE. The previous article about this topic dates back to March 2010, so it was due an update because there were so many new developments in the past two years,
-
Error while configuring SAP authentication in CMC adn Win XP PRO
Hi, I am new to Business Objects and i was installing the Business Objects integartion Kit for SAP. I have already installed Crystal Server 2008 and copied the SAP Jco to the specified folders.But whiling trying to configure the SAP authenticatuion,
-
Application form error related to Smartform
Hi , I am working on an Application form with a smart form as a Form Type. When I execute the Correpondence printing I get an errror : 'Graphic cannot be displayed'. But my smartform doesnot have any graphic in it. Can anyone help me on this topic. T
-
How can I upgrade lightroom 2.7 to 3.7 or 4 ?
how can I upgrade lightroom 2.7 to 3.7 or 4 ?
-
SSM KPI weighted consolidation
Hello, I am using SSM 10.1 and I want to create a measure (mea3) from another measure (mea1) with consolidation among dimensions weighted by other measure (mea2). The value of mea3 must calculated using the following formula mea3 = mea1 * mea2 / sum(