02-04-2008 6:37 AM
Problem with ALV display,
I would like to display my internal table records as formated like this:
In my internel table I am having the following colums : Col1, Col2, Col3, Col4, Col5, Col6, Col7. And I want to display them like this format and subsequent values:
Col1 | Col3 | Col5 | Col7
Col2 | Col4 | Col6|
can I have the logic or the code if possible.
Thanks,
Sridhar
02-04-2008 6:40 AM
hi sridhar,
you can use ROW-POS in FIELDCATALOGUE FOR THE DESIRED OUTPUT
Row_pos (row position): Only relevant if the list output is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output.
Value set: 0, 1 3
Example: Here Row_pos is set to 2 for ITEM NUMBER.
reward points if helpful,
Rohan
02-04-2008 6:40 AM
hi sridhar,
you can use ROW-POS in FIELDCATALOGUE FOR THE DESIRED OUTPUT
Row_pos (row position): Only relevant if the list output is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output.
Value set: 0, 1 3
Example: Here Row_pos is set to 2 for ITEM NUMBER.
reward points if helpful,
Rohan
02-04-2008 6:45 AM
02-04-2008 6:53 AM
hi madhvi,
here's the code
&----
*& Form zf_build_fieldcat
&----
text
----
-->P_I_FIELDCAT text
----
form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv. "local Workarea used
clear l_fieldcat.
V_LIGHTS(1) TYPE C, " FOR TRAFFIC LIGHTS.
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_LIGHTS'.
" FIELD FOR WHICH CATALOG ID FILLED.
*We are passing final internal table 'I_FINAL' to l_fieldcat(local
*variable
l_fieldcat-tabname = 'I_SALES_FINAL'.
" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-outputlen = 20.
" TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
FIRST COLUMN ********************************
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
*l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'X'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Sales Document'. " long text for header.
l_fieldcat-seltext_m = 'Sales Doc'. " medium text for header.
l_fieldcat-seltext_s = 'Sales Doc'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
POSNR
l_fieldcat-row_pos = '2'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Sales Document Item'. " long text for header.
l_fieldcat-seltext_m = 'Sales Document Item'. " medium text for header.
l_fieldcat-seltext_s = 'Sales Document Item'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
*MATNR
l_fieldcat-row_pos = '3'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Material no'. " long text for header.
l_fieldcat-seltext_m = 'Material no'. " medium text for header.
l_fieldcat-seltext_s = 'Material no'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
*DESCRIPTION
l_fieldcat-col_pos = '5'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
*l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Material Description'. " long text for header.
l_fieldcat-seltext_m = 'Material Desc'. " medium text for header.
l_fieldcat-seltext_s = 'Description'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'MAKT'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
endform. " zf_build_fieldcat
but it would work during priting of output and print preview
FOr viewing in outpout you have to use FM
REUSE_ALV_HIERSEQ_LIST_DISPLAY in your code
regards,
rohan malik
02-04-2008 6:41 AM
u can use a FM REUSE_ALV_HEIRAR_DISPLAY
(I'M NOT SURE ABOUT THE FM NAME IT IS FOR HEIRARCHICAL DISPLAY)
here u can pass two internal tables
first one will have elements of first row
second one will have elements of second row.
i will send you a sample code
reward if useful
vivek
02-04-2008 6:42 AM
wa_keyinfo-header01 = 'EBELN'.
wa_keyinfo-item01 = 'EBELN'.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = v_progname
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
is_layout = wa_layout1
it_fieldcat = it_fieldcat1
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
it_events = it_eventcat
IT_EVENT_EXIT =
i_tabname_header = 'IT_HEADER'
i_tabname_item = 'IT_ITEMS'
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
is_keyinfo = wa_keyinfo
IS_PRINT =
IS_REPREP_ID =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
IR_SALV_HIERSEQ_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = it_header
t_outtab_item = it_items
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.
plz reward if useful
02-04-2008 6:46 AM
Hello Sirdhar,
You want to print like this format,
Col1 | Col3 | Col5 | Col7
Col2 | Col4 | Col6|
Use REUSE_ALV_HIERSEQ_LIST_DISPLAY.
Make Col1 | Col3 | Col5 | Col7 as header fields and remaining fields as line item fields.
Reward If Helpful.
Regards
--
Sasidhar Reddy Matli.
02-04-2008 6:46 AM
Hi,
USE Field catlog to do so...
row_pos like sy-curow, " output in row
l_fieldcat-col_pos = '2'." position of the column
l_fieldcat-fieldname = 'VBELN'.
l_fieldcat-tabname = 'IT_VBAK_VBAP'.
currency(5) type c,decimal places of the field with currency unit
cfieldname type slis_fieldname, " field with currency unit
ctabname type slis_tabname, " and table
l_fieldcat-ifieldname = ''. " initial column
quantity(3) type c,
qfieldname type slis_fieldname, " field with quantity unit
qtabname type slis_tabname, " and table
round type i, " round in write statement
exponent(3) type c, " exponent for floats
l_fieldcat-key = 'X'." column with key-color
icon(1) type c, " as icon
symbol(1) type c, " as symbol
checkbox(1) type c, " as checkbox
l_fieldcat-just = 'R'." (R)ight (L)eft (C)ent.
l_fieldcat-lzero = 'X'." leading zero
no_sign(1) type c, " write no-sign
no_zero(1) type c, " write no-zero
no_convext(1) type c,
edit_mask type slis_edit_mask, "
emphasize(4) type c, " emphasize
fix_column(1) type c, " Spalte fixieren
do_sum(1) type c, " sum up
no_out(1) type c, " (O)blig.(X)no out
tech(1) type c, " technical field
outputlen like dd03p-outputlen,
offset type dd03p-outputlen, " offset
l_fieldcat-seltext_l = 'SALES ORDER NUMBER'. " long key word
l_fieldcat-seltext_m = 'SALES ORD. NO.'. " middle key word
l_fieldcat-seltext_s = 'SD NO.'. " short key word
ddictxt(1) type c, " (S)hort (M)iddle (L)ong
rollname like dd03p-rollname,
datatype like dd03p-datatype,
inttype like dd03p-inttype,
l_fieldcat-intlen = 20.
l_fieldcat-ref_fieldname = 'VBELN'.
l_fieldcat-ref_tabname = 'VBAK'.
roundfieldname
roundtabname
decimalsfieldname
decimalstabname
decimals_out(6) " decimals in write statement
text_fieldname
l_fieldcat-reptext_ddic = 'GAURAV'. " heading (ddic)
ddic_outputlen
key_sel(1) type c, " field not obligatory
l_fieldcat-no_sum = 'X'. " do not sum up
sp_group(4) type c, " group specification
reprep(1) type c, " selection for rep/rep
input(1) type c, " input
edit(1) type c, " internal use only
hotspot(1) type c, " hotspot
PLS REWARD IF USEFUL
GAURAV J>
02-04-2008 6:49 AM
Hi Sridher,
U need to use the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY in your code.Use the button PATTERN to get this FM.
In that,specify the following parameters:
Export Parameters:
I_TABNAME_HEADER : Name of the internal table in the program containing the output data of the highest hierarchy level.
I_TABNAME_ITEM : Name of the internal table in the program containing the output data of the lowest hierarchy level.
Tables parameters :
T_OUTTAB_HEADER : Header table with data to be output
T_OUTTAB_ITEM : Name of the internal table in the program containing the output data of the lowest hierarchy level.
Try this one & i hope u'll get it.....
Don forget to reward points if useful.....
Pavan.